-
-
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
.this pragma doesn't work with generics #5053
Comments
It works if the template is instantiated, maybe it has something to do with that. type A[T] = object
x: T
{.this: self.}
proc testproc[T](self: A[int]) =
echo x |
The issue is that
The compiler also looks up symbols when it generates an instantiation, so removing the pre-instantiation lookup doesn't appear to break anything, and it fixes this issue. But maybe it's there for a reason. |
The pre-instantiation lookup is required to implement the proper "open vs closed symbol lookup" rules. http://nim-lang.org/docs/manual.html#generics-symbol-lookup-in-generics It's a tough issue, maybe we need to weaken the prepass if a 'this' parameter is used. |
Is there some temporary workaround you can think of? |
{.this.} is deprecated. Can be closed? |
First example results in
Error: undeclared identifier: 'x'
, second example compiles without issue.The text was updated successfully, but these errors were encountered: