Fix location of super syntax errors
authorErik Arvidsson <arv@chromium.org>
Thu, 12 Feb 2015 20:53:03 +0000 (15:53 -0500)
committerErik Arvidsson <arv@chromium.org>
Thu, 12 Feb 2015 20:53:17 +0000 (20:53 +0000)
BUG=v8:3885
LOG=N
R=adamk@chromium.org, dslomov@chromium.org

Review URL: https://codereview.chromium.org/916293004

Cr-Commit-Position: refs/heads/master@{#26632}

src/preparser.h
test/message/super-in-function.js [new file with mode: 0644]
test/message/super-in-function.out [new file with mode: 0644]

index a60b218..141761d 100644 (file)
@@ -2736,7 +2736,6 @@ ParserBase<Traits>::ParseMemberExpression(bool* ok) {
 template <class Traits>
 typename ParserBase<Traits>::ExpressionT
 ParserBase<Traits>::ParseSuperExpression(bool is_new, bool* ok) {
-  int beg_pos = position();
   Expect(Token::SUPER, CHECK_OK);
 
   FunctionState* function_state = function_state_;
@@ -2760,7 +2759,7 @@ ParserBase<Traits>::ParseSuperExpression(bool is_new, bool* ok) {
     }
   }
 
-  ReportMessageAt(Scanner::Location(beg_pos, position()), "unexpected_super");
+  ReportMessageAt(scanner()->location(), "unexpected_super");
   *ok = false;
   return this->EmptyExpression();
 }
diff --git a/test/message/super-in-function.js b/test/message/super-in-function.js
new file mode 100644 (file)
index 0000000..edaa0e4
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright 2015 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.
+//
+// Flags: --harmony-classes
+'use strict';
+
+function f() {
+  super.x();
+}
diff --git a/test/message/super-in-function.out b/test/message/super-in-function.out
new file mode 100644 (file)
index 0000000..19f8bf0
--- /dev/null
@@ -0,0 +1,7 @@
+# Copyright 2014 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.
+*%(basename)s:9: SyntaxError: 'super' keyword unexpected here
+  super.x();
+  ^^^^^
+SyntaxError: 'super' keyword unexpected here