Skip to content

Logical assignment breaks on class static properties #4288

@KyleDavidE

Description

@KyleDavidE

I suspect this is because the variable flattener doesn't like how previous phases transpile local assignment in a way that creates a temporary variable.

Input:

class MyClass {}
console.log(() => {
  return (MyClass.myField ??= {});
});

with flags:

-O ADVANCED
--js in.js
--language_in ECMASCRIPT_NEXT
--language_out ECMASCRIPT_2020

Output:

class a{}console.log(()=>a.g??{});

Expected output:

// any of
class a{}console.log(()=>a.g??={});
var x;console.log(() => x??={});
var x;console.log(() => x??(x={}));
class a{};console.log(() => a.g??(a.g={}));

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions