v8/test/mjsunit/regress/regress-crbug-1245870.js
Marja Hölttä 6de4e21068 [parser] Fix class variable redeclaration
ParserBase::ParseClassLiteral and BaseConsumedPreparseData::RestoreDataForScope
both declare the class variable, but the logic is so complex
that they sometimes ended up both declaring it.

This is further complicated by some of the variable values (esp.
inner_scope_calls_eval_) potentially changing in between, so we can't
just redo the same logic any more.

Forcefully make it work by making RestoreDataForScope declare the variable
iff ParseClassLiteral didn't.

Bug: chromium:1245870
Change-Id: I777fd9d78145240448fc25709d2b118977d91056
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3140596
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76654}
2021-09-03 11:15:03 +00:00

15 lines
302 B
JavaScript

// Copyright 2021 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.
class Outer {
test() {
return class {
static #a() { }
b = eval();
};
}
}
const obj = new Outer();
obj.test();