Skip to content

Commit

Permalink
cue/load: make imports work in "all package" mode
Browse files Browse the repository at this point in the history
The `build.Instance` was being created directly by `cue/load`, but
that ends up with an instance that contains a nil `loadFunc`,
so imports are then ignored. Use the regular build context
to create the new instance instead.

Signed-off-by: Roger Peppe <[email protected]>
Change-Id: I9f456fc7f09497ef16ce5d09a2f84c1f48d3374e
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1201522
Unity-Result: CUE porcuepine <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
  • Loading branch information
rogpeppe committed Sep 19, 2024
1 parent deae2a0 commit 43a1e12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 6 additions & 9 deletions cue/load/loader_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,12 @@ func (fp *fileProcessor) add(root string, file *build.File, mode importMode) {
return
}
if q == nil {
q = &build.Instance{
PkgName: pkg,

Dir: p.Dir,
DisplayPath: p.DisplayPath,
ImportPath: p.ImportPath + ":" + pkg,
Root: p.Root,
Module: p.Module,
}
q = fp.c.Context.NewInstance(p.Dir, nil)
q.PkgName = pkg
q.DisplayPath = p.DisplayPath
q.ImportPath = p.ImportPath + ":" + pkg
q.Root = p.Root
q.Module = p.Module
fp.pkgs[pkg] = q
}
p = q
Expand Down
4 changes: 3 additions & 1 deletion cue/load/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,9 @@ root: $CWD/testdata/testmod
dir: $CWD/testdata/testmod
display:.
files:
$CWD/testdata/testmod/test.cue`,
$CWD/testdata/testmod/test.cue
imports:
mod.test/test/sub: $CWD/testdata/testmod/sub/sub.cue`,
}}
tdtest.Run(t, testCases, func(t *tdtest.T, tc *loadTest) {
pkgs := Instances(tc.args, tc.cfg)
Expand Down

0 comments on commit 43a1e12

Please sign in to comment.