Skip to content

Commit 1230d45

Browse files
authored
Asterisk should be ignored by object initializers. (#3872)
Fixes #3869 JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
1 parent ab2e821 commit 1230d45

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

jerry-core/parser/js/js-lexer.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3048,6 +3048,16 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
30483048
return;
30493049
}
30503050
case LIT_CHAR_ASTERISK:
3051+
{
3052+
if (ident_opts & (LEXER_OBJ_IDENT_ONLY_IDENTIFIERS | LEXER_OBJ_IDENT_OBJECT_PATTERN))
3053+
{
3054+
break;
3055+
}
3056+
3057+
context_p->token.type = LEXER_MULTIPLY;
3058+
lexer_consume_next_character (context_p);
3059+
return;
3060+
}
30513061
#endif /* ENABLED (JERRY_ES2015) */
30523062
case LIT_CHAR_RIGHT_BRACE:
30533063
{
@@ -3057,13 +3067,6 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
30573067
}
30583068

30593069
context_p->token.type = LEXER_RIGHT_BRACE;
3060-
#if ENABLED (JERRY_ES2015)
3061-
if (context_p->source_p[0] == LIT_CHAR_ASTERISK)
3062-
{
3063-
context_p->token.type = LEXER_MULTIPLY;
3064-
}
3065-
#endif /* ENABLED (JERRY_ES2015) */
3066-
30673070
lexer_consume_next_character (context_p);
30683071
return;
30693072
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
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+
try {
16+
eval('function a ({ *x:x }) {}')
17+
assert(false)
18+
} catch (e) {
19+
assert(e instanceof SyntaxError)
20+
}

0 commit comments

Comments
 (0)