[parsing] Provide location for function redeclaration error.

Bug: v8:7387
Change-Id: I831bf8f580d4112d7e0f48d90bbe2f44eff73225
Reviewed-on: https://chromium-review.googlesource.com/897326
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51047}
This commit is contained in:
Georg Neis 2018-02-01 21:10:23 +01:00 committed by Commit Bot
parent e0a761042d
commit cb01cbf2f3
5 changed files with 29 additions and 2 deletions

View File

@ -1532,8 +1532,7 @@ Statement* Parser::DeclareFunction(const AstRawString* variable_name,
ZoneList<const AstRawString*>* names,
bool* ok) {
VariableProxy* proxy =
factory()->NewVariableProxy(variable_name, NORMAL_VARIABLE);
factory()->NewVariableProxy(variable_name, NORMAL_VARIABLE, pos);
Declaration* declaration =
factory()->NewFunctionDeclaration(proxy, function, pos);
Declare(declaration, DeclarationDescriptor::NORMAL, mode, kCreatedInitialized,

View File

@ -0,0 +1,10 @@
// Copyright 2018 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.
"use strict";
{
function foo() {}
function foo() {}
}

View File

@ -0,0 +1,5 @@
*%(basename)s:9: SyntaxError: Identifier 'foo' has already been declared
function foo() {}
^
SyntaxError: Identifier 'foo' has already been declared

View File

@ -0,0 +1,8 @@
// Copyright 2018 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.
// MODULE
function foo() {}
function foo() {}

View File

@ -0,0 +1,5 @@
*%(basename)s:8: SyntaxError: Identifier 'foo' has already been declared
function foo() {}
^
SyntaxError: Identifier 'foo' has already been declared