This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/core: don't resolve values into anonymous packages
Non-CUE files are equivalent to a CUE file without a package clause or an anonyous package clause (package _). Identifier resolution should only happend across files of the same package. This can be a breaking change and we should probably introduce this in its separate release, maybe even minor release (say v0.4). Fixes #736 Change-Id: I28a0eb8618c2527b66c953c03e4bad695188654e Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8925 Reviewed-by: Marcel van Lohuizen <[email protected]> Reviewed-by: CUE cueckoo <[email protected]>
- Loading branch information
Showing
5 changed files
with
110 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Issue #736 | ||
# | ||
# references should never resolve to files of an | ||
# anonymous package (no package or package _). | ||
|
||
! cue eval data.yaml check.cue | ||
cmp stderr out-stderr | ||
|
||
! cue eval none.cue check.cue | ||
cmp stderr out-stderr | ||
|
||
! cue eval anon.cue check.cue | ||
cmp stderr out-stderr | ||
|
||
# TODO: allow this for now. Files without a package clause should not resolve | ||
# across other files. | ||
cue eval package.cue check.cue | ||
|
||
-- data.yaml -- | ||
nodes: | ||
- name: foo | ||
childs: | ||
- bar | ||
- baz | ||
|
||
- name: bar | ||
parent: foo | ||
|
||
- name: baz | ||
parent: foo | ||
|
||
-- none.cue -- | ||
nodes: [{ | ||
name: "foo" | ||
childs: ["bar", "baz"] | ||
}, { | ||
name: "bar" | ||
parent: "foo" | ||
}, { | ||
name: "baz" | ||
parent: "foo" | ||
}] | ||
|
||
-- anon.cue -- | ||
// This is an explicitly declared anonymous package. | ||
package _ | ||
|
||
nodes: [{ | ||
name: "foo" | ||
childs: ["bar", "baz"] | ||
}, { | ||
name: "bar" | ||
parent: "foo" | ||
}, { | ||
name: "baz" | ||
parent: "foo" | ||
}] | ||
|
||
-- package.cue -- | ||
package list | ||
|
||
nodes: [{ | ||
name: "foo" | ||
childs: ["bar", "baz"] | ||
}, { | ||
name: "bar" | ||
parent: "foo" | ||
}, { | ||
name: "baz" | ||
parent: "foo" | ||
}] | ||
|
||
-- check.cue -- | ||
import "list" | ||
|
||
#map: {for n in nodes {"\(n.name)": n}} | ||
|
||
-- out-stderr -- | ||
#map: reference "nodes" not found: | ||
./check.cue:3:17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters