I've been experimenting with upgrading to the latest Nim 2.2.0 and while the last ones (including 2.0.10) have been working fine for us, there is an issue in two similar with 2.2.0.
Code:
One of the spots is here: https://github.com/arturo-lang/arturo/blob/master/src/helpers/objects.nim#L282
# perform initialization
# using the available constructor
if (let constructor = magicMethods.getOrDefault(ConstructorM, nil); not constructor.isNil):
args.insert(result)
constructor(args)
MagicMethods, MagicMethodInternal, etc are all defined here: https://github.com/arturo-lang/arturo/blob/master/src/vm/values/types.nim#L152-L198
The error:
../arturo/src/vm/values/comparison.nim(179, 23) template/generic instantiation of `fetch` from here
../arturo/src/vm/values/types.nim(497, 20) template/generic instantiation of `getOrDefault` from here
/Users/drkameleon/.choosenim/toolchains/nim-2.2.0/lib/pure/collections/tables.nim(437, 19) Error: type mismatch: got <typedesc[MagicMethodInternal]>
but expected one of:
MagicMethodInternal = proc (values: ValueArray){.closure.}
stack trace: (most recent call last)
Can you please shed some light as to what is going on here? I've been experimenting a bit and I cannot say I know what to fix.
Any help is more than welcome! :)
Could be relevant?
Apparently, I got it to work by using:
magicMethods.getOrDefault(ConstructorM)
instead of:
magicMethods.getOrDefault(ConstructorM, nil)
Could there be an issue with converting nil to the expected default value?