diff --git a/cmd/cue/cmd/testdata/script/issue3250.txtar b/cmd/cue/cmd/testdata/script/issue3250.txtar index 55546225e89..f5fba6bdf53 100644 --- a/cmd/cue/cmd/testdata/script/issue3250.txtar +++ b/cmd/cue/cmd/testdata/script/issue3250.txtar @@ -10,9 +10,9 @@ exec cue mod init # passes - with module exec cue export -t foo .:foo -# fails - with module -# TODO fix this case -! exec cue export -t foo foo.cue +# passes - with module +# (failed previously due to #3250). +exec cue export -t foo foo.cue -- foo.cue -- @if(foo) diff --git a/cue/load/loader_common.go b/cue/load/loader_common.go index 703f2fbd218..677aed37b04 100644 --- a/cue/load/loader_common.go +++ b/cue/load/loader_common.go @@ -266,9 +266,11 @@ func (fp *fileProcessor) add(root string, file *build.File, mode importMode) { if !fp.c.AllCUEFiles { tagIsSet := fp.tagger.tagIsSet - if p.Module != fp.c.Module { + if p.Module != "" && p.Module != fp.c.Module { // The file is outside the main module so treat all build tag keys as unset. - // TODO also consider packages explicitly specified on the command line. + // Note that if there's no module, we don't consider it to be outside + // the main module, because otherwise @if tags in non-package files + // explicitly specified on the command line will not work. tagIsSet = func(string) bool { return false }