V version: 0.1.28 e666209
OS: Linux Mint 19.3
What did you do?
I have tried to make use of a generic structure, but the compiler gives me an error. I have checked the docs.md to see if it was doing something wrong, but it was still fine.
struct Zone<T> { val T }
What did you expect to see?
Make this work
What did you see instead?
error: `Zone` lacks body
1 |
2 | struct Zone<T> {
| ~~~~
3 | val T
4 | }
This would be my first contribution to V. Anyone mind if I take a stab at fixing this bug?
@joe-conigliaro has been working on generics (a couple of commits today), so I'd coordinate with him, but... PRs are always welcome!
Basic implementation for generics structs has arrived: https://github.com/vlang/v/commit/ab37dcaa9c0de86ee3be7673fdc42d8d0ba84cef
(What I mean basic is that things are still brittle so keep an eye for the updates :wink: )
This works now
struct Zone<T> { val T }
fn main() {
z := Zone<int>{val: 23}
println(z)
}
Output:
Zone_T_int {
val: 23
}