diff options
-rw-r--r-- | src/cmd/gc/typecheck.c | 6 | ||||
-rw-r--r-- | src/cmd/gc/walk.c | 4 | ||||
-rw-r--r-- | test/fixedbugs/bug186.go | 4 | ||||
-rw-r--r-- | test/fixedbugs/bug188.go | 14 |
4 files changed, 25 insertions, 3 deletions
diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c index 2ff2af930..fba107f8b 100644 --- a/src/cmd/gc/typecheck.c +++ b/src/cmd/gc/typecheck.c @@ -86,7 +86,7 @@ reswitch: case OLITERAL: ok |= Erv; if(n->iota && !(top & Eiota)) - yyerror("use of iota outside of constant initializer"); + yyerror("use of iota not in constant initializer"); goto ret; case ONONAME: @@ -101,6 +101,10 @@ reswitch: ok |= Erv; goto ret; + case OPACK: + yyerror("use of package %S not in selector", n->sym); + goto error; + /* * types (OIND is with exprs) */ diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index 2f5ff5832..b7d6d8e5e 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -230,6 +230,10 @@ walkdef(Node *n) yyerror("embedded type cannot be a pointer"); } break; + + case OPACK: + // nothing to see here + break; } ret: diff --git a/test/fixedbugs/bug186.go b/test/fixedbugs/bug186.go index 97c094734..a54934e2b 100644 --- a/test/fixedbugs/bug186.go +++ b/test/fixedbugs/bug186.go @@ -12,7 +12,7 @@ func f(x int) { } func main() { f(X); - f(iota); // ERROR "iota.*outside.*initializer" + f(iota); // ERROR "iota.*initializer" f(X); - f(iota); // ERROR "iota.*outside.*initializer" + f(iota); // ERROR "iota.*initializer" } diff --git a/test/fixedbugs/bug188.go b/test/fixedbugs/bug188.go new file mode 100644 index 000000000..cbd421bb7 --- /dev/null +++ b/test/fixedbugs/bug188.go @@ -0,0 +1,14 @@ +// errchk $G $D/$F.go + +// Copyright 2009 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. + +package main + +import "sort" + +func main() { + var x int; + sort(x); // ERROR "package.*selector" +} |