-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 6794: var scope should not extend reactive block
Fixes: #6794
- Loading branch information
1 parent
547fbc6
commit 987aa30
Showing
8 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[{ | ||
"code": "invalid_var_declaration", | ||
"message": "\"var\" scope should not extend outside the reactive block", | ||
"start": { "line": 14, "column": 7, "character": 204 }, | ||
"end": { "line": 14, "column": 16, "character": 213 }, | ||
"pos": 204 | ||
}] |
20 changes: 20 additions & 0 deletions
20
test/validator/samples/invalid-reactive-var-1/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script> | ||
var a; | ||
var {a, b: [d, f], c}= {a: 1, b: [1, 2], c: 2}; | ||
$: { | ||
function one() { | ||
var a = 'a'; | ||
function two() { | ||
var a = 'b'; | ||
return a; | ||
} | ||
return two(); | ||
} | ||
a = one(); | ||
for (var i = 0; i<5; i ++ ) { | ||
// Todo | ||
} | ||
} | ||
</script> | ||
|
||
<h1>Hello {a}</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[{ | ||
"code": "invalid_var_declaration", | ||
"message": "\"var\" scope should not extend outside the reactive block", | ||
"start": { "line": 4, "column": 2, "character": 32 }, | ||
"end": { "line": 4, "column": 50, "character": 80 }, | ||
"pos": 32 | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<script> | ||
$: { | ||
let f = 'f'; | ||
var {a, b: [c, d], e} = {a: 1, b: [2, 3], e: 4}; | ||
} | ||
</script> | ||
|
||
<h1>Hello</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script> | ||
var name = 'name'; | ||
var c = 'cc'; | ||
let d = 'd'; | ||
$: { | ||
function a() { | ||
function b() { | ||
var c = 'c'; | ||
return c; | ||
} | ||
return b; | ||
} | ||
let d = 'dd'; | ||
name = a()(); | ||
} | ||
</script> | ||
|
||
<h1>Hello {name}</h1> |