diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc index 060d14b6aa..f928f524d4 100644 --- a/src/parsing/parser.cc +++ b/src/parsing/parser.cc @@ -1532,8 +1532,7 @@ Statement* Parser::DeclareFunction(const AstRawString* variable_name, ZoneList* 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, diff --git a/test/message/fail/redeclaration4.js b/test/message/fail/redeclaration4.js new file mode 100644 index 0000000000..3cef563f30 --- /dev/null +++ b/test/message/fail/redeclaration4.js @@ -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() {} +} diff --git a/test/message/fail/redeclaration4.out b/test/message/fail/redeclaration4.out new file mode 100644 index 0000000000..9e1a7cbce9 --- /dev/null +++ b/test/message/fail/redeclaration4.out @@ -0,0 +1,5 @@ +*%(basename)s:9: SyntaxError: Identifier 'foo' has already been declared + function foo() {} + ^ +SyntaxError: Identifier 'foo' has already been declared + diff --git a/test/message/fail/redeclaration5.js b/test/message/fail/redeclaration5.js new file mode 100644 index 0000000000..d47593ef08 --- /dev/null +++ b/test/message/fail/redeclaration5.js @@ -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() {} diff --git a/test/message/fail/redeclaration5.out b/test/message/fail/redeclaration5.out new file mode 100644 index 0000000000..241582e0ee --- /dev/null +++ b/test/message/fail/redeclaration5.out @@ -0,0 +1,5 @@ +*%(basename)s:8: SyntaxError: Identifier 'foo' has already been declared +function foo() {} +^ +SyntaxError: Identifier 'foo' has already been declared +