blob: dae83f8a498bd9635993b19a4509f5e51935d9a5 [file] [log] [blame]
Russ Cox2b1c9b42012-02-16 23:49:30 -05001// errorcheck
Robert Griesemer044a3b12008-08-05 16:09:49 -07002
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
7package P
8
9var x int
10
11func foo() {
Russ Cox5b62b192009-08-12 13:18:54 -070012 print(P.x); // ERROR "undefined"
Robert Griesemer044a3b12008-08-05 16:09:49 -070013}
14
15/*
Russ Cox5b62b192009-08-12 13:18:54 -070016uetli:~/Source/go1/test/bugs gri$ 6g bug085.go
Robert Griesemer044a3b12008-08-05 16:09:49 -070017bug085.go:6: P: undefined
18Bus error
19*/
20
21/* expected scope hierarchy (outermost to innermost)
22
Ian Lance Taylorcc5682d2012-12-13 15:11:31 -080023universe scope (contains predeclared identifiers int, float32, int32, len, etc.)
Robert Griesemer044a3b12008-08-05 16:09:49 -070024"solar" scope (just holds the package name P so it can be found but doesn't conflict)
25global scope (the package global scope)
26local scopes (function scopes)
27*/