class Meh {
Str text := "meh" {
get { &text }
set { &text = it }
}
Void main() {
meh := 69 as Obj
foo := (meh as Meh)?.&text // --> sys::NullErr
}
}
It appears that the storage operator does not take the null safe operator into account and throws a NullErr; whereas I would expect it to return null instead.
In this simple example, removing the storage operator & then returns null as expected.
SlimerDude Sat 30 Nov 2024
I just came across this little edge case today...
class Meh { Str text := "meh" { get { &text } set { &text = it } } Void main() { meh := 69 as Obj foo := (meh as Meh)?.&text // --> sys::NullErr } }It appears that the storage operator does not take the null safe operator into account and throws a
NullErr; whereas I would expect it to returnnullinstead.In this simple example, removing the storage operator
&then returnsnullas expected.... foo := (meh as Meh)?.text // --> null ...brian Sun 1 Dec 2024
Thanks for reporting Steve - I pushed a fix