From f3d49f65dd6a4157b41f42ea77ee6e9dffa025c8 Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Thu, 16 Jan 2020 17:01:56 +0100 Subject: [PATCH] Always mark the identifers which are propagated to upper level after argument parsing. (#3516) JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com --- jerry-core/parser/js/js-scanner-util.c | 5 +---- tests/jerry/es2015/function-pattern2.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/jerry-core/parser/js/js-scanner-util.c b/jerry-core/parser/js/js-scanner-util.c index fc2740bb5..b10776b01 100644 --- a/jerry-core/parser/js/js-scanner-util.c +++ b/jerry-core/parser/js/js-scanner-util.c @@ -970,10 +970,7 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */ lexer_lit_location_t *literal_location_p = scanner_add_custom_literal (context_p, prev_literal_pool_p, literal_p); - if (type & SCANNER_LITERAL_NO_REG) - { - type |= SCANNER_LITERAL_NO_REG; - } + type |= SCANNER_LITERAL_NO_REG; #if ENABLED (JERRY_ES2015) type |= SCANNER_LITERAL_IS_USED; diff --git a/tests/jerry/es2015/function-pattern2.js b/tests/jerry/es2015/function-pattern2.js index d02a58823..7a9520dfd 100644 --- a/tests/jerry/es2015/function-pattern2.js +++ b/tests/jerry/es2015/function-pattern2.js @@ -76,3 +76,18 @@ Function("{a, x:b}","[c]", "{ 'dd':d, e = Math.cos(0)}", "assert(d === 4);" + "assert(e === 1);" )({a:1, b:3}, [3], {a:1, b:2, dd:4}); + +function m() +{ + var prop_name = "x"; + var def_val = 123; + + function g({[prop_name]: a, b = def_val }) + { + assert(a === 12); + assert(b === 123); + } + + g({ x:12 }) +} +m();