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
"Cannot instantiate" error when template uses generic type #5926
Comments
Hello, I just wanted to say that I got this error too trying to implement a reverse type lookup system to correlate related types. I was able to get a macro which looks up the family of related types based on a backend name string working no problem, but upon getting the reverse lookup to work, generating a MWE near exactly like the above resulted in precisely the same error message. If you are interested, look at this. The test at line 361 is what reproduces this same error. I had the problem in both the 0.17.2 release and devel 1d1ba44. Note that in order to get the error message, one has to remove the compiles(()) checks, which are in there to monitor for when this issue may be fixed.
Has there been any progress in determining the cause of this issue? |
I just ran into this issue as well. The problem still exists although there is a minor difference in the error reporting now. For me the problem seems to occur with any instantiation of type
Data*[T] = object
x: T
template test*[T](xxx: T) =
let data = Data[T](x: xxx)
test(1) Traceback:
I also found a work-around: template test*[T](xxx: T) =
type TT = T
let data = Data[TT](x: xxx) |
@endragor I inserted a workaround in your issue. I hope you are ok with it. |
It works in Nim 1.0.6
|
Sample:
Output:
The error occurs both for
void
andint
.Git hash: da52ade
/cc @zah
The text was updated successfully, but these errors were encountered: