-
-
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
Compilation error when using type-generic proc in type definition #20514
Comments
possibly addressed by #20423? |
It's not ideal but a common workaround is to use a template to intercept the typed code so it can actually compile as such: import std/math
template arr(a: typed, b: typedesc): auto = array[a, b]
type Foo[S:static[array[2, int]]] = object
values: arr(prod(S), float)
echo sizeof(Foo[[4,5]]) |
@beef331 Thanks! Any insight as to why the compiler chokes in the first place? I wound up wrapping proc intProd(s:seq[int]):int = prod[int](s)
type Foo[S:static[array[2, int]]] = object
values: array[intProd(S), float] |
this one may not related to my PR, that one main problem is inner generic doesn't get |
Related #19916 (generic object, static parameter, array index) |
What happened?
Using
prod
in a type definition causes the compiler to fail with an uninformative error message.Curiously, replacing
prod
withsum
causes a different outcome. The below program erroneously prints1
:Nim Version
Nim Compiler Version 1.7.3 [Windows: amd64]
Compiled at 2022-10-07
Copyright (c) 2006-2022 by Andreas Rumpf
active boot switches: -d:release
Current Standard Output Logs
Expected Standard Output Logs
No response
Possible Solution
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: