[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/+/3086902 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#76226}
This commit is contained in:
parent
4a0f3c6fc4
commit
b213e0fd8b
@ -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);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
// 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}))();
|
@ -0,0 +1,5 @@
|
||||
*%(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
|
Loading…
Reference in New Issue
Block a user