this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cue/load: fix `@if` attributes in command line-specified files

We were treating files directly specified on the command
line as outside of the module when actually they should not be.

Fixed #3250

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I6b6649aa0e53ed0184a2b3d0648f86bbd98561ed
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202738
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+7 -5
+3 -3
cmd/cue/cmd/testdata/script/issue3250.txtar
··· 10 10 # passes - with module 11 11 exec cue export -t foo .:foo 12 12 13 - # fails - with module 14 - # TODO fix this case 15 - ! exec cue export -t foo foo.cue 13 + # passes - with module 14 + # (failed previously due to #3250). 15 + exec cue export -t foo foo.cue 16 16 17 17 -- foo.cue -- 18 18 @if(foo)
+4 -2
cue/load/loader_common.go
··· 266 266 267 267 if !fp.c.AllCUEFiles { 268 268 tagIsSet := fp.tagger.tagIsSet 269 - if p.Module != fp.c.Module { 269 + if p.Module != "" && p.Module != fp.c.Module { 270 270 // The file is outside the main module so treat all build tag keys as unset. 271 - // TODO also consider packages explicitly specified on the command line. 271 + // Note that if there's no module, we don't consider it to be outside 272 + // the main module, because otherwise @if tags in non-package files 273 + // explicitly specified on the command line will not work. 272 274 tagIsSet = func(string) bool { 273 275 return false 274 276 }