Skip to content

Unreachable break in switch #931

@smokku

Description

@smokku

The following snippets generate unreachable code (break;) in switch:
JS linter running on compiled code is complaining on these.

foo = switch bar
| \a =>
  if baz then 1 else 2
| \b => 3
var foo;
foo = (function(){
  switch (bar) {
  case 'a':
    if (baz) {
      return 1;
    } else {
      return 2;
    }
    break;    // <-- HERE
  case 'b':
    return 3;
  }
}());
foo = switch bar
| \a =>
  switch baz
  | \1 => 1
  | \2 => 2
| \b => 3
var foo;
foo = (function(){
  switch (bar) {
  case 'a':
    switch (baz) {
    case '1':
      return 1;
    case '2':
      return 2;
    }
    break;    // <-- HERE
  case 'b':
    return 3;
  }
}());

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions