oxc icon indicating copy to clipboard operation
oxc copied to clipboard

[oxc_semantics] cfg does not handle ternary or chain expression control flow

Open TzviPM opened this issue 1 year ago • 1 comments

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, then super() is not called
  • Optional chain: a?.(super()); this.a;
    • if a is undefined or null, then super() is not called

TzviPM avatar Feb 04 '24 03:02 TzviPM

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:

main_ternary

In my PR branch (pending):

pr_ternary

Optional Chaining (chain) expression

Code:

class A extends B {
  constructor() {
    foo?.(super());
    this.a();
  }
}

In main branch:

main_chaining

In my PR branch (pending):

pr_chaining

TzviPM avatar Feb 04 '24 03:02 TzviPM

fixed via #3127

rzvxa avatar Jun 13 '24 03:06 rzvxa