Skip to content

Commit 3d31bfe

Browse files
ruben-ayrapetyanegavrin
authored andcommitted
Fix parse of nested switch statements.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected]
1 parent 6e2733d commit 3d31bfe

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

jerry-core/parser/js/opcodes-dumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2340,9 +2340,9 @@ rewrite_default_clause (void)
23402340
void
23412341
finish_dumping_case_clauses (void)
23422342
{
2343-
STACK_DROP (U8, 1);
23442343
STACK_DROP (case_clauses, STACK_SIZE (case_clauses) - STACK_TOP (U8));
23452344
STACK_DROP (U8, 1);
2345+
STACK_DROP (U8, 1);
23462346
}
23472347

23482348
/**

tests/jerry/switch-case.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,25 @@ switch ("var") {
7373
}
7474

7575
assert (counter === 4);
76+
77+
var flow = '';
78+
79+
switch ("var") {
80+
case "var":
81+
flow += '1';
82+
case "var1":
83+
flow += '2';
84+
case "var2":
85+
flow += '3';
86+
switch (flow) {
87+
case '123':
88+
flow += 'a';
89+
break;
90+
default:
91+
flow += 'b';
92+
}
93+
default:
94+
flow += '4';
95+
}
96+
97+
assert (flow === '123a4');

0 commit comments

Comments
 (0)