Skip to content

control flow switch recovery does not work if there's case with return in if/else #162

@Le0Developer

Description

@Le0Developer

Describe the bug

This example has a case with no trailing continue or return, so the matcher fails

m.switchCase(
m.stringLiteral(m.matcher((s) => /^\d+$/.test(s))),
m.anyList(
m.zeroOrMore(),
m.or(m.continueStatement(), m.returnStatement()),
),
),

Expected Behaviour

Not sure what the ideal fix is, but I replaced the m.anyList() with m.zeroOrMore() and it seems to work.

Code

function gl() {
  var d = "0".split("|");
  var e = 0;
  while (true) {
    switch (d[e++]) {
      case "0":
        if (true) {
          return 123;
        } else {
          return 456;
        }
    }
    break;
  }
}

Logs


Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions