Skip to content

cue/load: tags across packages#4318

Open
bcachet wants to merge 2 commits intocue-lang:masterfrom
bcachet:feat/tags-across-packages
Open

cue/load: tags across packages#4318
bcachet wants to merge 2 commits intocue-lang:masterfrom
bcachet:feat/tags-across-packages

Conversation

@bcachet
Copy link
Copy Markdown

@bcachet bcachet commented Mar 30, 2026

tags marked with scope=mod are shared across packages of the same module
=> it allow to define some tag once in the module and reuse them in several packages/files

Note

Fix issue reported in #1070

@bcachet bcachet requested a review from cueckoo as a code owner March 30, 2026 21:13
@bcachet bcachet marked this pull request as draft March 30, 2026 21:14
@bcachet bcachet marked this pull request as ready for review March 30, 2026 21:16
@bcachet bcachet changed the title cmd/cue: tags across packages cue/load: tags across packages Mar 30, 2026
@tag marked with `scope=mod` are shared across packages of the same module
=> it allow to define some @tag once in the module and reuse them in several packages/files

Fixes cue-lang#1070

Signed-off-by: Bertrand Cachet <bertrand.cachet@exoscale.ch>
@bcachet bcachet force-pushed the feat/tags-across-packages branch from ddef495 to 869f72f Compare March 30, 2026 21:18
// the same module. These tags are injected even when their package is
// not a root package but is merely imported.
if c.Module != "" {
visited := map[string]bool{}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, it looks like you know the minimum required size of the map, but then you pass it down through findModuleScopeTags recursively, and continue adding to it. Can you estimate how many entries you'll wind up with?

Suggested change
visited := map[string]bool{}
visited := make(map[string]bool, len(a))

Also, I'd rather see map[string]struct{} here, but you'd need to adjust your findModuleScopeTags signature to play along.

Copy link
Copy Markdown
Author

@bcachet bcachet Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adapted accordingly in ec6d5f6

Signed-off-by: Bertrand Cachet <bertrand.cachet@exoscale.ch>
@bcachet bcachet force-pushed the feat/tags-across-packages branch from 8060b49 to ec6d5f6 Compare March 31, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants