mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Fix duplicated argument validation for default arguments (#3178)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
parent
e9664b78cd
commit
195b0d3c3a
@ -2272,7 +2272,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
lexer_literal_t *literal_p;
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
if (initializer_found)
|
||||
if (initializer_found && (context_p->lit_object.literal_p->status_flags & LEXER_FLAG_FUNCTION_ARGUMENT))
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_DUPLICATED_ARGUMENT_NAMES);
|
||||
}
|
||||
@ -2296,6 +2296,9 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
* since no byte code has been emitted yet. Therefore there is no
|
||||
* need to set the index field. */
|
||||
context_p->lit_object.literal_p->type = LEXER_UNUSED_LITERAL;
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
|
||||
context_p->lit_object.literal_p->prop.index = context_p->literal_count;
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
|
||||
|
||||
/* Only the LEXER_FLAG_FUNCTION_ARGUMENT flag is kept. */
|
||||
context_p->lit_object.literal_p->status_flags &= LEXER_FLAG_FUNCTION_ARGUMENT;
|
||||
|
||||
@ -88,3 +88,11 @@ f();
|
||||
|
||||
var f = new Function (str, "return (a + c) * (b == undefined ? 1 : 0)");
|
||||
assert (f() == 9);
|
||||
|
||||
function duplicatedArg (a = c, b = d, c) {
|
||||
assert(a === 1);
|
||||
assert(b === 2);
|
||||
assert(c === 3);
|
||||
}
|
||||
|
||||
duplicatedArg(1, 2, 3);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user