@@ 18,9 18,11 @@ fn main() {
# this should work, s is mutable
let tup: (int, I) = (1, s)
tup.1.foo()
+ println(s.i)
}
@extern(import: "fmt", symbol: "Println")
fn println(v: int)
#=1
+#=2
@@ 628,7 628,6 @@ func (t *translator) goTypeExprFor(T semantic.Type) goast.Expr {
}
for i, field := range T.Fields {
st.Fields.List[i] = &goast.Field{
- // TODO: for now, always unexported?
Names: []*goast.Ident{{Name: t.resolver.NameForTuple(i, false)}},
Type: t.goTypeExprFor(field),
}
@@ 662,6 661,9 @@ func (t *translator) convertExprFromTo(expr goast.Expr, fromT, toT semantic.Type
// to it (as the rules for assignability are the same). Only thing is if one of the methods
// is satisfied by a ref function, the address of expr must be returned instead.
if semantic.AsInterfaceType(toT) != nil {
+ if st := semantic.AsStructType(fromT); st != nil && st.Ctx == semantic.Mutable {
+ return &goast.UnaryExpr{Op: gotoken.AND, X: expr}
+ }
return expr
}