mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
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:
parent
6119dc1b52
commit
21b2e16842
|
@ -1144,7 +1144,10 @@ defaultlit(Node **np, Type *t)
|
||||||
}
|
}
|
||||||
if(n->val.ctype == CTNIL) {
|
if(n->val.ctype == CTNIL) {
|
||||||
lineno = lno;
|
lineno = lno;
|
||||||
yyerror("use of untyped nil");
|
if(!n->diag) {
|
||||||
|
yyerror("use of untyped nil");
|
||||||
|
n->diag = 1;
|
||||||
|
}
|
||||||
n->type = T;
|
n->type = T;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
13
test/fixedbugs/issue6402.go
Normal file
13
test/fixedbugs/issue6402.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 6402: spurious 'use of untyped nil' error
|
||||||
|
|
||||||
|
package p
|
||||||
|
|
||||||
|
func f() uintptr {
|
||||||
|
return nil // ERROR "cannot use nil as type uintptr in return argument"
|
||||||
|
}
|
Loading…
Reference in a new issue