[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:
parent
e0a761042d
commit
cb01cbf2f3
@ -1532,8 +1532,7 @@ Statement* Parser::DeclareFunction(const AstRawString* variable_name,
|
|||||||
ZoneList<const AstRawString*>* names,
|
ZoneList<const AstRawString*>* names,
|
||||||
bool* ok) {
|
bool* ok) {
|
||||||
VariableProxy* proxy =
|
VariableProxy* proxy =
|
||||||
factory()->NewVariableProxy(variable_name, NORMAL_VARIABLE);
|
factory()->NewVariableProxy(variable_name, NORMAL_VARIABLE, pos);
|
||||||
|
|
||||||
Declaration* declaration =
|
Declaration* declaration =
|
||||||
factory()->NewFunctionDeclaration(proxy, function, pos);
|
factory()->NewFunctionDeclaration(proxy, function, pos);
|
||||||
Declare(declaration, DeclarationDescriptor::NORMAL, mode, kCreatedInitialized,
|
Declare(declaration, DeclarationDescriptor::NORMAL, mode, kCreatedInitialized,
|
||||||
|
10
test/message/fail/redeclaration4.js
Normal file
10
test/message/fail/redeclaration4.js
Normal 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() {}
|
||||||
|
}
|
5
test/message/fail/redeclaration4.out
Normal file
5
test/message/fail/redeclaration4.out
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
*%(basename)s:9: SyntaxError: Identifier 'foo' has already been declared
|
||||||
|
function foo() {}
|
||||||
|
^
|
||||||
|
SyntaxError: Identifier 'foo' has already been declared
|
||||||
|
|
8
test/message/fail/redeclaration5.js
Normal file
8
test/message/fail/redeclaration5.js
Normal 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() {}
|
5
test/message/fail/redeclaration5.out
Normal file
5
test/message/fail/redeclaration5.out
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
*%(basename)s:8: SyntaxError: Identifier 'foo' has already been declared
|
||||||
|
function foo() {}
|
||||||
|
^
|
||||||
|
SyntaxError: Identifier 'foo' has already been declared
|
||||||
|
|
Loading…
Reference in New Issue
Block a user