Commit b213e0fd authored by legendecas's avatar legendecas Committed by V8 LUCI CQ

[builtins] throw non-iterable error on iterator method not callable

CallPrinter cannot determine the actual reason when the error is
triggered by CallRuntime. In the case, throw iterator error by
default instead of non-callable error to present more intuitive
error messages.

Bug: v8:12039
Change-Id: I240f9a729878b2dd606f4cc71236c8427bba316e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3086902Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76226}
parent 4a0f3c6f
......@@ -681,6 +681,8 @@ extern macro ThrowTypeError(implicit context: Context)(
constexpr MessageTemplate, Object, Object, Object): never;
extern transitioning runtime ThrowTypeErrorIfStrict(implicit context: Context)(
Smi, Object, Object): void;
extern transitioning runtime ThrowIteratorError(implicit context: Context)(
JSAny): never;
extern transitioning runtime ThrowCalledNonCallable(implicit context: Context)(
JSAny): never;
......
......@@ -110,7 +110,7 @@ transitioning builtin CallIteratorWithFeedback(
iteratorMethod, %MakeLazy<JSAny, JSAny>('GetLazyReceiver', receiver),
context, feedback, callSlotUnTagged);
const iteratorCallable: Callable = Cast<Callable>(iteratorMethod)
otherwise ThrowCalledNonCallable(iteratorMethod);
otherwise ThrowIteratorError(receiver);
return Call(context, iteratorCallable, receiver);
}
......
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var [a] = (() => ({a: 1}))();
*%(basename)s:5: TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
var [a] = (() => ({a: 1}))();
^
TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
at *%(basename)s:5:11
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment