Skip to content

Compiler: synthesized parameter field resets an earlier initializer write #3521

Open

Description

@nickna
class Item {
  first = (this.value = 7);
  constructor(public value = 1) {}
  last = this.value;
}
const item = new Item();
console.log(item.first, item.last, item.value, Object.keys(item).join(','));

Compile as an unchecked .js fixture with sharpts --no-tsconfig --noLib --compile repro.js -o repro.dll --verify. The saved assembly from unchanged main cabb41636 passes complete IL verification and prints 7 undefined 1 value,first,last.

Expected 7 7 1 value,first,last. An ES2022 class with an initial value; declaration and an assignment this.value = value in the constructor prints that result in Node. The synthesized field at the constructor's source position must not reset the earlier initializer's write before last is initialized.

Found when checking the compiled equivalent of the interpreter-only #3482 regression in #3510. This is separate from #3514, which concerns the missing initial declaration on an escaped replacement receiver after abrupt completion. All-state parameter-property and field-reset searches found no focused compiler owner for this successful-construction case.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions