From: Dominik Honnef Date: Wed, 22 Jan 2014 03:44:54 +0000 (-0500) Subject: cmd/gc: do not typecheck nil types in multiple assignment X-Git-Tag: go1.3beta1~905 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=062ae4571168608ca2bcd6fa1a9d122a20a5d677;p=gostls13.git cmd/gc: do not typecheck nil types in multiple assignment Fixes #6572. LGTM=rsc, daniel.morsing, rsc R=golang-codereviews, bradfitz, minux.ma, iant, rsc, gobot, daniel.morsing CC=golang-codereviews https://golang.org/cl/14516055 --- diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c index 68d2c3404d..3c27d99154 100644 --- a/src/cmd/gc/typecheck.c +++ b/src/cmd/gc/typecheck.c @@ -2814,7 +2814,7 @@ typecheckas2(Node *n) n->op = OAS2FUNC; t = structfirst(&s, &r->type); for(ll=n->list; ll; ll=ll->next) { - if(ll->n->type != T) + if(t->type != T && ll->n->type != T) checkassignto(t->type, ll->n); if(ll->n->defn == n && ll->n->ntype == N) ll->n->type = t->type; diff --git a/test/fixedbugs/issue6572.go b/test/fixedbugs/issue6572.go new file mode 100644 index 0000000000..e75da54c99 --- /dev/null +++ b/test/fixedbugs/issue6572.go @@ -0,0 +1,21 @@ +// errorcheck + +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +func foo() (T, T) { // ERROR "undefined" + return 0, 0 +} + +func bar() (T, string, T) { // ERROR "undefined" + return 0, "", 0 +} + +func main() { + var x, y, z int + x, y = foo() + x, y, z = bar() // ERROR "cannot (use type|assign) string" +}