Skip to content

Commit 3e31931

Browse files
committed
Fix: parse error when no expression follows after 'return', 'break', 'continue'
JerryScript-DCO-1.0-Signed-off-by: Hanjoung Lee hanjoung.lee@samsung.com
1 parent 4aaa0ac commit 3e31931

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

jerry-core/parser/js/parser.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2831,6 +2831,11 @@ parse_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (first) lab
28312831
}
28322832
}
28332833

2834+
if (token_is (TOK_CLOSE_BRACE))
2835+
{
2836+
lexer_save_token (tok);
2837+
}
2838+
28342839
JERRY_ASSERT (label_p != NULL);
28352840

28362841
jsp_label_add_jump (label_p, is_simply_jumpable, is_break);
@@ -2845,7 +2850,7 @@ parse_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (first) lab
28452850
}
28462851

28472852
skip_token ();
2848-
if (!token_is (TOK_SEMICOLON) && !token_is (TOK_NEWLINE))
2853+
if (!token_is (TOK_SEMICOLON) && !token_is (TOK_NEWLINE) && !token_is (TOK_CLOSE_BRACE))
28492854
{
28502855
const jsp_operand_t op = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP);
28512856
dump_retval (op);
@@ -2855,6 +2860,11 @@ parse_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (first) lab
28552860
else
28562861
{
28572862
dump_ret ();
2863+
2864+
if (token_is (TOK_CLOSE_BRACE))
2865+
{
2866+
lexer_save_token (tok);
2867+
}
28582868
return;
28592869
}
28602870
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2015 Samsung Electronics Co., Ltd.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
function f(){return}
16+
17+
switch (1) {
18+
case 1:
19+
break}
20+
21+
while (false) {continue}

0 commit comments

Comments
 (0)