Skip to content

Commit

Permalink
internal/core/adt: less special handling for non-rooted
Browse files Browse the repository at this point in the history
We know from the cycle algorithm that inline and
non-rooted structs/lists should get the same treatment
as regular fields. This is a first step in removing
their discrepancies.

To avoid some test breakages, we had to move where
the unification of shared structures was done.
This indeed seems to be a more sensible spot.

Issue #3476
Issue #2850
Issue #2854
Fixes #3509

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: Ic26cb31f207d7be0209d01bad5c6df3130251e2f
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202269
Unity-Result: CUE porcuepine <[email protected]>
Reviewed-by: Matthew Sackman <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
mpvl committed Oct 14, 2024
1 parent 48b5a22 commit f5f947e
Show file tree
Hide file tree
Showing 18 changed files with 443 additions and 231 deletions.
43 changes: 43 additions & 0 deletions cue/testdata/builtins/056_issue314.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,49 @@ Retain: 17
Unifications: 45
Conjuncts: 77
Disjuncts: 62
-- out/evalalpha --
(struct){
x: (#struct){
s: (string){ "myname" }
out: (string){ "myname" }
}
#T: (#struct){
s: (string){ string }
out: (_|_){
// [incomplete] #T.out: error in call to text/template.Execute: cannot convert non-concrete value string:
// ./in.cue:14:7
// ./in.cue:13:2
}
}
#V: (#struct){
s: (string){ string }
out: (_|_){
// [incomplete] cannot convert incomplete value "string" to JSON:
// ./in.cue:20:7
}
}
#U: (#struct){
s: (string){ string }
out: (_|_){
// [incomplete] #U.out: error in call to encoding/yaml.Marshal: incomplete value string:
// ./in.cue:26:7
// ./in.cue:25:7
}
}
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -8,7 +8,7 @@
out: (_|_){
// [incomplete] #T.out: error in call to text/template.Execute: cannot convert non-concrete value string:
// ./in.cue:14:7
- // ./in.cue:15:3
+ // ./in.cue:13:2
}
}
#V: (#struct){
-- out/eval --
(struct){
x: (#struct){
Expand Down
8 changes: 4 additions & 4 deletions cue/testdata/builtins/incomplete.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Result:
// ./in.cue:50:17
}
max: (_|_){
// [incomplete] 0: operand param of '+' not concrete (was int):
// [incomplete] incompleteArgDecimalList.#a.transformed: operand param of '+' not concrete (was int):
// ./in.cue:50:17
}
}
Expand All @@ -221,7 +221,7 @@ Result:
// ./in.cue:58:16
}
joined: (_|_){
// [incomplete] 0: non-concrete value string in operand to +:
// [incomplete] incompleteArgStringList.#a.transformed: non-concrete value string in operand to +:
// ./in.cue:59:16
// ./in.cue:58:16
}
Expand Down Expand Up @@ -307,7 +307,7 @@ diff old new
}
max: (_|_){
- // [incomplete] incompleteArgDecimalList.#a.0: operand param of '+' not concrete (was int):
+ // [incomplete] 0: operand param of '+' not concrete (was int):
+ // [incomplete] incompleteArgDecimalList.#a.transformed: operand param of '+' not concrete (was int):
// ./in.cue:50:17
}
}
Expand All @@ -316,7 +316,7 @@ diff old new
}
joined: (_|_){
- // [incomplete] incompleteArgStringList.#a.0: non-concrete value string in operand to +:
+ // [incomplete] 0: non-concrete value string in operand to +:
+ // [incomplete] incompleteArgStringList.#a.transformed: non-concrete value string in operand to +:
// ./in.cue:59:16
// ./in.cue:58:16
}
Expand Down
48 changes: 32 additions & 16 deletions cue/testdata/builtins/matchn.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,10 @@ Result:
}
-- out/evalalpha --
Errors:
match.singleErr: invalid value {a:"foo"} (does not satisfy matchN(1, [{a:int}])): 0 matched, expected 1:
match.singleErr: invalid value {a:"foo"} (does not satisfy matchN(1, [~(#Foo)])): 0 matched, expected 1:
./in.cue:8:17
./in.cue:8:24
match.incompleteErr: invalid value {a:string} (does not satisfy matchN(1, [{a:int}])): 0 matched, expected 1:
match.incompleteErr: invalid value {a:string} (does not satisfy matchN(1, [~(#Foo)])): 0 matched, expected 1:
./in.cue:12:21
./in.cue:12:28
match.defaults.pickNested1Err: invalid value {a:*3 | int} (does not satisfy matchN(1, [{a:2}])): 0 matched, expected 1:
Expand All @@ -641,7 +641,7 @@ match.defaults.pickNested1Err: invalid value {a:*3 | int} (does not satisfy matc
match.defaults.pickNested2Err: invalid value {a:*3 | int} (does not satisfy matchN(1, [{a:<=2}])): 0 matched, expected 1:
./in.cue:41:23
./in.cue:41:30
not.singleErr: invalid value {a:2} (does not satisfy matchN(0, [{a:int}])): 1 matched, expected 0:
not.singleErr: invalid value {a:2} (does not satisfy matchN(0, [~(#Foo)])): 1 matched, expected 0:
./in.cue:74:17
./in.cue:74:24
not.doubleErr: invalid value {a:"foo"} (does not satisfy matchN(0, [matchN(0, [#Foo])])): 1 matched, expected 0:
Expand Down Expand Up @@ -699,7 +699,7 @@ Result:
a: (int){ 2 }
}
singleErr: (_|_){
// [eval] match.singleErr: invalid value {a:"foo"} (does not satisfy matchN(1, [{a:int}])): 0 matched, expected 1:
// [eval] match.singleErr: invalid value {a:"foo"} (does not satisfy matchN(1, [~(#Foo)])): 0 matched, expected 1:
// ./in.cue:8:17
// ./in.cue:8:24
a: (string){ "foo" }
Expand All @@ -708,7 +708,7 @@ Result:
a: (int){ int }
}
incompleteErr: (_|_){
// [eval] match.incompleteErr: invalid value {a:string} (does not satisfy matchN(1, [{a:int}])): 0 matched, expected 1:
// [eval] match.incompleteErr: invalid value {a:string} (does not satisfy matchN(1, [~(#Foo)])): 0 matched, expected 1:
// ./in.cue:12:21
// ./in.cue:12:28
a: (string){ string }
Expand Down Expand Up @@ -782,7 +782,7 @@ Result:
a: (string){ "foo" }
}
singleErr: (_|_){
// [eval] not.singleErr: invalid value {a:2} (does not satisfy matchN(0, [{a:int}])): 1 matched, expected 0:
// [eval] not.singleErr: invalid value {a:2} (does not satisfy matchN(0, [~(#Foo)])): 1 matched, expected 0:
// ./in.cue:74:17
// ./in.cue:74:24
a: (int){ 2 }
Expand Down Expand Up @@ -1015,12 +1015,15 @@ Result:
diff old new
--- old
+++ new
@@ -2,27 +2,21 @@
match.singleErr: invalid value {a:"foo"} (does not satisfy matchN(1, [{a:int}])): 0 matched, expected 1:
@@ -1,28 +1,22 @@
Errors:
-match.singleErr: invalid value {a:"foo"} (does not satisfy matchN(1, [{a:int}])): 0 matched, expected 1:
+match.singleErr: invalid value {a:"foo"} (does not satisfy matchN(1, [~(#Foo)])): 0 matched, expected 1:
./in.cue:8:17
./in.cue:8:24
- ./in.cue:10:13
match.incompleteErr: invalid value {a:string} (does not satisfy matchN(1, [{a:int}])): 0 matched, expected 1:
-match.incompleteErr: invalid value {a:string} (does not satisfy matchN(1, [{a:int}])): 0 matched, expected 1:
+match.incompleteErr: invalid value {a:string} (does not satisfy matchN(1, [~(#Foo)])): 0 matched, expected 1:
./in.cue:12:21
./in.cue:12:28
- ./in.cue:14:17
Expand All @@ -1032,7 +1035,8 @@ diff old new
./in.cue:41:23
./in.cue:41:30
- ./in.cue:44:19
not.singleErr: invalid value {a:2} (does not satisfy matchN(0, [{a:int}])): 1 matched, expected 0:
-not.singleErr: invalid value {a:2} (does not satisfy matchN(0, [{a:int}])): 1 matched, expected 0:
+not.singleErr: invalid value {a:2} (does not satisfy matchN(0, [~(#Foo)])): 1 matched, expected 0:
./in.cue:74:17
./in.cue:74:24
- ./in.cue:76:13
Expand Down Expand Up @@ -1067,16 +1071,24 @@ diff old new

Result:
(_|_){
@@ -83,7 +72,6 @@
// [eval] match.singleErr: invalid value {a:"foo"} (does not satisfy matchN(1, [{a:int}])): 0 matched, expected 1:
@@ -80,10 +69,9 @@
a: (int){ 2 }
}
singleErr: (_|_){
- // [eval] match.singleErr: invalid value {a:"foo"} (does not satisfy matchN(1, [{a:int}])): 0 matched, expected 1:
+ // [eval] match.singleErr: invalid value {a:"foo"} (does not satisfy matchN(1, [~(#Foo)])): 0 matched, expected 1:
// ./in.cue:8:17
// ./in.cue:8:24
- // ./in.cue:10:13
a: (string){ "foo" }
}
incompleteOK: (struct){
@@ -93,7 +81,6 @@
// [eval] match.incompleteErr: invalid value {a:string} (does not satisfy matchN(1, [{a:int}])): 0 matched, expected 1:
@@ -90,10 +78,9 @@
a: (int){ int }
}
incompleteErr: (_|_){
- // [eval] match.incompleteErr: invalid value {a:string} (does not satisfy matchN(1, [{a:int}])): 0 matched, expected 1:
+ // [eval] match.incompleteErr: invalid value {a:string} (does not satisfy matchN(1, [~(#Foo)])): 0 matched, expected 1:
// ./in.cue:12:21
// ./in.cue:12:28
- // ./in.cue:14:17
Expand Down Expand Up @@ -1108,8 +1120,12 @@ diff old new
a: (int){ |(*(int){ 3 }, (int){ int }) }
}
}
@@ -170,7 +155,6 @@
// [eval] not.singleErr: invalid value {a:2} (does not satisfy matchN(0, [{a:int}])): 1 matched, expected 0:
@@ -167,10 +152,9 @@
a: (string){ "foo" }
}
singleErr: (_|_){
- // [eval] not.singleErr: invalid value {a:2} (does not satisfy matchN(0, [{a:int}])): 1 matched, expected 0:
+ // [eval] not.singleErr: invalid value {a:2} (does not satisfy matchN(0, [~(#Foo)])): 1 matched, expected 0:
// ./in.cue:74:17
// ./in.cue:74:24
- // ./in.cue:76:13
Expand Down
Loading

0 comments on commit f5f947e

Please sign in to comment.