Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty "default" in a switch causes unreachable code error #8832

Closed
evmar opened this issue May 25, 2016 · 0 comments · Fixed by #8869
Closed

Empty "default" in a switch causes unreachable code error #8832

evmar opened this issue May 25, 2016 · 0 comments · Fixed by #8869
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@evmar
Copy link
Contributor

evmar commented May 25, 2016

Using TS master from May 23:

function foo(x: any) {
  switch (x) {
    case 1: return;
    default:
  }
  console.log('x');
}

Produces an 'unreachable code' error on the console.log.
If you put anything after the 'default:', e.g. 1; then it is accepted.
I imagine the empty default case is somehow being treated as terminal.

@evmar evmar changed the title Empty "default" in a switch causes unreachable code Empty "default" in a switch causes unreachable code error May 25, 2016
@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label May 25, 2016
@vladima vladima added the Fixed A PR has been merged for this issue label May 27, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants