From d6070a9fed68be4dbd7d97387494a53a0ddecbb7 Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Tue, 14 Jan 2020 15:10:19 +0100 Subject: [PATCH] Call filter arguments after the global arguments are parsed. (#3511) JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com --- jerry-core/parser/js/js-scanner-util.c | 2 +- jerry-core/parser/js/js-scanner.c | 1 + tests/jerry/es2015/function-pattern2.js | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/jerry-core/parser/js/js-scanner-util.c b/jerry-core/parser/js/js-scanner-util.c index 01e9c67f2..fc2740bb5 100644 --- a/jerry-core/parser/js/js-scanner-util.c +++ b/jerry-core/parser/js/js-scanner-util.c @@ -964,7 +964,7 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */ new_literal_p = (lexer_lit_location_t *) parser_list_append (context_p, &new_literal_pool_p->literal_pool); *new_literal_p = *literal_p; } - else + else if (prev_literal_pool_p != NULL) { /* Propagate literal to upper level. */ lexer_lit_location_t *literal_location_p = scanner_add_custom_literal (context_p, diff --git a/jerry-core/parser/js/js-scanner.c b/jerry-core/parser/js/js-scanner.c index d80779c7a..dc4cc652a 100644 --- a/jerry-core/parser/js/js-scanner.c +++ b/jerry-core/parser/js/js-scanner.c @@ -2759,6 +2759,7 @@ scanner_scan_all (parser_context_t *context_p, /**< context */ context_p->line = 1; context_p->column = 1; + scanner_filter_arguments (context_p, &scanner_context); lexer_next_token (context_p); scanner_check_directives (context_p, &scanner_context); continue; diff --git a/tests/jerry/es2015/function-pattern2.js b/tests/jerry/es2015/function-pattern2.js index 74bf5d8ce..d02a58823 100644 --- a/tests/jerry/es2015/function-pattern2.js +++ b/tests/jerry/es2015/function-pattern2.js @@ -68,3 +68,11 @@ function l(a = 0, ...[b, c = 1, d = 4]) assert(d === 4); } l(1,2,3); + +Function("{a, x:b}","[c]", "{ 'dd':d, e = Math.cos(0)}", + "assert(a === 1);" + + "assert(b === undefined);" + + "assert(c === 3);" + + "assert(d === 4);" + + "assert(e === 1);" +)({a:1, b:3}, [3], {a:1, b:2, dd:4});