$ fan -version
Fantom Launcher
Copyright (c) 2006-2011, Brian Frank and Andy Frank
Licensed under the Academic Free License version 3.0
Java Runtime:
java.version: 1.6.0_22
java.vm.name: Java HotSpot(TM) 64-Bit Server VM
java.vm.vendor: Apple Inc.
java.vm.version: 17.1-b03-307
java.home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
fan.platform: macosx-x86_64
fan.version: 1.0.58
fan.env: sys::BootEnv
fan.home: /Users/me/fantom-1.0.58
brianSat 5 Mar 2011
It doesn't really have anything to do with the compiler actually. I believe your problem is caused by a fix to how Map handles null values. In build 1.0.57 we changed the behavior of containsKey to work correctly if the value if null. See #1356.
What is happening is that "__map" has actually be already mapped to null. So it does a get, not an add (with the result being null). But then you are trying to assign null to a non-nullable variable so NullErr is thrown.
vkuzkokovSat 5 Mar 2011
There is also a potential problem not covered by tests: You always create Str:Obj[:], while Str:Obj?[:] (with question mark) is what, I think, you need there.
yachrisSun 6 Mar 2011
@brian
I believe your problem is caused by a fix to how Map handles null values.
Bingo, that was it, thanks.
@vkuzkokov
There is also a potential problem not covered by tests: You always create Str:Obj[:], while Str:Obj?[:] (with question mark) is what, I think, you need there.
Good point -- I changed all the Str:Obj? declarations to Str:Obj, since this implements the "null is not an allowed value" idea. It's not a fantom map :-)
yachris Sat 5 Mar 2011
This works under 1.0.56, and fails under 1.0.58.
The code:
The tests:
My
fan -version
output:brian Sat 5 Mar 2011
It doesn't really have anything to do with the compiler actually. I believe your problem is caused by a fix to how Map handles null values. In build 1.0.57 we changed the behavior of containsKey to work correctly if the value if null. See #1356.
So consider this code:
What is happening is that "__map" has actually be already mapped to null. So it does a get, not an add (with the result being null). But then you are trying to assign null to a non-nullable variable so NullErr is thrown.
vkuzkokov Sat 5 Mar 2011
There is also a potential problem not covered by tests: You always create
Str:Obj[:]
, whileStr:Obj?[:]
(with question mark) is what, I think, you need there.yachris Sun 6 Mar 2011
@brian
Bingo, that was it, thanks.
@vkuzkokov
Good point -- I changed all the
Str:Obj?
declarations toStr:Obj
, since this implements the "null is not an allowed value" idea. It's not a fantom map :-)