Commit 9eacb3a
Fix variable resolution in switch statements with let declarations
Fixed the regression introduced by 2ba6e57, which made `switch`
a proper `Scope`.
The issue was that `Scope.splitScope()` creates an outer block scope
and moves the symbol table from the switch to the block, but doesn't
update the switch's `parentScope` pointer. This breaks the scope chain
used for variable resolution, causing it to skip the block where
symbols are stored.
Fixed by manually fixing the scope chain, and follow the same pattern as
`transformForLoop()` for manually managing `currentScope` instead
of using `pushScope`/`popScope`, since the scope hierarchy is modified
after parsing.1 parent ddf877c commit 9eacb3a
2 files changed
Lines changed: 40 additions & 2 deletions
File tree
- rhino/src/main/java/org/mozilla/javascript
- tests/src/test/java/org/mozilla/javascript/tests/es5
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1179 | 1179 | | |
1180 | 1180 | | |
1181 | 1181 | | |
| 1182 | + | |
1182 | 1183 | | |
1183 | | - | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
1184 | 1191 | | |
1185 | 1192 | | |
1186 | 1193 | | |
| |||
1205 | 1212 | | |
1206 | 1213 | | |
1207 | 1214 | | |
1208 | | - | |
| 1215 | + | |
1209 | 1216 | | |
1210 | 1217 | | |
1211 | 1218 | | |
| |||
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
97 | 128 | | |
0 commit comments