Skip to content

Commit

Permalink
remove PACKAGE_NAME hack (google#100)
Browse files Browse the repository at this point in the history
Bazel no longer relies on this special (thread-local) variable.
  • Loading branch information
adonovan authored Apr 4, 2018
1 parent c67265e commit 8b59892
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
13 changes: 2 additions & 11 deletions interp.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,17 +526,8 @@ loop:
name := f.Prog.Names[arg]
x := fr.fn.predeclared[name]
if x == nil {
if name == "PACKAGE_NAME" {
// Gross spec, gross hack.
// Users should just call package_name() function.
if v, ok := fr.fn.predeclared["package_name"].(*Builtin); ok {
x, _ = v.fn(thread, v, nil, nil)
}
}
if x == nil {
err = fmt.Errorf("internal error: predeclared variable %s is uninitialized", name)
break loop
}
err = fmt.Errorf("internal error: predeclared variable %s is uninitialized", name)
break loop
}
stack[sp] = x
sp++
Expand Down
2 changes: 0 additions & 2 deletions resolve/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,6 @@ func (r *resolver) useGlobal(id *syntax.Ident) binding {
id.Index = prev.Index
} else if r.isPredeclared(id.Name) {
scope = Predeclared // use of pre-declared
} else if id.Name == "PACKAGE_NAME" {
scope = Predeclared // nasty hack in Skylark spec; will go away (b/34240042).
} else if r.isUniversal(id.Name) {
scope = Universal // use of universal name
if !AllowFloat && id.Name == "float" {
Expand Down

0 comments on commit 8b59892

Please sign in to comment.