Commit e14a24d3 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Always return a valid var from DeclareVariableName

That way we can continue running in failure mode.

Bug: chromium:933214
Change-Id: I975901a72f615e2b7ed9955b75ce86bbcad0bbbb
Reviewed-on: https://chromium-review.googlesource.com/c/1481219Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59813}
parent 42a38d2a
...@@ -56,7 +56,8 @@ class ExpressionScope { ...@@ -56,7 +56,8 @@ class ExpressionScope {
// with or catch scope. In those cases the proxy isn't guaranteed to // with or catch scope. In those cases the proxy isn't guaranteed to
// refer to the declared variable, so consider it unresolved. // refer to the declared variable, so consider it unresolved.
parser()->scope()->AddUnresolved(result); parser()->scope()->AddUnresolved(result);
} else if (var) { } else {
DCHECK_NOT_NULL(var);
result->BindTo(var); result->BindTo(var);
} }
} }
...@@ -327,11 +328,10 @@ class VariableDeclarationParsingScope : public ExpressionScope<Types> { ...@@ -327,11 +328,10 @@ class VariableDeclarationParsingScope : public ExpressionScope<Types> {
// //
// This also handles marking of loop variables in for-in and for-of // This also handles marking of loop variables in for-in and for-of
// loops, as determined by loop-nesting-depth. // loops, as determined by loop-nesting-depth.
if (V8_LIKELY(var)) { DCHECK_NOT_NULL(var);
var->set_maybe_assigned(); var->set_maybe_assigned();
} }
} }
}
return var; return var;
} }
......
...@@ -1110,6 +1110,8 @@ class PreParser : public ParserBase<PreParser> { ...@@ -1110,6 +1110,8 @@ class PreParser : public ParserBase<PreParser> {
Variable* var = scope->DeclareVariableName(name, mode, was_added, kind); Variable* var = scope->DeclareVariableName(name, mode, was_added, kind);
if (var == nullptr) { if (var == nullptr) {
ReportUnidentifiableError(); ReportUnidentifiableError();
if (!IsLexicalVariableMode(mode)) scope = scope->GetDeclarationScope();
var = scope->LookupLocal(name);
} else if (var->scope() != scope) { } else if (var->scope() != scope) {
DCHECK_NE(kNoSourcePosition, position); DCHECK_NE(kNoSourcePosition, position);
DCHECK_EQ(VariableMode::kVar, mode); DCHECK_EQ(VariableMode::kVar, mode);
......
// Copyright 2019 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.
assertThrows(`
function __v_0() {
function __v_2() {
try {
function* __v_0() {}
function __v_0() {}
}
}
}`, SyntaxError);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment