Commit 11406eb
Fix continue/break at first instruction of env-allocating block (Issue #1571)
A continue/break that is the first instruction inside a lexical block which
allocates an environment (e.g. `for(;c;){ continue; eval(); const x=1; }`) was
emitted as a plain Jump, skipping the block's CloseLexicalEnvironment. The
leaked environment then caused a subsequent outer-scope `const` to initialize
in the wrong environment, producing a spurious
`ReferenceError: Cannot access '...' before initialization`.
registerJumpPositionsToComplexCase compared jump positions against frontlimit
(= lexicalBlockStartPosition, the first body instruction) with strict `>`, so a
jump located exactly at the first body instruction was never morphed into a
JumpComplexCase and the block environment was left un-popped. Use `>=` for
break/continue/labelledBreak/labelledContinue.
With the environment now unwound correctly, the hasBinding guard band-aid in
InterpreterSlowPath::initializeByName is no longer needed and is removed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>1 parent df9078d commit 11406eb
2 files changed
Lines changed: 12 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
186 | 193 | | |
187 | | - | |
| 194 | + | |
188 | 195 | | |
189 | 196 | | |
190 | 197 | | |
191 | 198 | | |
192 | 199 | | |
193 | | - | |
| 200 | + | |
194 | 201 | | |
195 | 202 | | |
196 | 203 | | |
197 | 204 | | |
198 | 205 | | |
199 | | - | |
| 206 | + | |
200 | 207 | | |
201 | 208 | | |
202 | 209 | | |
203 | 210 | | |
204 | 211 | | |
205 | | - | |
| 212 | + | |
206 | 213 | | |
207 | 214 | | |
208 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1840 | 1840 | | |
1841 | 1841 | | |
1842 | 1842 | | |
1843 | | - | |
1844 | | - | |
1845 | | - | |
1846 | | - | |
| 1843 | + | |
1847 | 1844 | | |
1848 | 1845 | | |
1849 | 1846 | | |
| |||
0 commit comments