Commit b086856f authored by Caitlin Potter's avatar Caitlin Potter Committed by Commit Bot

[prettyprinter] improve call-printing of GetIterator nodes

Fix error message printed by Runtime_ThrowCalledNonCallable.

As noted on the bug, this has a slight problem in that it will always
print that "asyncIterator" was not callable for GetIterator with an
async IteratorType, though it may be referring to a different call.
This issue is present regardless of the change I introduced to perform
this desugaring in the BytecodeGenerator.

BUG=v8:6187
R=adamk@chromium.org, verwaest@chromium.org

Change-Id: I2077b7cd5976d9d9ba044f0dff44ee8c312d1263
Reviewed-on: https://chromium-review.googlesource.com/470806Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Cr-Commit-Position: refs/heads/master@{#44543}
parent 14be6ae5
......@@ -370,9 +370,18 @@ void CallPrinter::VisitEmptyParentheses(EmptyParentheses* node) {
}
void CallPrinter::VisitGetIterator(GetIterator* node) {
Print("GetIterator(");
// Because CallPrinter is used by RenderCallSite() in runtime-internal.cc,
// and the GetIterator node results in a Call, either to a [@@iterator] or
// [@@asyncIterator]. It's unknown which call this error refers to, so we
// assume it's the first call.
bool was_found = !found_ && node->position() == position_;
if (was_found) {
found_ = true;
}
Find(node->iterable(), true);
Print(")");
Print(node->hint() == IteratorType::kNormal ? "[Symbol.iterator]"
: "[Symbol.asyncIterator]");
if (was_found) done_ = true;
}
void CallPrinter::VisitThisFunction(ThisFunction* node) {}
......
// Copyright 2017 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.
function nonIterable() { return 0; }
[...nonIterable()];
*%(basename)s:7: TypeError: nonIterable(...)[Symbol.iterator] is not a function
[...nonIterable()];
^
TypeError: nonIterable(...)[Symbol.iterator] is not a function
at *%(basename)s:7:5
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