V version: V 0.1.29 2994e71
OS: macos, Mac OS X, 10.15.6, 19G2021
What did you do?
// source
if idx >= maxlen {
break(2)
}
What did you expect to see?
No change
What did you see instead?
// vfmt output
if idx >= maxlen {
break
(2)
}
Possibly related? #6005
This is correct behavior.
break doesn't have any arguments, and V doesn't use semicolons to separate statements, so (2) is parsed as the next statement.
Sorry – I just realized that this came from a C extension I've used in the past, and not C directly 🤦
Something like https://github.com/xbarin02/c-ext#some-examples
Is there a V shorthand for breaking a nested loop? In JS, this is something like:
outer: for (let i=0; i < foo.length; i++) {
for (let j=0; j < bar.length; j++) {
if (condition) break outer;
}
}
Not yet, but it's planned.
Thank you; feel free to mark this as invalid.
This has just been implemented by @ntrel
@lukeed
Amazing, thank you @ntrel!