diff --git a/jerry-core/parser/js/js-parser-expr.c b/jerry-core/parser/js/js-parser-expr.c index cc82778d7..6dd6e2221 100644 --- a/jerry-core/parser/js/js-parser-expr.c +++ b/jerry-core/parser/js/js-parser-expr.c @@ -2216,8 +2216,13 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */ if (context_p->stack_top_uint8 == LEXER_KEYW_NEW) { - parser_stack_pop_uint8 (context_p); - opcode = CBC_NEW; +#if ENABLED (JERRY_ESNEXT) + if (context_p->token.type == LEXER_LEFT_PAREN) +#endif /* ENABLED (JERRY_ESNEXT) */ + { + parser_stack_pop_uint8 (context_p); + opcode = CBC_NEW; + } } else { diff --git a/tests/jerry/es.next/tagged-template-literal.js b/tests/jerry/es.next/tagged-template-literal.js index a54154e83..50d496cd3 100644 --- a/tests/jerry/es.next/tagged-template-literal.js +++ b/tests/jerry/es.next/tagged-template-literal.js @@ -137,3 +137,45 @@ var desc = Object.getOwnPropertyDescriptor(templateObject, '0'); assert(desc.writable === false); assert(desc.enumerable === true); assert(desc.configurable === false); + +(function () { + function f (strings, ...args) { + return function () { + return Array(...args); + }; + } + + var a = new f`${1}${2}${3}`; + assert(a.length === 3); + assert(a[0] === 1); + assert(a[1] === 2); + assert(a[2] === 3); + + function g (strings, ...args) { + return Array; + } + + a = new g`${1}${2}${3}`(4, 5, 6); + assert(a.length === 3); + assert(a[0] === 4); + assert(a[1] === 5); + assert(a[2] === 6); + + try { + new (g`${1}${2}${3}`(4, 5, 6)); + assert(false); + } catch (e) { + assert (e instanceof TypeError); + } + + function h (strings, ...args) { + return 5; + } + + try { + new h`foo`; + assert(false); + } catch (e) { + assert (e instanceof TypeError); + } +})(); diff --git a/tests/test262-es6-excludelist.xml b/tests/test262-es6-excludelist.xml index 237bdfbeb..26bcbaafa 100644 --- a/tests/test262-es6-excludelist.xml +++ b/tests/test262-es6-excludelist.xml @@ -335,7 +335,6 @@ -