oxc
oxc copied to clipboard
[oxc_semantics] cfg does not handle ternary or chain expression control flow
In general, we have chosen not to handle every expression explicitly in the CFG for performance reasons. That said, certain expressions also have implied control flow logic that we need to handle:
For example, was this
used before super
in each of these cases?
- Ternary expression:
foo ? super() : null; this.a;
- if
foo
is false, thensuper()
is not called
- if
- Optional chain:
a?.(super()); this.a;
- if
a
isundefined
ornull
, thensuper()
is not called
- if
I'll have a PR up shortly:
Ternary (conditional) expression
Code:
class A extends B {
constructor() {
const foo = bar ? super() : null;
this.a();
}
}
In main
branch:
In my PR branch (pending):
Optional Chaining (chain) expression
Code:
class A extends B {
constructor() {
foo?.(super());
this.a();
}
}
In main
branch:
In my PR branch (pending):
fixed via #3127