Spread operator should not update the scanner context's binding type (#3613)
This patch fixes #3595. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
@@ -217,17 +217,19 @@ scanner_scan_primary_expression (parser_context_t *context_p, /**< context */
|
|||||||
}
|
}
|
||||||
#if ENABLED (JERRY_ES2015)
|
#if ENABLED (JERRY_ES2015)
|
||||||
case LEXER_THREE_DOTS:
|
case LEXER_THREE_DOTS:
|
||||||
|
{
|
||||||
|
/* Elision or spread arguments */
|
||||||
|
if (stack_top != SCAN_STACK_PAREN_EXPRESSION && stack_top != SCAN_STACK_ARRAY_LITERAL)
|
||||||
|
{
|
||||||
|
scanner_raise_error (context_p);
|
||||||
|
}
|
||||||
|
scanner_context_p->mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||||
|
break;
|
||||||
|
}
|
||||||
#endif /* ENABLED (JERRY_ES2015) */
|
#endif /* ENABLED (JERRY_ES2015) */
|
||||||
case LEXER_COMMA:
|
case LEXER_COMMA:
|
||||||
{
|
{
|
||||||
/* Elision or spread arguments */
|
if (stack_top != SCAN_STACK_ARRAY_LITERAL)
|
||||||
#if ENABLED (JERRY_ES2015)
|
|
||||||
bool raise_error = (stack_top != SCAN_STACK_PAREN_EXPRESSION && stack_top != SCAN_STACK_ARRAY_LITERAL);
|
|
||||||
#else /* !ENABLED (JERRY_ES2015) */
|
|
||||||
bool raise_error = stack_top != SCAN_STACK_ARRAY_LITERAL;
|
|
||||||
#endif /* ENABLED (JERRY_ES2015) */
|
|
||||||
|
|
||||||
if (raise_error)
|
|
||||||
{
|
{
|
||||||
scanner_raise_error (context_p);
|
scanner_raise_error (context_p);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// Test if the native function as constructor is correctly invoked
|
||||||
|
// when used as parent "class"
|
||||||
|
|
||||||
|
var src = "({ $($) { a(...args) }";
|
||||||
|
|
||||||
|
try {
|
||||||
|
eval (src);
|
||||||
|
assert (false);
|
||||||
|
} catch (e) {
|
||||||
|
assert (e instanceof SyntaxError);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user