Russ Cox | 2b1c9b4 | 2012-02-16 23:49:30 -0500 | [diff] [blame] | 1 | // errorcheck |
Robert Griesemer | 044a3b1 | 2008-08-05 16:09:49 -0700 | [diff] [blame] | 2 | |
| 3 | // Copyright 2009 The Go Authors. All rights reserved. |
| 4 | // Use of this source code is governed by a BSD-style |
| 5 | // license that can be found in the LICENSE file. |
| 6 | |
| 7 | package P |
| 8 | |
| 9 | var x int |
| 10 | |
| 11 | func foo() { |
Russ Cox | 5b62b19 | 2009-08-12 13:18:54 -0700 | [diff] [blame] | 12 | print(P.x); // ERROR "undefined" |
Robert Griesemer | 044a3b1 | 2008-08-05 16:09:49 -0700 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | /* |
Russ Cox | 5b62b19 | 2009-08-12 13:18:54 -0700 | [diff] [blame] | 16 | uetli:~/Source/go1/test/bugs gri$ 6g bug085.go |
Robert Griesemer | 044a3b1 | 2008-08-05 16:09:49 -0700 | [diff] [blame] | 17 | bug085.go:6: P: undefined |
| 18 | Bus error |
| 19 | */ |
| 20 | |
| 21 | /* expected scope hierarchy (outermost to innermost) |
| 22 | |
Ian Lance Taylor | cc5682d | 2012-12-13 15:11:31 -0800 | [diff] [blame] | 23 | universe scope (contains predeclared identifiers int, float32, int32, len, etc.) |
Robert Griesemer | 044a3b1 | 2008-08-05 16:09:49 -0700 | [diff] [blame] | 24 | "solar" scope (just holds the package name P so it can be found but doesn't conflict) |
| 25 | global scope (the package global scope) |
| 26 | local scopes (function scopes) |
| 27 | */ |