File tree 3 files changed +28
-1
lines changed
test/validator/samples/binding-let
3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,12 @@ export default class Binding extends Node {
31
31
this . is_contextual = scope . names . has ( name ) ;
32
32
33
33
// make sure we track this as a mutable ref
34
- if ( this . is_contextual ) {
34
+ if ( scope . is_let ( name ) ) {
35
+ component . error ( this , {
36
+ code : 'invalid-binding' ,
37
+ message : 'Cannot bind to a variable declared with the let: directive'
38
+ } ) ;
39
+ } else if ( this . is_contextual ) {
35
40
scope . dependencies_for_name . get ( name ) . forEach ( name => {
36
41
const variable = component . var_lookup . get ( name ) ;
37
42
variable [ this . expression . node . type === 'MemberExpression' ? 'mutated' : 'reassigned' ] = true ;
Original file line number Diff line number Diff line change
1
+ [{
2
+ "code" : " invalid-binding" ,
3
+ "message" : " Cannot bind to a variable declared with the let: directive" ,
4
+ "pos" : 52 ,
5
+ "start" : {
6
+ "line" : 6 ,
7
+ "column" : 8 ,
8
+ "character" : 52
9
+ },
10
+ "end" : {
11
+ "line" : 6 ,
12
+ "column" : 24 ,
13
+ "character" : 68
14
+ }
15
+ }]
Original file line number Diff line number Diff line change
1
+ <script >
2
+ let Foo;
3
+ </script >
4
+
5
+ <Foo let:bar >
6
+ <input bind:value ={bar }>
7
+ </Foo >
You can’t perform that action at this time.
0 commit comments