Skip to content

I hope the type checker to report an error when I call a function which return never. #37747

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

Closed
zhuobinggang opened this issue Apr 2, 2020 · 1 comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@zhuobinggang
Copy link

For example:

class OpenBox implements Box{
  open(): never{
    throw "No I should not call this method"
  }
  close(): CloseBox{
    return new CloseBox();
  }
}

new OpenBox().open() // I want the type checker to report an error.
@DanielRosenwasser DanielRosenwasser added the Working as Intended The behavior described is the intended behavior; this is not a bug label Apr 2, 2020
@DanielRosenwasser
Copy link
Member

It's no more of an error to call a never-returning function than it is to write a throw statement.

Maybe what you're requesting is that we report an error on unreachable code following that statement, but that's a design limitation (see #33622).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants