Repository navigation
Commit 52f91fd
committed
fix(compiler): reject var in unbraced branch body in Strong localInit
The scope-based check for whether a var is declared directly in a
function body incorrectly accepted vars inside unbraced if/while/do
bodies, because those control-flow statements do not create a new
scope. This meant `if (cond) var ready = await load();` was treated
as always-initialized, allowing a zero-delay effect-update bypass.
Replace the scope check with an AST-structural check that verifies
the VariableDeclarator belongs to a VariableDeclaration that is a
direct child statement of a function/module body.1 parent eac9426 commit 52f91fd
1 file changed
Lines changed: 17 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
56 | 72 | | |
57 | 73 | | |
58 | 74 | | |
| |||
300 | 316 | | |
301 | 317 | | |
302 | 318 | | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
| 319 | + | |
307 | 320 | | |
308 | 321 | | |
309 | 322 | | |
| |||
0 commit comments