Open timotheecour opened 5 years ago
see https://github.com/nim-lang/Nim/pull/11950 which fixes 1st part the fact the 1st part exists only for generics is because a different code path is being used for generics vs regular procs for calling macros. The 2nd part is still there.
The "different code path" is a feature and this is your basic mistake:
Expected Output same as for when fun is not generic
It's simply not like that in Nim with its semi-checked generics.
The generic prepass order seems buggy, resulting in incomprehensible semantics (eg https://github.com/nim-lang/Nim/issues/8924), see also below.
that means if you add a
static: doAssert false
orwhen false: seemsDisabledButIsNot
the results are not what you'd expect and differ from what would happen inside a non-generic proc.Example2
Current Output
mfun7
(with nostatic
param) is evaluated too earlyExpected Output
same as for when fun is not generic:
Additional Information
Your Nim version (output of
nim -v
). recent devel c0d240b8cd3dc08d25c671b0dc7614fbfa980c2eWas it working in the previous Nim releases? no
root cause for this: https://github.com/nim-lang/Nim/issues/8924 (
when false:
doesn't work inside generics)related to this discussion: https://github.com/nim-lang/Nim/issues/6387 and https://github.com/nim-lang/Nim/issues/8677 (/cc @mratsim ) I don't this this is a dup because I didn't find a mention of
FieldError
as in example1