-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generics execute compile time code in wrong order #11947
Labels
Documentation Content
Related to documentation content (not generation).
Comments
timotheecour
changed the title
generic prepass executes code in wrong order, and gives FieldError
generics execute static code in wrong order, and gives FieldError
Aug 14, 2019
timotheecour
changed the title
generics execute static code in wrong order, and gives FieldError
generics execute compile time code in wrong order, and gives FieldError
Aug 14, 2019
see #11950 which fixes 1st part |
timotheecour
changed the title
generics execute compile time code in wrong order, and gives FieldError
generics cannot call macros (gives FieldError) and execute compile time code in wrong order
Aug 14, 2019
Araq
pushed a commit
that referenced
this issue
Aug 15, 2019
timotheecour
changed the title
generics cannot call macros (gives FieldError) and execute compile time code in wrong order
generics execute compile time code in wrong order
Aug 15, 2019
The "different code path" is a feature and this is your basic mistake:
It's simply not like that in Nim with its semi-checked generics. |
Araq
added
the
Documentation Content
Related to documentation content (not generation).
label
Aug 16, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The generic prepass order seems buggy, resulting in incomprehensible semantics (eg #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 c0d240b
Was it working in the previous Nim releases?
no
root cause for this:
when false
doesn't work inside a generic #8924 (when false:
doesn't work inside generics)related to this discussion: Generics proc + macros: identifier resolution happens before macros #6387 and [Meta] Generics/Static early symbol resolution #8677 (/cc @mratsim )
I don't this this is a dup because I didn't find a mention of
FieldError
as in example1The text was updated successfully, but these errors were encountered: