]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix spurious 'use of untyped nil' error
authorJan Ziak <0xe2.0x9a.0x9b@gmail.com>
Thu, 27 Mar 2014 17:47:00 +0000 (18:47 +0100)
committerJan Ziak <0xe2.0x9a.0x9b@gmail.com>
Thu, 27 Mar 2014 17:47:00 +0000 (18:47 +0100)
Fixes #6402

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/81340044

src/cmd/gc/const.c
test/fixedbugs/issue6402.go [new file with mode: 0644]

index cfb1f0adef22f638b8aded22b827afd0d9c4b935..a725ea971cd3f8bb5b2bd9ccec8a82f9a2a61a8f 100644 (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;
                }
diff --git a/test/fixedbugs/issue6402.go b/test/fixedbugs/issue6402.go
new file mode 100644 (file)
index 0000000..da5980c
--- /dev/null
@@ -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"
+}