We create a variable y. The value of y is typed as [Int:Float]:Str. However, I try to index y at 3. This should be an error, because the key type is Int:Float, not Int. But instead of an error, I get null.
If I use the more usual syntax, I get the expected error.
fansh> z := [Int:Float]:Str[:]
[:]
fansh> z.typeof
[[sys::Int:sys::Float]:sys::Str]
fansh> z[3]
ERROR(2): Invalid args get([sys::Int:sys::Float], sys::Str?), not (sys::Int)
ERROR(2): Not a statement
fansh>
It seems as if Map.make doesn't properly initialize the object's type.
KevinKelleyMon 5 Apr 2010
That sounds like something that's come up before, but I can't find it. I think you're right, that's a bug; as I remember it, there was a ticket some time back about make for List and Map failing to note the type info. But searching, I got sidetracked into #7. :-)
Actually that is the expected behavior because calling Map constructor directly is typing y as Obj:Obj? thus no compiler type checking happens when you do y[3].
tacticsSat 10 Apr 2010
Ah, so the variable is typed as Obj:Obj? but the value stored there is [[sys::Int:sys::Float]:sys::Str]. Gotcha.
tactics Mon 5 Apr 2010
I just noticed this and I want to make sure it's me and not a a bug.
We create a variable
y
. The value ofy
is typed as[Int:Float]:Str
. However, I try to indexy
at3
. This should be an error, because the key type isInt:Float
, notInt
. But instead of an error, I getnull
.If I use the more usual syntax, I get the expected error.
It seems as if
Map.make
doesn't properly initialize the object's type.KevinKelley Mon 5 Apr 2010
That sounds like something that's come up before, but I can't find it. I think you're right, that's a bug; as I remember it, there was a ticket some time back about
make
for List and Map failing to note the type info. But searching, I got sidetracked into #7. :-)#633 is semi-related...
brian Sat 10 Apr 2010
Actually that is the expected behavior because calling
Map
constructor directly is typingy
asObj:Obj?
thus no compiler type checking happens when you doy[3]
.tactics Sat 10 Apr 2010
Ah, so the variable is typed as
Obj:Obj?
but the value stored there is[[sys::Int:sys::Float]:sys::Str]
. Gotcha.