v icon indicating copy to clipboard operation
v copied to clipboard

checker: specific array initialisation fails

Open Hunam6 opened this issue 3 years ago • 2 comments

OS: macos, macOS, 12.3.1, 21E258
Processor: 8 cpus, 64bit, little endian, Apple M1
CC version: Apple clang version 13.1.6 (clang-1316.0.21.2)

getwd: /Users/hunam/Documents/dev/go2v
vmodules: /Users/hunam/.vmodules
vroot: /Applications/v
vexe: /Applications/v/v
vexe mtime: 2022-05-02 17:47:15
is vroot writable: true
is vmodules writable: true
V full version: V 0.2.4 8cc79e4.990afe3

Git version: git version 2.32.0 (Apple Git-132)
Git vroot status: weekly.2022.16-125-g990afe37
.git/config present: true
thirdparty/tcc status: thirdparty-unknown-unknown de82a130

What did you do?

fn main() {
	arr := []int{len: 2, init: [4][it] or { 0 }}
}

What did you expect to see? arr equals [4, 0]

What did you see instead?

a.v:2:33: error: non-constant array bound `it`
    1 | fn main() {
    2 |     arr := []int{len: 2, init: [4][it] or { 0 }}
      |                                    ~~
    3 | }

Hunam6 avatar May 02 '22 17:05 Hunam6

(the first three mentions are mistakes on my part)

Hunam6 avatar May 02 '22 22:05 Hunam6

currently

bug.v:2:42: error: unexpected number `0`, expecting name
    1 | fn main() {
    2 |     arr := []int{len: 2, init: [4][it] or { 0 }}
      |                                             ^
    3 | }

felipensp avatar Nov 15 '25 14:11 felipensp