Open
Description
Describe the bug
We have an array of arrays rows = [][]string{}
and push a not defined empty array rows << [ ]
and got a C error.
Operation rows << [ ]
is not marked as invalid.
A workaround is to push like this: rows << []string{}
.
Reproduction Steps
fn one(mut rows [][]string) {
rows << [ '1a', '1b' ]
}
fn two(empty bool, mut rows [][]string) {
if empty {
rows << [ ] // C error
//rows << []string{} // workaround
} else {
rows << [ '2a', '2b' ]
}
}
fn main() {
mut rows := [][]string{}
one(mut rows)
two(true, mut rows)
println(rows)
}
Expected Behavior
Print:
[['1a', '1b'], []]
Or inform rows << []
should be changed by row << []string{}
Current Behavior
Running code...
Can't run code. The server returned an error:
/tmp/v_60000/../../../../../../box/code.v:7: error: pointer expected
builder error:
==================
C error found. It should never happen, when compiling pure V code.
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.9 a59ebea
Environment details (OS name and version, etc.)
https://play.vlang.io/p/734e07e5c5
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.