1
0
mirror of https://github.com/golang/go synced 2024-11-11 20:50:23 -07:00

gc: const nil bug

Fixes #1073.

R=ken2
CC=golang-dev
https://golang.org/cl/2169043
This commit is contained in:
Russ Cox 2010-09-11 15:47:56 -04:00
parent fa0c53da60
commit 0acb63769c
2 changed files with 6 additions and 0 deletions

View File

@ -261,6 +261,10 @@ walkdef(Node *n)
yyerror("const initializer must be constant");
goto ret;
}
if(isconst(e, CTNIL)) {
yyerror("const initializer cannot be nil");
goto ret;
}
t = n->type;
if(t != T) {
convlit(&e, t);

View File

@ -77,3 +77,5 @@ func main() {
f(String) // ERROR "convert|wrong type|cannot|incompatible"
f(Bool) // ERROR "convert|wrong type|cannot|incompatible"
}
const ptr = nil // ERROR "const.*nil"