ast: fix `new_struct := MyStruct{...(*old_struct)}` (#8544)
parent
27239db427
commit
162c42dbe9
|
@ -1254,6 +1254,8 @@ pub fn (expr Expr) is_lvalue() bool {
|
|||
CTempVar { return true }
|
||||
IndexExpr { return expr.left.is_lvalue() }
|
||||
SelectorExpr { return expr.expr.is_lvalue() }
|
||||
ParExpr { return expr.expr.is_lvalue() } // for var := &{...(*pointer_var)}
|
||||
PrefixExpr { return expr.right.is_lvalue() }
|
||||
else {}
|
||||
}
|
||||
return false
|
||||
|
|
|
@ -170,6 +170,14 @@ fn test_assoc_with_vars() {
|
|||
}
|
||||
assert merged.a == 42
|
||||
assert merged.b == 7
|
||||
|
||||
def3 := &Def{ 100, 200 }
|
||||
merged1 := Def{...(*def3)}
|
||||
merged2 := &Def{...(*def3)}
|
||||
assert merged1.a == 100
|
||||
assert merged1.b == 200
|
||||
assert merged2.a == 100
|
||||
assert merged2.b == 200
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
Loading…
Reference in New Issue