diff --git a/internal/core/compile/compile.go b/internal/core/compile/compile.go index a812b6803d1..9c530ef5cc6 100644 --- a/internal/core/compile/compile.go +++ b/internal/core/compile/compile.go @@ -275,7 +275,7 @@ func (c *compiler) compileFiles(a []*ast.File) *adt.Vertex { // Or value? // - anything in an anonymous file // for _, f := range a { - if p := internal.GetPackageInfo(f); p.IsAnonymous() { + if f.PackageName() == "" { continue } for _, d := range f.Decls { diff --git a/internal/core/runtime/resolve.go b/internal/core/runtime/resolve.go index 59ab5f224d5..843245864b4 100644 --- a/internal/core/runtime/resolve.go +++ b/internal/core/runtime/resolve.go @@ -21,7 +21,6 @@ import ( "cuelang.org/go/cue/ast" "cuelang.org/go/cue/build" "cuelang.org/go/cue/errors" - "cuelang.org/go/internal" ) // TODO(resolve): this is also done in compile, do we need both? @@ -32,7 +31,7 @@ func (r *Runtime) ResolveFiles(p *build.Instance) (errs errors.Error) { // may be linked to any top-level entry of any of the files. allFields := map[string]ast.Node{} for _, f := range p.Files { - if p := internal.GetPackageInfo(f); p.IsAnonymous() { + if f.PackageName() == "" { continue } for _, d := range f.Decls { @@ -44,7 +43,7 @@ func (r *Runtime) ResolveFiles(p *build.Instance) (errs errors.Error) { } } for _, f := range p.Files { - if p := internal.GetPackageInfo(f); p.IsAnonymous() { + if f.PackageName() == "" { continue } err := resolveFile(idx, f, p, allFields) diff --git a/internal/internal.go b/internal/internal.go index bb459deade6..e70008fbbf6 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -138,11 +138,6 @@ type PkgInfo struct { Name string } -// IsAnonymous reports whether the package is anonymous. -func (p *PkgInfo) IsAnonymous() bool { - return p.Name == "" || p.Name == "_" -} - func GetPackageInfo(f *ast.File) PkgInfo { for i, d := range f.Decls { switch x := d.(type) {