File tree 6 files changed +41
-2
lines changed
binding-invalid-value-global
6 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -1182,7 +1182,7 @@ export default class Component {
1182
1182
if ( name [ 0 ] === '$' ) return ; // $$props
1183
1183
}
1184
1184
1185
- if ( this . var_lookup . has ( name ) ) return ;
1185
+ if ( this . var_lookup . has ( name ) && ! this . var_lookup . get ( name ) . global ) return ;
1186
1186
if ( template_scope && template_scope . names . has ( name ) ) return ;
1187
1187
if ( globals . has ( name ) ) return ;
1188
1188
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ export default class Binding extends Node {
39
39
} else {
40
40
const variable = component . var_lookup . get ( name ) ;
41
41
42
- if ( ! variable ) component . error ( this . expression . node , {
42
+ if ( ! variable || variable . global ) component . error ( this . expression . node , {
43
43
code : 'binding-undeclared' ,
44
44
message : `${ name } is not declared`
45
45
} ) ;
Original file line number Diff line number Diff line change
1
+ [{
2
+ "code" : " binding-undeclared" ,
3
+ "message" : " foo is not declared" ,
4
+ "pos" : 58 ,
5
+ "start" : {
6
+ "line" : 4 ,
7
+ "column" : 19 ,
8
+ "character" : 58
9
+ },
10
+ "end" : {
11
+ "line" : 4 ,
12
+ "column" : 22 ,
13
+ "character" : 61
14
+ }
15
+ }]
Original file line number Diff line number Diff line change
1
+ <script >
2
+ console .log (foo);
3
+ </script >
4
+ <input bind:value ={foo }>
Original file line number Diff line number Diff line change
1
+ <script >
2
+ console .log (potato);
3
+ </script >
4
+
5
+ <p >{potato }</p >
Original file line number Diff line number Diff line change
1
+ [{
2
+ "code" : " missing-declaration" ,
3
+ "message" : " 'potato' is not defined" ,
4
+ "pos" : 46 ,
5
+ "start" : {
6
+ "line" : 5 ,
7
+ "column" : 4 ,
8
+ "character" : 46
9
+ },
10
+ "end" : {
11
+ "line" : 5 ,
12
+ "column" : 10 ,
13
+ "character" : 52
14
+ }
15
+ }]
You can’t perform that action at this time.
0 commit comments