Skip to content
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

[TODO] fix #13524: magics with untyped params (eg astToStr) now work inside generics #13525

Closed

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Feb 28, 2020

mixinContext = s.magic in {mDefined, mDefinedInScope, mCompiles, mAstToStr}

@timotheecour timotheecour force-pushed the pr_fix_13524_astToStr branch 2 times, most recently from 148818e to a507895 Compare February 28, 2020 03:50
@@ -1629,7 +1629,7 @@ else:
result[i+1] = y[i]


proc astToStr*[T](x: T): string {.magic: "AstToStr", noSideEffect.}
proc astToStr*(x: untyped): string {.magic: "AstToStr", noSideEffect.}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change though, for example, now astToStr(2 + 3) produces something different. Arguably something better, but ... breaking change!

Copy link
Member Author

@timotheecour timotheecour Feb 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what you mean; both before and after PR I get:

echo 'echo astToStr(2+3)' | nim c -r -f -
2 + 3

(where the -f is needed until #13506 gets merged)

x is really untyped, not typed, so the previous declaration didn't make sense (in particular, T is meaningless); it only worked because of the way magics currently work, but hopefully one day this would be an error

compiler/semgnrc.nim Outdated Show resolved Hide resolved
@krux02
Copy link
Contributor

krux02 commented Mar 16, 2020

if the tyUntyped trick i used isn't acceptable for some reason, I can simply change the logic to:

mixinContext = s.magic in {mDefined, mDefinedInScope, mCompiles, mAstToStr}

Yes, please do that.

@timotheecour
Copy link
Member Author

Yes, please do that.

did so in #13681 so #13524 can be fixed soon; but keeping this PR open as it provides a more general fix

@krux02
Copy link
Contributor

krux02 commented Mar 18, 2020

closing in favor of #13681

@krux02 krux02 closed this Mar 18, 2020
@timotheecour timotheecour changed the title fix #13524: magics with untyped params (eg astToStr) now work inside generics [TODO] fix #13524: magics with untyped params (eg astToStr) now work inside generics Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

astToStr doesn't work inside generics
3 participants