cuelang/cue

cmd/cue(/load): clarify scope of build attributes and tags

myitcv opened this issue · 1 comments

What version of CUE are you using (cue version)?

$ cue version
cue version +37bf801b linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

# ./a
exec cue eval ./a
stdout 'name: string'

# ./b
exec cue eval ./b
stdout 'name: string'

# -t prod ./a
exec cue eval -t prod ./a
stdout 'name: "cueckoo"'

# -t prod ./b
exec cue eval -t prod ./b
stdout 'name: "cueckoo"'

# -t name=gopher ./a
exec cue eval -t name=gopher ./a
stdout 'name: "gopher"'

# -t name=gopher ./b
exec cue eval -t name=gopher ./b
stdout 'name: "gopher"'

-- a/a.cue --
package a

name: string @tag(name)
-- a/a2.cue --
@if(prod)

package a

name: string | *"cueckoo"
-- b/b.cue --
package b

import "mod.com/a"

name: a.name
-- cue.mod/module.cue --
module: "mod.com"

This behaves as expected. However, it's not clear this should be the behaviour from the docs at cue help injection.

What did you expect to see?

The docs for cue help injection are not clear on precisely what the expectation here should be. My intuition is that those docs should clarify that build attribute constraints apply to all packages during evaluation (a la Go build constraints), whereas tag attributes only apply to named package instances.

What did you see instead?

Potential confusion given the docs are incomplete on this question.

This issue has been migrated to cue-lang/cue#1005.

For more details about CUE's migration to a new home, please see cue-lang/cue#1078.