[parser] Fix conflict detection loop early exit

During conflict detection, we want to early exit the scope loop when we
find a non-conflict, but continue looking at the other declarations in
the scope.

Bug: chromium:1038588
Change-Id: Ia2a19b02222fbd13cec70d3a60d2f5bae4ce245b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1985991
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65602}
This commit is contained in:
Leszek Swirski 2020-01-07 12:44:00 +01:00 committed by Commit Bot
parent bfd16238ea
commit 2a6c0f4acf
2 changed files with 10 additions and 1 deletions

View File

@ -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();

View File

@ -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);