Fix: parse error when no expression follows after 'return', 'break', 'continue'

JerryScript-DCO-1.0-Signed-off-by: Hanjoung Lee hanjoung.lee@samsung.com
This commit is contained in:
Hanjoung Lee
2015-10-20 20:02:43 +09:00
parent 4aaa0ace17
commit 3e31931537
2 changed files with 32 additions and 1 deletions
+11 -1
View File
@@ -2831,6 +2831,11 @@ parse_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (first) lab
}
}
if (token_is (TOK_CLOSE_BRACE))
{
lexer_save_token (tok);
}
JERRY_ASSERT (label_p != NULL);
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
}
skip_token ();
if (!token_is (TOK_SEMICOLON) && !token_is (TOK_NEWLINE))
if (!token_is (TOK_SEMICOLON) && !token_is (TOK_NEWLINE) && !token_is (TOK_CLOSE_BRACE))
{
const jsp_operand_t op = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP);
dump_retval (op);
@@ -2855,6 +2860,11 @@ parse_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (first) lab
else
{
dump_ret ();
if (token_is (TOK_CLOSE_BRACE))
{
lexer_save_token (tok);
}
return;
}
}
+21
View File
@@ -0,0 +1,21 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
function f(){return}
switch (1) {
case 1:
break}
while (false) {continue}