mirror of
https://github.com/golang/go
synced 2024-11-26 07:07:57 -07:00
cmd/gc: fix spurious 'not enough arguments to return' error
Fixes #6405 LGTM=rsc R=rsc, iant CC=golang-codereviews https://golang.org/cl/72920046
This commit is contained in:
parent
cbe777b2c7
commit
1483747f3c
@ -1065,6 +1065,7 @@ reswitch:
|
|||||||
goto reswitch;
|
goto reswitch;
|
||||||
}
|
}
|
||||||
typecheck(&n->left, Erv | Etype | Ecall |(top&Eproc));
|
typecheck(&n->left, Erv | Etype | Ecall |(top&Eproc));
|
||||||
|
n->diag |= n->left->diag;
|
||||||
l = n->left;
|
l = n->left;
|
||||||
if(l->op == ONAME && l->etype != 0) {
|
if(l->op == ONAME && l->etype != 0) {
|
||||||
if(n->isddd && l->etype != OAPPEND)
|
if(n->isddd && l->etype != OAPPEND)
|
||||||
@ -2165,6 +2166,7 @@ typecheckaste(int op, Node *call, int isddd, Type *tstruct, NodeList *nl, char *
|
|||||||
if(tstruct->broke)
|
if(tstruct->broke)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
n = N;
|
||||||
if(nl != nil && nl->next == nil && (n = nl->n)->type != T)
|
if(nl != nil && nl->next == nil && (n = nl->n)->type != T)
|
||||||
if(n->type->etype == TSTRUCT && n->type->funarg) {
|
if(n->type->etype == TSTRUCT && n->type->funarg) {
|
||||||
tn = n->type->type;
|
tn = n->type->type;
|
||||||
@ -2239,10 +2241,14 @@ out:
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
notenough:
|
notenough:
|
||||||
if(call != N)
|
if(n == N || !n->diag) {
|
||||||
yyerror("not enough arguments in call to %N", call);
|
if(call != N)
|
||||||
else
|
yyerror("not enough arguments in call to %N", call);
|
||||||
yyerror("not enough arguments to %O", op);
|
else
|
||||||
|
yyerror("not enough arguments to %O", op);
|
||||||
|
if(n != N)
|
||||||
|
n->diag = 1;
|
||||||
|
}
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
toomany:
|
toomany:
|
||||||
|
13
test/fixedbugs/issue6405.go
Normal file
13
test/fixedbugs/issue6405.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// Issue 6405: spurious 'not enough arguments to return' error
|
||||||
|
|
||||||
|
package p
|
||||||
|
|
||||||
|
func Open() (int, error) {
|
||||||
|
return OpenFile() // ERROR "undefined: OpenFile"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user