disallow bindings to global variables (#2295)

pull/2321/head
Conduitry 6 years ago
parent d637211e3e
commit fa79a72348

@ -39,7 +39,7 @@ export default class Binding extends Node {
} else { } else {
const variable = component.var_lookup.get(name); const variable = component.var_lookup.get(name);
if (!variable) component.error(this.expression.node, { if (!variable || variable.global) component.error(this.expression.node, {
code: 'binding-undeclared', code: 'binding-undeclared',
message: `${name} is not declared` message: `${name} is not declared`
}); });

@ -0,0 +1,15 @@
[{
"code": "binding-undeclared",
"message": "foo is not declared",
"pos": 58,
"start": {
"line": 4,
"column": 19,
"character": 58
},
"end": {
"line": 4,
"column": 22,
"character": 61
}
}]

@ -0,0 +1,4 @@
<script>
console.log(foo);
</script>
<input bind:value={foo}>
Loading…
Cancel
Save