mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Fix tagged template literal call precedence for new operator (#3998)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
parent
fdb5d893bf
commit
f596211553
@ -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
|
||||
{
|
||||
|
||||
@ -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);
|
||||
}
|
||||
})();
|
||||
|
||||
@ -335,7 +335,6 @@
|
||||
<test id="language/expressions/tagged-template/cache-identical-source-eval.js"><reason></reason></test>
|
||||
<test id="language/expressions/tagged-template/cache-identical-source.js"><reason></reason></test>
|
||||
<test id="language/expressions/tagged-template/cache-identical-source-new-function.js"><reason></reason></test>
|
||||
<test id="language/expressions/tagged-template/constructor-invocation.js"><reason></reason></test>
|
||||
<test id="language/expressions/template-literal/invalid-legacy-octal-escape-sequence.js"><reason></reason></test>
|
||||
<test id="language/literals/string/7.8.4-1-s.js"><reason></reason></test>
|
||||
<test id="language/module-code/export-unresolvable.js"><reason></reason></test>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user