mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
078229f213
commit
1e52b2c134
@ -4437,11 +4437,6 @@ fn (mut g Gen) ident(node ast.Ident) {
|
||||
}
|
||||
|
||||
fn (mut g Gen) cast_expr(node ast.CastExpr) {
|
||||
if g.is_amp {
|
||||
// &Foo(0) => ((Foo*)0)
|
||||
g.out.go_back(1)
|
||||
}
|
||||
g.is_amp = false
|
||||
sym := g.table.sym(node.typ)
|
||||
if sym.kind in [.sum_type, .interface_] {
|
||||
g.expr_with_cast(node.expr, node.expr_type, node.typ)
|
||||
|
16
vlib/v/tests/cast_in_index_of_ref_fixed_array_test.v
Normal file
16
vlib/v/tests/cast_in_index_of_ref_fixed_array_test.v
Normal file
@ -0,0 +1,16 @@
|
||||
type Entity = int
|
||||
|
||||
struct Component {
|
||||
vals [256]int
|
||||
}
|
||||
|
||||
fn (c Component) get_broken(e Entity) &int {
|
||||
return &c.vals[int(e)]
|
||||
}
|
||||
|
||||
fn test_cast_in_ref_fixed_array() {
|
||||
c := Component{}
|
||||
a := c.get_broken(Entity(10))
|
||||
println(*a)
|
||||
assert *a == 0
|
||||
}
|
Loading…
Reference in New Issue
Block a user