You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Downlevel super in static initializers loses this or emits an invalid assignment when the reference is parenthesized or has !, as or satisfies #65640
The tested TypeScript version is main at 01f1a75 (7.1.0-dev). 6.0.3 emits the same, so this is not a regression. Every target below ES2022 is affected; ES2022 and later are correct.
User Goal
The user maintains a fuzzer for TypeScript and asked me to find real bugs and report them. This one was found next to the fix for #65598 (#65602), which handled the same wrappers for #private calls but not for super references.
D undefined undefined undefined undefined
ReferenceError: Invalid left-hand side in assignment
Only the bare call keeps this:
value: Reflect.get(_b,"m",_a).call(_a)// super.m()
value: (Reflect.get(_b,"m",_a))()// (super.m)()
value: Reflect.get(_b,"m",_a)()// (super.m as any)() and super.m!()
value: (Reflect.get(_b,"m",_a))?.()// (super.m)?.()Reflect.get(_d,"x",_c)=1;// (super.x as any) = 1
The same happens in static fields (static r = ((super.x) = 5, 0)) and with tagged templates ((super.m)`x` ).
What I expected: what --target es2022 prints:
D D D D D
true
The wrappers do not change the reference, so this should be D and the assignment should still define E.x.
In classfields.go, the static-initializer super branches of visitCallExpression, visitTaggedTemplateExpression, visitBinaryExpression and visitDestructuringAssignmentTarget test ast.IsSuperProperty on the node before skipping outer expressions. A wrapped super.m therefore goes through the plain property-access path and becomes a bare Reflect.get(...) value. #65602 added SkipOuterExpressions/RestoreOuterExpressions to the #private branches of the same functions.
Activity