V version:
0.1.22 b4e8989
0.1.23 576618d
OS:
Linux / Kubuntu 18.04
What did you do?
I'm trying to get the attached array_bug_example.zip example to compile.
It tries to access a fixed size property on a "forwarded" C struct in a loop.
What did you expect to see?
I expected it to work and print the value stored in .x
What did you see instead?
jc_voronoi/jc_voronoi.v:59:25: Cant [] non-array/string/map. Got type "jcv_point"
57| println('Looping edges')
58| for bool(edge) {
59| println(edge.pos[0].x)
^
60| edge = C.jcv_diagram_get_next_edge( edge )
61| }
Updated array_bug_example.zip so it's compatible with 576618d
hehe was doing the same :-)
I have it to pass the issue BTW
Thanks to @nsauzede it's now working using:
for !isnil(edge) {
p := (edge.pos)[0] // Fix by calling like this
println(p.x)
edge = C.jcv_diagram_get_next_edge( edge )
}
I'll still regard it as an issue - the compiler should warn, auto fix or at least tell me what's wrong - or the syntax should be valid :slightly_smiling_face:
It also works if you use pos [2]pos, that also needs to be fixed.
Fixed size arrays need lots of work.
This issue seems to be fixed in the latest V (0.1.29 99e607d at the time of writing), but I can't test the code above as gg now uses Sokol and the glfw module was removed.
I can confirm it's fixed.
I've included the updated code here (stripped from all the graphic stuff) - outputting the seemingly correct points.
array_bug_example.zip
Most helpful comment
It also works if you use
pos [2]pos, that also needs to be fixed.Fixed size arrays need lots of work.