Commit a35a7059 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[parser] Don't mark const variables as assigned

Since const variables are  immutable, ignore SetMaybeAssigned for them.

Bug: chromium:999450, chromium:1000170, v8:8510
Change-Id: Idc1b71677b3d03bb63cc025017c119710b8f392d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1782170
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63579}
parent 9a6f23c2
...@@ -73,6 +73,8 @@ class Variable final : public ZoneObject { ...@@ -73,6 +73,8 @@ class Variable final : public ZoneObject {
return MaybeAssignedFlagField::decode(bit_field_); return MaybeAssignedFlagField::decode(bit_field_);
} }
void SetMaybeAssigned() { void SetMaybeAssigned() {
if (mode() == VariableMode::kConst) return;
// If this variable is dynamically shadowing another variable, then that // If this variable is dynamically shadowing another variable, then that
// variable could also be assigned (in the non-shadowing case). // variable could also be assigned (in the non-shadowing case).
if (has_local_if_not_shadowed()) { if (has_local_if_not_shadowed()) {
...@@ -81,7 +83,8 @@ class Variable final : public ZoneObject { ...@@ -81,7 +83,8 @@ class Variable final : public ZoneObject {
if (!maybe_assigned()) { if (!maybe_assigned()) {
local_if_not_shadowed()->SetMaybeAssigned(); local_if_not_shadowed()->SetMaybeAssigned();
} }
DCHECK(local_if_not_shadowed()->maybe_assigned()); DCHECK_IMPLIES(local_if_not_shadowed()->mode() != VariableMode::kConst,
local_if_not_shadowed()->maybe_assigned());
} }
set_maybe_assigned(); set_maybe_assigned();
} }
......
// 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.
//
// Flags: --no-lazy --stress-lazy-source-positions --enable-lazy-source-positions
(function a() {
function b() { a(); }
function c() { eval(); }
})();
// 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.
//
// Flags: --no-lazy --stress-lazy-source-positions --enable-lazy-source-positions
(function foo() {
foo = null;
() => foo;
})
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