From 21b2e168424ee28bd20f7886ab53f68513857fa2 Mon Sep 17 00:00:00 2001 From: Jan Ziak <0xe2.0x9a.0x9b@gmail.com> Date: Thu, 27 Mar 2014 18:47:00 +0100 Subject: [PATCH] cmd/gc: fix spurious 'use of untyped nil' error Fixes #6402 LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/81340044 --- src/cmd/gc/const.c | 5 ++++- test/fixedbugs/issue6402.go | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/fixedbugs/issue6402.go diff --git a/src/cmd/gc/const.c b/src/cmd/gc/const.c index cfb1f0adef..a725ea971c 100644 --- a/src/cmd/gc/const.c +++ b/src/cmd/gc/const.c @@ -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 index 0000000000..da5980c9ab --- /dev/null +++ b/test/fixedbugs/issue6402.go @@ -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" +} -- 2.50.0