diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc index eebaa5c3bf..bb3793b396 100644 --- a/src/ast/scopes.cc +++ b/src/ast/scopes.cc @@ -1187,7 +1187,7 @@ Declaration* DeclarationScope::CheckConflictingVarDeclarations() { // anything, so we can't conflict with anything either. The one // exception is the binding variable in catch scopes, which is handled // by the if above. - if (!IsLexicalVariableMode(other_var->mode())) return nullptr; + if (!IsLexicalVariableMode(other_var->mode())) break; return decl; } current = current->outer_scope(); diff --git a/test/mjsunit/regress/regress-1038588.js b/test/mjsunit/regress/regress-1038588.js new file mode 100644 index 0000000000..ffa787a7dd --- /dev/null +++ b/test/mjsunit/regress/regress-1038588.js @@ -0,0 +1,9 @@ +// Copyright 2020 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. + +function foo(arg){ + const x = 0; + eval("var arg, x;"); +} +assertThrows(foo, SyntaxError);