Skip to content

Commit f20db76

Browse files
committed
Fix parse error of parse_switch_statement
Related issue: jerryscript-project#725 JerryScript-DCO-1.0-Signed-off-by: Hanjoung Lee hanjoung.lee@samsung.com
1 parent 17f7bad commit f20db76

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

jerry-core/parser/js/parser.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,7 +2447,7 @@ parse_switch_statement (void)
24472447
{
24482448
assert_keyword (KW_SWITCH);
24492449

2450-
const jsp_operand_t switch_expr = parse_expression_inside_parens ();
2450+
const jsp_operand_t switch_expr = dump_assignment_of_lhs_if_literal (parse_expression_inside_parens ());
24512451
token_after_newlines_must_be (TOK_OPEN_BRACE);
24522452

24532453
start_dumping_case_clauses ();
@@ -2529,7 +2529,6 @@ parse_switch_statement (void)
25292529
}
25302530

25312531
current_token_must_be (TOK_CLOSE_BRACE);
2532-
skip_token ();
25332532

25342533
jsp_label_rewrite_jumps_and_pop (&label,
25352534
serializer_get_current_instr_counter ());
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2015 Samsung Electronics Co., Ltd.
2+
// Copyright 2015 University of Szeged.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
try {
17+
eval("switch(foo){} {}");
18+
assert(false);
19+
} catch (e) {
20+
assert(e instanceof ReferenceError);
21+
}
22+

0 commit comments

Comments
 (0)