#2511 Check null safe chaining with shortcuts

SlimerDude Thu 11 Feb 2016

The following code generates a useful compiler error:

url := null as Uri

foo := url?.query.get("foo")
// --> Non-null safe call chained after null safe call

But if I substitute get for a get operator then everything compiles okay. I'm also lulled into a false sense of security because I used a safe invoke. Until that is, I run it and get a runtime err:

url := null as Uri

poo := url?.query["poo"]
// --> sys::NullErr: java.lang.NullPointerException

If the compiler could generate an error for the above case then I'd know I have to re-write it the long way round:

url := null as Uri

bar := url?.query?.get("bar")

brian Wed 4 Oct

Ticket promoted to #2511 and assigned to brian

brian Wed 4 Oct

Ticket resolved in 1.0.70

Fix compiler error checking to include shortcuts such as get when chaining null safe chaining

Login or Signup to reply.