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

Calling a method on null should throw a NullPointerException #61

Closed
OlivierBlanvillain opened this issue Dec 15, 2013 · 2 comments
Closed
Labels
wontfix We decided not to fix this issue/not implement that feature request.

Comments

@OlivierBlanvillain
Copy link
Contributor

At this point it throw a ☹ TypeError. Here is a failing test:

it("should throw a NullPointerException when calling a method on null") {
  try {
    null.toString()
  } catch {
    case e: NullPointerException => ()
  }
}
@sjrd
Copy link
Member

sjrd commented Dec 15, 2013

Hi @OlivierBlanvillain !
This is an intended semantic difference as documented here:
http://www.scala-js.org/doc/semantics.html#exceptions
Well, not exactly intended, but something I don't plan to "fix". Throwing proper NullPointerExceptions would require lots of additional runtime checks, for an exception which is not supposed to be thrown in a bug-free program anyway.

@sjrd sjrd closed this as completed Dec 15, 2013
@joneshf
Copy link

joneshf commented Dec 17, 2013

It is very refreshing to read this.

@gzm0 gzm0 added can't reproduce We cannot reproduce the issue. Closed until a more reliable reproduction can be provided. wontfix We decided not to fix this issue/not implement that feature request. as-designed The observed behavior is as-designed, it need not be fixed. and removed can't reproduce We cannot reproduce the issue. Closed until a more reliable reproduction can be provided. wontfix We decided not to fix this issue/not implement that feature request. as-designed The observed behavior is as-designed, it need not be fixed. labels Sep 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix We decided not to fix this issue/not implement that feature request.
Projects
None yet
Development

No branches or pull requests

4 participants