From 9f65b7601336430600bd063c5e3288f5323227f3 Mon Sep 17 00:00:00 2001 From: Youngil Choi Date: Tue, 30 Aug 2016 12:50:12 +0900 Subject: [PATCH] Fix bug in for-in bytecode replacement JerryScript-DCO-1.0-Signed-off-by: Youngil Choi duddlf.choi@samsung.com --- jerry-core/parser/js/js-parser-statm.c | 2 +- tests/jerry/regression-test-issue-1300.js | 28 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/jerry/regression-test-issue-1300.js diff --git a/jerry-core/parser/js/js-parser-statm.c b/jerry-core/parser/js/js-parser-statm.c index de44010a3..0d6678dbf 100644 --- a/jerry-core/parser/js/js-parser-statm.c +++ b/jerry-core/parser/js/js-parser-statm.c @@ -789,7 +789,7 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */ } else if (opcode == CBC_PUSH_PROP_LITERAL) { - opcode = CBC_PUSH_PROP_LITERAL_REFERENCE; + opcode = CBC_ASSIGN_PROP_LITERAL; context_p->last_cbc_opcode = PARSER_CBC_UNAVAILABLE; } else if (opcode == CBC_PUSH_PROP_LITERAL_LITERAL) diff --git a/tests/jerry/regression-test-issue-1300.js b/tests/jerry/regression-test-issue-1300.js new file mode 100644 index 000000000..30ada6abf --- /dev/null +++ b/tests/jerry/regression-test-issue-1300.js @@ -0,0 +1,28 @@ +// Copyright 2016 Samsung Electronics Co., Ltd. +// Copyright 2016 University of Szeged. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +var array = [ [0] ]; +var obj = { prop : "" }; +var i = 0; +var count = 0; + +(function () { + for (array[0][i] in obj) + count++; +})(); + +assert(array[0][0] == "prop"); +assert(count == 1); +