-
-
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
Templates: Method call prefers injected proc to outside, normal call doesn't #20000
Comments
???? proc bar(x: int): int = 10
template foo =
proc bar(x: int): int {.gensym.} = x + 2
echo bar(3)
block:
foo() Output:
proc bar(x: int): int = 10
template foo =
proc bar(x: int): int {.gensym.} = x + 2
echo 3.bar
block:
foo() Output:
Full stacktrace:
Edit: Moved to #20002 |
Nim/tests/template/template_various.nim Lines 274 to 283 in d0bae98
Does this imply the behavior for the normal call is intended? If so, is the inconsistency with method calls also fine since the behavior of method calls are intended? Blame gives this PR |
The solution in #20003 (treating the proc symbol as Cannot reproduce At the very least we can make it so explicitly |
fixes nim-lang#11184, fixes nim-lang#22605, fixes nim-lang#20000
fixes nim-lang#11184, fixes nim-lang#22605, fixes nim-lang#20000
Example
Current Output
Expected Output
Possible Solution
The issue is here:
Nim/compiler/semtempl.nim
Lines 63 to 72 in fb5fbf1
sfGenSym notin s.flags
is always true andnot isField
alternates betweentrue
andfalse
between normal call syntax and method call syntax. The XXX part seems to have the solution, considering thes.kind notin routineKinds
invariant.It could also fix #13515.Additional Information
{.dirty.}
is a workaroundmixin bar
is also a workaroundThe text was updated successfully, but these errors were encountered: