[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/470806
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Cr-Commit-Position: refs/heads/master@{#44543}
This commit is contained in:
Caitlin Potter 2017-04-06 20:36:59 -04:00 committed by Commit Bot
parent 14be6ae5e1
commit b086856f0a
3 changed files with 23 additions and 2 deletions

View File

@ -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) {}

View File

@ -0,0 +1,7 @@
// 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()];

View File

@ -0,0 +1,5 @@
*%(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