[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/1481219 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/master@{#59813}
This commit is contained in:
parent
42a38d2ada
commit
e14a24d32e
@ -56,7 +56,8 @@ class ExpressionScope {
|
||||
// with or catch scope. In those cases the proxy isn't guaranteed to
|
||||
// refer to the declared variable, so consider it unresolved.
|
||||
parser()->scope()->AddUnresolved(result);
|
||||
} else if (var) {
|
||||
} else {
|
||||
DCHECK_NOT_NULL(var);
|
||||
result->BindTo(var);
|
||||
}
|
||||
}
|
||||
@ -327,9 +328,8 @@ class VariableDeclarationParsingScope : public ExpressionScope<Types> {
|
||||
//
|
||||
// This also handles marking of loop variables in for-in and for-of
|
||||
// loops, as determined by loop-nesting-depth.
|
||||
if (V8_LIKELY(var)) {
|
||||
var->set_maybe_assigned();
|
||||
}
|
||||
DCHECK_NOT_NULL(var);
|
||||
var->set_maybe_assigned();
|
||||
}
|
||||
}
|
||||
return var;
|
||||
|
@ -1110,6 +1110,8 @@ class PreParser : public ParserBase<PreParser> {
|
||||
Variable* var = scope->DeclareVariableName(name, mode, was_added, kind);
|
||||
if (var == nullptr) {
|
||||
ReportUnidentifiableError();
|
||||
if (!IsLexicalVariableMode(mode)) scope = scope->GetDeclarationScope();
|
||||
var = scope->LookupLocal(name);
|
||||
} else if (var->scope() != scope) {
|
||||
DCHECK_NE(kNoSourcePosition, position);
|
||||
DCHECK_EQ(VariableMode::kVar, mode);
|
||||
|
13
test/mjsunit/regress/regress-crbug-933214.js
Normal file
13
test/mjsunit/regress/regress-crbug-933214.js
Normal file
@ -0,0 +1,13 @@
|
||||
// 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);
|
Loading…
Reference in New Issue
Block a user