mirror of
https://github.com/vlang/v.git
synced 2025-09-18 11:56:57 -04:00
parent
6c9dd62d35
commit
f7a0eeb65c
@ -324,7 +324,7 @@ fn (mut g Gen) index_of_array(node ast.IndexExpr, sym ast.TypeSymbol) {
|
|||||||
if !node.is_option {
|
if !node.is_option {
|
||||||
g.or_block(tmp_opt, node.or_expr, elem_type)
|
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…
x
Reference in New Issue
Block a user