Reviewers: arv,
Message:
PTAL
Description:
Better message location for 'super(...)' restriction error.
[email protected]
BUG=v8:3330
LOG=N
Please review this at https://codereview.chromium.org/776563002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+9, -10 lines):
M src/compiler.cc
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index
546ac887421ab2e10f251ec038d98f049dc37755..c4949dcc9ed0859811fe7dc82396773321cbe12c
100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -762,15 +762,14 @@ static bool Renumber(CompilationInfo* info) {
}
-static void ThrowSuperConstructorCheckError(CompilationInfo* info) {
+static void ThrowSuperConstructorCheckError(CompilationInfo* info,
+ Statement* stmt) {
MaybeHandle<Object> obj = info->isolate()->factory()->NewTypeError(
"super_constructor_call", HandleVector<Object>(nullptr, 0));
Handle<Object> exception;
if (!obj.ToHandle(&exception)) return;
- FunctionLiteral* lit = info->function();
- MessageLocation location(info->script(), lit->start_position(),
- lit->end_position());
+ MessageLocation location(info->script(), stmt->position(),
stmt->position());
USE(info->isolate()->Throw(*exception, &location));
}
@@ -801,20 +800,20 @@ static bool
CheckSuperConstructorCall(CompilationInfo* info) {
break;
}
- ExpressionStatement* exprStm =
- body->at(super_call_index)->AsExpressionStatement();
+ Statement* stmt = body->at(super_call_index);
+ ExpressionStatement* exprStm = stmt->AsExpressionStatement();
if (exprStm == nullptr) {
- ThrowSuperConstructorCheckError(info);
+ ThrowSuperConstructorCheckError(info, stmt);
return false;
}
Call* callExpr = exprStm->expression()->AsCall();
if (callExpr == nullptr) {
- ThrowSuperConstructorCheckError(info);
+ ThrowSuperConstructorCheckError(info, stmt);
return false;
}
if (!callExpr->expression()->IsSuperReference()) {
- ThrowSuperConstructorCheckError(info);
+ ThrowSuperConstructorCheckError(info, stmt);
return false;
}
@@ -825,7 +824,7 @@ static bool CheckSuperConstructorCall(CompilationInfo*
info) {
if (this_access_visitor.HasStackOverflow()) return false;
if (this_access_visitor.UsesThis()) {
- ThrowSuperConstructorCheckError(info);
+ ThrowSuperConstructorCheckError(info, stmt);
return false;
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.