#2134 NullErr with Safe Invoke

SlimerDude Sat 13 Apr 2013

Using a Safe Invoke I can still get a NullErr - it has caught me out a couple of times and is getting quite annoying!

The exact conditions are bit nebulous but the following both compiles and gives a NullErr:

class Npe {
  static Void main(Str[] args) {
    MyClass1? myClass1 := null
    myClass1?.myClass2.stuff
  }
}

class MyClass1 {
  MyClass2? myClass2
}

class MyClass2 { 
  Void stuff() { }
}

katox Sat 13 Apr 2013

See 2068.

SlimerDude Sat 13 Apr 2013

Okay cool. I'm pleased I'm not the only one who's been caught out by this - makes me feel less stoopid!

SlimerDude Sun 14 Apr 2013

Given this is a compiler error, perhaps it should be promoted to a ticket?

brian Thu 18 Apr 2013

Promoted to ticket #2134 and assigned to brian

I thought we already had ticket for this (I have it my off-line todo list at least). I looked at this before thinking it was going to be easy and it wasn't as trivial as I first thought.

brian Mon 20 May 2013

Ticket resolved in 1.0.65

Actually I did have this implemented already for calls, but forgot to add it for null-safe field access chaining. Should all work correctly now.

Login or Signup to reply.