-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from jow-/compiler-fix-switch-stack-mismatch
compiler: fix stack mismatch on continue statements nested in switches
- Loading branch information
Showing
3 changed files
with
48 additions
and
11 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,31 @@ | ||
When compiling continue statements nested in switches, the compiler only | ||
emitted pop statements for the local variables in the switch body scope, | ||
but not for the locals in the scope(s) leading up to the containing loop | ||
body. | ||
|
||
Depending on the context, this either led to infinite loops, wrong local | ||
variable values or segmentation faults. | ||
|
||
-- Testcase -- | ||
{% | ||
let n = 0; | ||
|
||
while (true) { | ||
let x = 1; | ||
|
||
switch (n++) { | ||
case 0: | ||
case 1: | ||
continue; | ||
} | ||
|
||
break; | ||
} | ||
|
||
print(n, '\n'); | ||
%} | ||
-- End -- | ||
|
||
-- Expect stdout -- | ||
3 | ||
-- End -- |