mirror of
https://github.com/vlang/v.git
synced 2025-09-15 23:42:28 +03:00
parent
6c9dd62d35
commit
f7a0eeb65c
2 changed files with 15 additions and 1 deletions
|
@ -324,7 +324,7 @@ fn (mut g Gen) index_of_array(node ast.IndexExpr, sym ast.TypeSymbol) {
|
|||
if !node.is_option {
|
||||
g.or_block(tmp_opt, node.or_expr, elem_type)
|
||||
}
|
||||
g.write('\n${cur_line}*(${elem_type_str}*)${tmp_opt}.data')
|
||||
g.write('\n${cur_line}(*(${elem_type_str}*)${tmp_opt}.data)')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
14
vlib/v/tests/indexexpr_or_test.v
Normal file
14
vlib/v/tests/indexexpr_or_test.v
Normal file
|
@ -0,0 +1,14 @@
|
|||
struct Element {
|
||||
children []int
|
||||
}
|
||||
|
||||
fn f() []Element {
|
||||
return [Element{
|
||||
children: [1, 2, 3]
|
||||
}]
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
a := f()[0]!.children[0]!.str()
|
||||
assert dump(a) == '1'
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue