Apparently, the it special object isn't handling null. The coerce message is coming up because it's trying to cast null to an Obj in both cases.
AkcelistoThu 25 Mar 2010
What is mean cast to sys::Obj? I think, everything is instance of sys::Obj.
--
1st case
[null].each|v|{
echo(v)
}
2nd case
[null].each{
echo(it)
}
It seems 1st and 2nd case are identical. But indeed they have different output.
1st case
null
2nd case
sys::NullErr: Coerce to non-null
tacticsThu 25 Mar 2010
Obj can hold any value in Fantom except for null.
In case 1, the variable v is inferring the type Obj?. Everything works.
In case 2, the special variable it is inferring the type Obj. It tries to coerce null an it blows up and you get an exception.
This is a bug. Case 2 should work the same as case 1.
brianThu 25 Mar 2010
Promoted to ticket #1039 and assigned to brian
I think that is just a nullable bug somewhere in the compiler. If it is typed as Obj? then null should be a valid value. I suspect that is just some place where it is typed as Obj instead of Obj?.
brianThu 25 Mar 2010
Renamed from Exclude null from List to It not typed as Obj? correctly
brianThu 25 Mar 2010
Ticket resolved in 1.0.53
Took a while to track down, but its a one line fix
Akcelisto Thu 25 Mar 2010
throws
Why?
Addition
I found more simple.
throws
Why?
tactics Thu 25 Mar 2010
Apparently, the
it
special object isn't handlingnull
. The coerce message is coming up because it's trying to castnull
to anObj
in both cases.Akcelisto Thu 25 Mar 2010
What is mean cast to
sys::Obj
? I think, everything is instance ofsys::Obj
.--
1st case
2nd case
It seems 1st and 2nd case are identical. But indeed they have different output.
1st case
2nd case
tactics Thu 25 Mar 2010
Obj
can hold any value in Fantom except fornull
.In case 1, the variable
v
is inferring the typeObj?
. Everything works.In case 2, the special variable
it
is inferring the typeObj
. It tries to coercenull
an it blows up and you get an exception.This is a bug. Case 2 should work the same as case 1.
brian Thu 25 Mar 2010
Promoted to ticket #1039 and assigned to brian
I think that is just a nullable bug somewhere in the compiler. If
it
is typed asObj?
thennull
should be a valid value. I suspect that is just some place whereit
is typed asObj
instead ofObj?
.brian Thu 25 Mar 2010
Renamed from Exclude null from List to It not typed as Obj? correctly
brian Thu 25 Mar 2010
Ticket resolved in 1.0.53
Took a while to track down, but its a one line fix