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
static Void main(){ echo(["",null].findAll{it!=null}) }throws
Why?
Addition
I found more simple.
static Void main(){ null{ echo(it) } }throws
Why?
tactics Thu 25 Mar 2010
Apparently, the
itspecial object isn't handlingnull. The coerce message is coming up because it's trying to castnullto anObjin both cases.Akcelisto Thu 25 Mar 2010
What is mean cast to
sys::Obj? I think, everything is instance ofsys::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
2nd case
tactics Thu 25 Mar 2010
Objcan hold any value in Fantom except fornull.In case 1, the variable
vis inferring the typeObj?. Everything works.In case 2, the special variable
itis inferring the typeObj. It tries to coercenullan 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
itis typed asObj?thennullshould be a valid value. I suspect that is just some place whereitis typed asObjinstead 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