aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/internal/gc/typecheck.go23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/cmd/internal/gc/typecheck.go b/src/cmd/internal/gc/typecheck.go
index fdd393d0cf..185cfecc68 100644
--- a/src/cmd/internal/gc/typecheck.go
+++ b/src/cmd/internal/gc/typecheck.go
@@ -1636,11 +1636,10 @@ OpSwitch:
}
// Unpack multiple-return result before type-checking.
+ var funarg *Type
if Istype(t, TSTRUCT) && t.Funarg != 0 {
- t = t.Type
- if Istype(t, TFIELD) {
- t = t.Type
- }
+ funarg = t
+ t = t.Type.Type
}
n.Type = t
@@ -1678,11 +1677,19 @@ OpSwitch:
break OpSwitch
}
- for args = args.Next; args != nil; args = args.Next {
- if args.N.Type == nil {
- continue
+ if funarg != nil {
+ for t := funarg.Type.Down; t != nil; t = t.Down {
+ if assignop(t.Type, n.Type.Type, nil) == 0 {
+ Yyerror("cannot append %v value to []%v", t.Type, n.Type.Type)
+ }
+ }
+ } else {
+ for args = args.Next; args != nil; args = args.Next {
+ if args.N.Type == nil {
+ continue
+ }
+ args.N = assignconv(args.N, t.Type, "append")
}
- args.N = assignconv(args.N, t.Type, "append")
}
break OpSwitch