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) {
|
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)
|
sym := g.table.sym(node.typ)
|
||||||
if sym.kind in [.sum_type, .interface_] {
|
if sym.kind in [.sum_type, .interface_] {
|
||||||
g.expr_with_cast(node.expr, node.expr_type, node.typ)
|
g.expr_with_cast(node.expr, node.expr_type, node.typ)
|
||||||
|
|
|
@ -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