mirror of
https://github.com/vlang/v.git
synced 2025-09-24 04:48:28 -04:00
parent
c088cbdbd5
commit
f2abf79f71
14
vlib/v/checker/tests/wrong_muti_dim_arr_declare_err.out
Normal file
14
vlib/v/checker/tests/wrong_muti_dim_arr_declare_err.out
Normal file
@ -0,0 +1,14 @@
|
||||
vlib/v/checker/tests/wrong_muti_dim_arr_declare_err.vv:4:15: warning: use `x := []Type{}` instead of `x := []Type`
|
||||
2 |
|
||||
3 | fn main() {
|
||||
4 | a2 := [][][]f32[][]{}
|
||||
| ~~~~~~~~~~
|
||||
5 | dump(typeof(a2).name)
|
||||
6 |
|
||||
vlib/v/checker/tests/wrong_muti_dim_arr_declare_err.vv:4:25: error: invalid expression: unexpected token `]`
|
||||
2 |
|
||||
3 | fn main() {
|
||||
4 | a2 := [][][]f32[][]{}
|
||||
| ^
|
||||
5 | dump(typeof(a2).name)
|
||||
6 |
|
9
vlib/v/checker/tests/wrong_muti_dim_arr_declare_err.vv
Normal file
9
vlib/v/checker/tests/wrong_muti_dim_arr_declare_err.vv
Normal file
@ -0,0 +1,9 @@
|
||||
module main
|
||||
|
||||
fn main() {
|
||||
a2 := [][][]f32[][]{}
|
||||
dump(typeof(a2).name)
|
||||
|
||||
assert typeof(a2).name == '[][][]f32'
|
||||
}
|
||||
|
@ -111,15 +111,7 @@ fn (mut p Parser) parse_array_type(expecting token.Kind, is_option bool) ast.Typ
|
||||
if elem_type.idx() == ast.thread_type_idx {
|
||||
p.register_auto_import('sync.threads')
|
||||
}
|
||||
mut nr_dims := 1
|
||||
// detect attr
|
||||
not_attr := p.peek_tok.kind != .name && p.peek_token(2).kind !in [.semicolon, .rsbr]
|
||||
for p.tok.kind == expecting && not_attr {
|
||||
p.next()
|
||||
p.check(.rsbr)
|
||||
nr_dims++
|
||||
}
|
||||
idx := p.table.find_or_register_array_with_dims(elem_type, nr_dims)
|
||||
idx := p.table.find_or_register_array_with_dims(elem_type, 1)
|
||||
if elem_type.has_flag(.generic) {
|
||||
return ast.new_type(idx).set_flag(.generic)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user