cmd/gc: fix spurious 'use of untyped nil' error

Fixes #6402

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/81340044
This commit is contained in:
Jan Ziak 2014-03-27 18:47:00 +01:00
parent 6119dc1b52
commit 21b2e16842
2 changed files with 17 additions and 1 deletions

View file

@ -1144,7 +1144,10 @@ defaultlit(Node **np, Type *t)
}
if(n->val.ctype == CTNIL) {
lineno = lno;
yyerror("use of untyped nil");
if(!n->diag) {
yyerror("use of untyped nil");
n->diag = 1;
}
n->type = T;
break;
}

View 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 6402: spurious 'use of untyped nil' error
package p
func f() uintptr {
return nil // ERROR "cannot use nil as type uintptr in return argument"
}