From fd5a0de2af9d33be2d8871b3c40f484c8b15956a Mon Sep 17 00:00:00 2001 From: Erik Arvidsson Date: Thu, 12 Feb 2015 15:53:03 -0500 Subject: [PATCH] Fix location of super syntax errors 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 | 3 +-- test/message/super-in-function.js | 10 ++++++++++ test/message/super-in-function.out | 7 +++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 test/message/super-in-function.js create mode 100644 test/message/super-in-function.out diff --git a/src/preparser.h b/src/preparser.h index a60b218..141761d 100644 --- a/src/preparser.h +++ b/src/preparser.h @@ -2736,7 +2736,6 @@ ParserBase::ParseMemberExpression(bool* ok) { template typename ParserBase::ExpressionT ParserBase::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::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 index 0000000..edaa0e4 --- /dev/null +++ b/test/message/super-in-function.js @@ -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 index 0000000..19f8bf0 --- /dev/null +++ b/test/message/super-in-function.out @@ -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 -- 2.7.4