-
-
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
fix dot calls with resolved symbols in templates #22076
Conversation
doAssert deb1(-12'wrap) == "-12'wrap" | ||
doAssert deb1(-12'nonexistent) == "-12'nonexistent" | ||
doAssert deb2(-12'nonexistent) == """(DotExpr (RStrLit "-12") (Ident "\'nonexistent"))""" | ||
when false: # xxx bug: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not a bug. It's because this code is in a giant main
template, which binds the outer 'wrap
and wrap2
, because that's how the language works.
@@ -165,21 +162,16 @@ template main = | |||
doAssert fn2() == "[[-12]]" | |||
doAssert fn3() == "[[-12]]" | |||
|
|||
when false: # xxx this fails; bug 9 from https://github.com/nim-lang/Nim/pull/17020#issuecomment-803193947 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meanwhile this was actually the bug fixed by this PR, custom numeric literals generate dot fields which did not keep their resolved symbols in templates. It really wouldn't have taken much investigation to figure out this is related to dot fields and has nothing to do with custom numeric literals. The linked comment thinks it has something to do with 'abc
not working where abc
is a template param??? Very weird understanding of the language
Thanks for your hard work on this PR! Hint: mm: orc; opt: speed; options: -d:release |
@arnetheduck I think I've seen this kind of error appearing in Status' codebase. Backport to 1.6? |
sure, looks interesting as far as bugfixes go |
closes nim-lang#7223, closes nim-lang#11733, were fixed by nim-lang#22076
* fix dot calls with resolved symbols in templates * make old code work * fix custom number literals test * remove leftover debug marker * enable "bug 9" test too * fix renderer, add test for nim-lang#7085
add test to close nim-lang#7223, close nim-lang#11733 closes nim-lang#7223, closes nim-lang#11733, were fixed by nim-lang#22076
fixes #20073, fixes #7085
dotTransformation
transforms any resolvednkSym
s as the field name back intonkIdent
, but does not do this for sym choices. Generics account for this by converting tonkClosedSymChoice
, but templates don't do anything similar. Now this is done in templates, but since code depended on it turning tonkIdent
which was not resolved, we usenkOpenSymChoice
instead.