This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/core/eval: rewrite of closedness algorithm
Spec did not change, but simplified algorithm. Fixes many bugs. This also adds a new compaction algorithm. This will be enabled in a follow-up CL. Also: - "not allowed" failure is now registered with child. This allows multiple failures to be recorded naturally, and also retains more of the correct structure. But more importantly, it prevents descending into the substructure, preventing spurious errors. - Position information has changed slightly, mostly for the better. This introduces a regression on trim. See tools/trim/trim_test.go Fixes #271 Fixes #320 Fixes #370 Fixes #471 Fixes #476 Fixes #483 Fixes #490 Fixes #491 Fixes #493 Fixes #494 Fixes #496 Fixes #497 Change-Id: Ia90ebbbafd8cfc768188d33f109a2e33a4cee922 Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7002 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
- Loading branch information
Showing
45 changed files
with
2,393 additions
and
956 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,20 @@ | ||
cue cmd run | ||
|
||
-- task.cue -- | ||
package ci | ||
|
||
// Must have | ||
// - indirection through definition | ||
// - unification of two list elements | ||
// - one of those elements must be _ | ||
// - Must use merge and unify tool file | ||
|
||
workflows: #Workflow | ||
|
||
#Workflow: ["a"] & [_] | ||
|
||
-- task_tool.cue -- | ||
package ci | ||
|
||
command: run: { | ||
} |
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,38 @@ | ||
cue cmd dostuffloop | ||
cmp stdout expect-stdout | ||
|
||
-- x_tool.cue -- | ||
package x | ||
|
||
import ( | ||
"tool/cli" | ||
"encoding/yaml" | ||
) | ||
|
||
command: dostuff: { | ||
write: cli.Print & { | ||
text: "yaml is " + yaml.Marshal(w) | ||
} | ||
} | ||
|
||
command: dostuffloop: { | ||
for w in l { | ||
write: cli.Print & { | ||
text: "yaml is " + yaml.Marshal(w) | ||
} | ||
} | ||
} | ||
-- y.cue -- | ||
package x | ||
|
||
#Workflow: { | ||
#: "working-directory": string | ||
} | ||
|
||
l: [w] | ||
w: #Workflow & { | ||
} | ||
|
||
-- expect-stdout -- | ||
yaml is {} | ||
|
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 |
---|---|---|
|
@@ -44,6 +44,7 @@ foo: multipath: { | |
} | ||
|
||
t: u: { | ||
x: 5 | ||
} | ||
} | ||
|
||
|
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,57 @@ | ||
-- in.cue -- | ||
a: close({ | ||
a: b: int | ||
}) | ||
|
||
b: a & { x: int } // err | ||
c: a & { a: c: int } // okay (non-recursive close) | ||
|
||
-- out/eval -- | ||
Errors: | ||
b: field `x` not allowed: | ||
./in.cue:1:10 | ||
./in.cue:5:10 | ||
|
||
Result: | ||
(_|_){ | ||
// [eval] | ||
a: (#struct){ | ||
a: (#struct){ | ||
b: (int){ int } | ||
} | ||
} | ||
b: (_|_){ | ||
// [eval] | ||
a: (#struct){ | ||
b: (int){ int } | ||
} | ||
x: (_|_){ | ||
// [eval] b: field `x` not allowed: | ||
// ./in.cue:1:10 | ||
// ./in.cue:5:10 | ||
} | ||
} | ||
c: (#struct){ | ||
a: (#struct){ | ||
b: (int){ int } | ||
c: (int){ int } | ||
} | ||
} | ||
} | ||
-- out/compile -- | ||
--- in.cue | ||
{ | ||
a: close({ | ||
a: { | ||
b: int | ||
} | ||
}) | ||
b: (〈0;a〉 & { | ||
x: int | ||
}) | ||
c: (〈0;a〉 & { | ||
a: { | ||
c: int | ||
} | ||
}) | ||
} |
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,44 @@ | ||
-- test.cue -- | ||
A: close({ | ||
a: 1 | ||
b: 2 | ||
}) | ||
|
||
B: A & { | ||
c: 3 | ||
} | ||
-- out/eval -- | ||
Errors: | ||
B: field `c` not allowed: | ||
./test.cue:1:10 | ||
./test.cue:7:2 | ||
|
||
Result: | ||
(_|_){ | ||
// [eval] | ||
A: (#struct){ | ||
a: (int){ 1 } | ||
b: (int){ 2 } | ||
} | ||
B: (_|_){ | ||
// [eval] | ||
a: (int){ 1 } | ||
b: (int){ 2 } | ||
c: (_|_){ | ||
// [eval] B: field `c` not allowed: | ||
// ./test.cue:1:10 | ||
// ./test.cue:7:2 | ||
} | ||
} | ||
} | ||
-- out/compile -- | ||
--- test.cue | ||
{ | ||
A: close({ | ||
a: 1 | ||
b: 2 | ||
}) | ||
B: (〈0;A〉 & { | ||
c: 3 | ||
}) | ||
} |
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
Oops, something went wrong.