decl *declInfo // package-level declaration whose init expression/function body is checked
scope *Scope // top-most scope for lookups
version goVersion // current accepted language version; changes across files
- pos syntax.Pos // if valid, identifiers are looked up as if at position pos (used by Eval)
iota constant.Value // value of iota in a constant declaration; nil otherwise
errpos syntax.Pos // if valid, identifier position of a constant with inherited initializer
inTParamList bool // set if inside a type parameter list
// whose parent is the scope of the package that exported them.
func (env *environment) lookupScope(name string) (*Scope, Object) {
for s := env.scope; s != nil; s = s.parent {
- if obj := s.Lookup(name); obj != nil && (!env.pos.IsKnown() || cmpPos(obj.scopePos(), env.pos) <= 0) {
+ if obj := s.Lookup(name); obj != nil {
return s, obj
}
}
decl *declInfo // package-level declaration whose init expression/function body is checked
scope *Scope // top-most scope for lookups
version goVersion // current accepted language version; changes across files
- pos token.Pos // if valid, identifiers are looked up as if at position pos (used by Eval)
iota constant.Value // value of iota in a constant declaration; nil otherwise
errpos positioner // if set, identifier position of a constant with inherited initializer
inTParamList bool // set if inside a type parameter list
isPanic map[*ast.CallExpr]bool // set of panic call expressions (used for termination check)
hasLabel bool // set if a function makes use of labels (only ~1% of functions); unused outside functions
hasCallOrRecv bool // set if an expression contains a function call or channel receive operation
+
+ // go/types only
+ exprPos token.Pos // if valid, identifiers are looked up as if at position pos (used by CheckExpr, Eval)
}
// lookupScope looks up name in the current environment and if an object
// whose parent is the scope of the package that exported them.
func (env *environment) lookupScope(name string) (*Scope, Object) {
for s := env.scope; s != nil; s = s.parent {
- if obj := s.Lookup(name); obj != nil && (!env.pos.IsValid() || cmpPos(obj.scopePos(), env.pos) <= 0) {
+ if obj := s.Lookup(name); obj != nil && (!env.exprPos.IsValid() || cmpPos(obj.scopePos(), env.exprPos) <= 0) {
return s, obj
}
}