Skip to content

Commit

Permalink
cmd/gc: fix spurious 'not enough arguments to return' error
Browse files Browse the repository at this point in the history
Fixes #6405

LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/72920046
  • Loading branch information
atomsymbol-notifications committed Mar 14, 2014
1 parent cbe777b commit 1483747
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/cmd/gc/typecheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,7 @@ typecheck1(Node **np, int top)
goto reswitch;
}
typecheck(&n->left, Erv | Etype | Ecall |(top&Eproc));
n->diag |= n->left->diag;
l = n->left;
if(l->op == ONAME && l->etype != 0) {
if(n->isddd && l->etype != OAPPEND)
Expand Down Expand Up @@ -2165,6 +2166,7 @@ typecheckaste(int op, Node *call, int isddd, Type *tstruct, NodeList *nl, char *
if(tstruct->broke)
goto out;

n = N;
if(nl != nil && nl->next == nil && (n = nl->n)->type != T)
if(n->type->etype == TSTRUCT && n->type->funarg) {
tn = n->type->type;
Expand Down Expand Up @@ -2239,10 +2241,14 @@ typecheckaste(int op, Node *call, int isddd, Type *tstruct, NodeList *nl, char *
return;

notenough:
if(call != N)
yyerror("not enough arguments in call to %N", call);
else
yyerror("not enough arguments to %O", op);
if(n == N || !n->diag) {
if(call != N)
yyerror("not enough arguments in call to %N", call);
else
yyerror("not enough arguments to %O", op);
if(n != N)
n->diag = 1;
}
goto out;

toomany:
Expand Down
13 changes: 13 additions & 0 deletions test/fixedbugs/issue6405.go
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 1483747

Please sign in to comment.