mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Colon tokens are not optional. (#3150)
Colon tokens must be present before the next statement is executed. Fixes #3145 JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
parent
137dd8d1f5
commit
8f7565db5f
@ -78,8 +78,8 @@ typedef enum
|
||||
SCAN_STACK_FOR_CONDITION, /**< condition part of "for" iterator */
|
||||
SCAN_STACK_FOR_EXPRESSION, /**< expression part of "for" iterator */
|
||||
SCAN_STACK_SWITCH_EXPRESSION, /**< expression part of "switch" statement */
|
||||
SCAN_STACK_COLON_EXPRESSION, /**< colon expression group */
|
||||
SCAN_STACK_CASE_STATEMENT, /**< colon statement group */
|
||||
SCAN_STACK_CASE_STATEMENT, /**< case statement inside a switch statement */
|
||||
SCAN_STACK_COLON_EXPRESSION, /**< expression between a question mark and colon */
|
||||
SCAN_STACK_TRY_STATEMENT, /**< try statement */
|
||||
SCAN_STACK_CATCH_STATEMENT, /**< catch statement */
|
||||
SCAN_STACK_SQUARE_BRACKETED_EXPRESSION, /**< square bracketed expression group */
|
||||
@ -450,36 +450,6 @@ scanner_scan_primary_expression_end (parser_context_t *context_p, /**< context *
|
||||
scanner_context_p->mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
return SCAN_NEXT_TOKEN;
|
||||
}
|
||||
case LEXER_COLON:
|
||||
{
|
||||
if (stack_top == SCAN_STACK_COLON_EXPRESSION)
|
||||
{
|
||||
scanner_context_p->mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
return SCAN_NEXT_TOKEN;
|
||||
}
|
||||
|
||||
if (stack_top != SCAN_STACK_CASE_STATEMENT)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
scanner_source_start_t source_start;
|
||||
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
parser_stack_pop (context_p, &source_start, sizeof (scanner_source_start_t));
|
||||
|
||||
scanner_location_info_t *location_info_p;
|
||||
location_info_p = (scanner_location_info_t *) scanner_insert_info (context_p,
|
||||
source_start.source_p,
|
||||
sizeof (scanner_location_info_t));
|
||||
location_info_p->info.type = SCANNER_TYPE_CASE;
|
||||
|
||||
scanner_get_location (&location_info_p->location, context_p);
|
||||
|
||||
scanner_context_p->mode = SCAN_MODE_STATEMENT_OR_TERMINATOR;
|
||||
return SCAN_NEXT_TOKEN;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
@ -700,6 +670,40 @@ scanner_scan_primary_expression_end (parser_context_t *context_p, /**< context *
|
||||
scanner_context_p->mode = SCAN_MODE_STATEMENT_OR_TERMINATOR;
|
||||
return SCAN_KEEP_TOKEN;
|
||||
}
|
||||
case SCAN_STACK_CASE_STATEMENT:
|
||||
{
|
||||
if (type != LEXER_COLON)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
scanner_source_start_t source_start;
|
||||
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
parser_stack_pop (context_p, &source_start, sizeof (scanner_source_start_t));
|
||||
|
||||
scanner_location_info_t *location_info_p;
|
||||
location_info_p = (scanner_location_info_t *) scanner_insert_info (context_p,
|
||||
source_start.source_p,
|
||||
sizeof (scanner_location_info_t));
|
||||
location_info_p->info.type = SCANNER_TYPE_CASE;
|
||||
|
||||
scanner_get_location (&location_info_p->location, context_p);
|
||||
|
||||
scanner_context_p->mode = SCAN_MODE_STATEMENT_OR_TERMINATOR;
|
||||
return SCAN_NEXT_TOKEN;
|
||||
}
|
||||
case SCAN_STACK_COLON_EXPRESSION:
|
||||
{
|
||||
if (type != LEXER_COLON)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
scanner_context_p->mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
return SCAN_NEXT_TOKEN;
|
||||
}
|
||||
case SCAN_STACK_SQUARE_BRACKETED_EXPRESSION:
|
||||
{
|
||||
if (type != LEXER_RIGHT_SQUARE)
|
||||
|
||||
15
tests/jerry/fail/regresssion-test-issue-3145.js
Normal file
15
tests/jerry/fail/regresssion-test-issue-3145.js
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright JS Foundation and other contributors, http://js.foundation
|
||||
//
|
||||
// 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.
|
||||
|
||||
[this?$
|
||||
Loading…
x
Reference in New Issue
Block a user