Closed flyx closed 6 years ago
BTW, the code as written (with the static[]) works correctly under nimscript.
While this is a valid bug, I don't see a good reason to make the mTable
parameter of putMutated
static here. This will only make the putMutated
proc generic, which will lead to unnecessary code bloat. The code works fine if mTable
is a normal array
or openarray
parameter.
this maybe related
type
helloProc = proc(): int
proc hello(): int =
echo "hello"
result = 1
let procs1 = [hello.helloProc]
const procs2 = [hello.helloProc]
echo procs1[0]() # ok
#echo procs2[0]() # failed to compile with `internal error: genAssignment: tyNil`
helloProc
is a closure proc type, but proc hello
is not, but why it works with let
in the first place? this conversion should be forbidden.
or the compiler could suggest something like:
please try to change `helloProc = proc(): int` into `helloProc = proc(): int {.nimcall.}`
this snippet below show without conversion both let
and const
works.
proc hello(): int =
echo "hello"
result = 1
let procs1 = [hello]
const procs2 = [hello]
echo procs1[0]()
echo procs2[0]()
this conversion should be forbidden.
No, why? The spec says that conversions from nimcall
to closure
are allowed.
This yields:
Removing the
static[]
around the parameter ofputMutated
make the code compile and work as expected.