From 0c154306a87492f255edae6f483a768f128c2c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20B=C3=A1tyai?= Date: Tue, 11 Aug 2020 14:01:18 +0200 Subject: [PATCH] Fix yield* with undefined return method. (#4126) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #4097. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu --- .../ecma/operations/ecma-iterator-object.c | 2 +- .../es.next/regression-test-issue-4097.js | 26 +++++++++++++++++++ tests/test262-esnext-excludelist.xml | 1 - 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 tests/jerry/es.next/regression-test-issue-4097.js diff --git a/jerry-core/ecma/operations/ecma-iterator-object.c b/jerry-core/ecma/operations/ecma-iterator-object.c index f3d7dda03..412cd7ca9 100644 --- a/jerry-core/ecma/operations/ecma-iterator-object.c +++ b/jerry-core/ecma/operations/ecma-iterator-object.c @@ -386,7 +386,7 @@ ecma_op_iterator_return (ecma_value_t iterator, /**< iterator value */ if (func_return == ECMA_VALUE_UNDEFINED) { - return ecma_create_iter_result_object (value, true); + return ecma_create_iter_result_object (value, ECMA_VALUE_TRUE); } if (!ecma_is_value_object (func_return) || !ecma_op_is_callable (func_return)) diff --git a/tests/jerry/es.next/regression-test-issue-4097.js b/tests/jerry/es.next/regression-test-issue-4097.js new file mode 100644 index 000000000..80241d36a --- /dev/null +++ b/tests/jerry/es.next/regression-test-issue-4097.js @@ -0,0 +1,26 @@ +// Copyright JS Foundation and other contributors, http://js.foundation +// +// 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. + +function* g(a) { + yield* a; + return -3.14; +} + +try { + var iter = g("foo" + "bar"); + new WeakMap(iter); + assert(false); +} catch (e) { + assert(e instanceof TypeError); +} diff --git a/tests/test262-esnext-excludelist.xml b/tests/test262-esnext-excludelist.xml index 907c809ba..adc7509db 100644 --- a/tests/test262-esnext-excludelist.xml +++ b/tests/test262-esnext-excludelist.xml @@ -6773,7 +6773,6 @@ -