Skip to content

Commit

Permalink
internal/core/adt: finalize let value
Browse files Browse the repository at this point in the history
This introduces some bugs in issue2146.txtar that we will
fix again in a later CL.

Issue #2884

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Ic6ef903b4aefd47ab7324e3c631b980590957697
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193150
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
mpvl committed Apr 17, 2024
1 parent d323ba5 commit 4abbb53
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 130 deletions.
28 changes: 19 additions & 9 deletions cue/testdata/cycle/issue990.txtar
Expand Up @@ -416,7 +416,14 @@ Disjuncts: 3258
k: (string){ "simple" }
}
}
r2_r2_r1: (_){ _ }
r2_r2_r1: (#struct){
a: (#struct){
d: (#struct){
n: (string){ "c1" }
}
k: (string){ "simple" }
}
}
}
let subs#1multi = &[&[&[&[&[(〈3;#sub〉 & {
#p: 〈2;rd〉.a
Expand All @@ -427,7 +434,7 @@ Disjuncts: 3258
diff old new
--- old
+++ new
@@ -47,201 +47,194 @@
@@ -47,201 +47,201 @@
}
dict: (#struct){
}
Expand Down Expand Up @@ -752,10 +759,14 @@ diff old new
- d: (#struct){
- n: (string){ "c1" }
- }
- }
- }
- r2_r2_r1: (#struct){
- a: (#struct){
+ d: (#struct){
+ n: (string){ "c1" }
+ }
+ k: (string){ "simple" }
}
}
r2_r2_r1: (#struct){
a: (#struct){
- k: (string){ "simple" }
- d: (#struct){
- n: (string){ "c1" }
Expand All @@ -772,15 +783,14 @@ diff old new
+ k: (string){ "simple" }
+ }
+ }
+ r2_r2_r1: (_){ _ }
+ }
+ let subs#1multi = &[&[&[&[&[(〈3;#sub〉 & {
+ #p: 〈2;rd〉.a
+ })]]]]]
}
}
-- diff/todo/p0 --
out.#p.dict.r2_(r2_)_r1: missing structure!
-- diff/todo/p3 --
Reordering
-- out/eval --
(struct){
#AC: (#struct){
Expand Down
165 changes: 61 additions & 104 deletions cue/testdata/eval/issue2146.txtar
Expand Up @@ -52,33 +52,16 @@ Disjuncts: 189
-- out/evalalpha --
(struct){
p1: (struct){
#A: (#struct){ |(*(#struct){
x?: (_|_){
// [user] explicit error (_|_ literal) in source:
// ./in.cue:10:8
}
y: (int){ 1 }
let list#1 = (_|_){
// [user]
0: (_|_){
// [user] explicit error (_|_ literal) in source:
// ./in.cue:10:8
}
1: (int){ 1 }
}
all: (#list){
0: (int){ 1 }
}
}, (#struct){
x?: (int){ int }
y?: (int){ int }
let list#1 = (#list){
0: (int){ int }
1: (int){ int }
}
all: (#list){
}
}) }
#A: (#struct){
x?: (int){ int }
y?: (int){ int }
let list#1 = (#list){
0: (int){ int }
1: (int){ int }
}
all: (#list){
}
}
a: (#struct){
x: (int){ 3 }
y?: (int){ int }
Expand All @@ -103,33 +86,16 @@ Disjuncts: 189
}
}
p2: (struct){
#A: (#struct){ |(*(#struct){
x?: (_|_){
// [user] explicit error (_|_ literal) in source:
// ./in.cue:27:8
}
y: (int){ 1 }
let list#2 = (_|_){
// [user]
0: (_|_){
// [user] explicit error (_|_ literal) in source:
// ./in.cue:27:8
}
1: (int){ 1 }
}
all: (#list){
0: (int){ 1 }
}
}, (#struct){
x?: (int){ int }
y?: (int){ int }
let list#2 = (#list){
0: (int){ int }
1: (int){ int }
}
all: (#list){
}
}) }
#A: (#struct){
x?: (int){ int }
y?: (int){ int }
let list#2 = (#list){
0: (int){ int }
1: (int){ int }
}
all: (#list){
}
}
a: (#struct){
x: (int){ 3 }
y: (int){ 2 }
Expand Down Expand Up @@ -160,10 +126,15 @@ Disjuncts: 189
diff old new
--- old
+++ new
@@ -6,53 +6,45 @@
// ./in.cue:10:8
}
y: (int){ 1 }
@@ -1,58 +1,33 @@
(struct){
p1: (struct){
- #A: (#struct){ |(*(#struct){
- x?: (_|_){
- // [user] explicit error (_|_ literal) in source:
- // ./in.cue:10:8
- }
- y: (int){ 1 }
- let list#1 = (#list){
- 0: (_|_){
- // [incomplete] p1.#A.list.0: cannot reference optional field: x:
Expand Down Expand Up @@ -211,27 +182,16 @@ diff old new
- 〈1;x〉,
- 〈1;y〉,
- ]
+ let list#1 = (_|_){
+ // [user]
+ 0: (_|_){
+ // [user] explicit error (_|_ literal) in source:
+ // ./in.cue:10:8
+ }
+ 1: (int){ 1 }
+ }
+ all: (#list){
+ 0: (int){ 1 }
+ }
+ }, (#struct){
+ x?: (int){ int }
+ y?: (int){ int }
+ let list#1 = (#list){
+ 0: (int){ int }
+ 1: (int){ int }
+ }
+ all: (#list){
+ }
+ }) }
+ #A: (#struct){
+ x?: (int){ int }
+ y?: (int){ int }
+ let list#1 = (#list){
+ 0: (int){ int }
+ 1: (int){ int }
+ }
+ all: (#list){
+ }
+ }
+ a: (#struct){
+ x: (int){ 3 }
+ y?: (int){ int }
Expand All @@ -253,10 +213,16 @@ diff old new
all: (#list){
0: (int){ 3 }
}
@@ -65,51 +57,46 @@
// ./in.cue:27:8
}
y: (int){ 1 }
@@ -59,57 +34,35 @@
}
}
p2: (struct){
- #A: (#struct){ |(*(#struct){
- x?: (_|_){
- // [user] explicit error (_|_ literal) in source:
- // ./in.cue:27:8
- }
- y: (int){ 1 }
- let list#2 = (#list){
- 0: (_|_){
- // [incomplete] p2.#A.list.0: cannot reference optional field: x:
Expand Down Expand Up @@ -302,27 +268,16 @@ diff old new
- 〈1;x〉,
- 〈1;y〉,
- ]
+ let list#2 = (_|_){
+ // [user]
+ 0: (_|_){
+ // [user] explicit error (_|_ literal) in source:
+ // ./in.cue:27:8
+ }
+ 1: (int){ 1 }
+ }
+ all: (#list){
+ 0: (int){ 1 }
+ }
+ }, (#struct){
+ x?: (int){ int }
+ y?: (int){ int }
+ let list#2 = (#list){
+ 0: (int){ int }
+ 1: (int){ int }
+ }
+ all: (#list){
+ }
+ }) }
+ #A: (#struct){
+ x?: (int){ int }
+ y?: (int){ int }
+ let list#2 = (#list){
+ 0: (int){ int }
+ 1: (int){ int }
+ }
+ all: (#list){
+ }
+ }
+ a: (#struct){
+ x: (int){ 3 }
+ y: (int){ 2 }
Expand All @@ -345,6 +300,8 @@ diff old new
all: (#list){
0: (int){ 3 }
1: (int){ 2 }
-- diff/todo/p1 --
p1: missing disjuncts in result.
-- diff/todo/p3 --
Let expressions encoded differently.
-- out/eval --
Expand Down
32 changes: 16 additions & 16 deletions cue/testdata/eval/let.txtar
Expand Up @@ -159,14 +159,14 @@ keepDescending: t2: {
}

-- out/evalalpha/stats --
Leaks: 227
Leaks: 226
Freed: 16
Reused: 16
Allocs: 227
Allocs: 226
Retain: 0

Unifications: 211
Conjuncts: 1367
Unifications: 210
Conjuncts: 1451
Disjuncts: 32
-- out/evalalpha --
Errors:
Expand Down Expand Up @@ -203,11 +203,11 @@ referencesForViaLet."2": conflicting values 12 and 4:
./incomprehension.cue:23:24
referencesForViaLet."2": conflicting values 8 and 4:
./incomprehension.cue:23:24
nestedFor."0".X: invalid interpolation: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
nestedFor."0".X: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
./incomprehension.cue:55:5
./incomprehension.cue:53:15
./incomprehension.cue:53:18
nestedFor."1".X: invalid interpolation: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
nestedFor."1".X: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
./incomprehension.cue:55:5
./incomprehension.cue:53:15
./incomprehension.cue:53:18
Expand Down Expand Up @@ -404,14 +404,14 @@ Result:
}
}]]]]
"0": (_|_){
// [eval] nestedFor."0".X: invalid interpolation: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
// [eval] nestedFor."0".X: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
// ./incomprehension.cue:55:5
// ./incomprehension.cue:53:15
// ./incomprehension.cue:53:18
let X#1Fmulti = &[&[&[&[&[&[&[&[〈1;x〉]]]]]]]]
}
"1": (_|_){
// [eval] nestedFor."1".X: invalid interpolation: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
// [eval] nestedFor."1".X: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
// ./incomprehension.cue:55:5
// ./incomprehension.cue:53:15
// ./incomprehension.cue:53:18
Expand Down Expand Up @@ -489,17 +489,17 @@ diff old new
-Reused: 149
-Allocs: 61
-Retain: 184
+Leaks: 227
+Leaks: 226
+Freed: 16
+Reused: 16
+Allocs: 227
+Allocs: 226
+Retain: 0

-Unifications: 196
-Conjuncts: 365
-Disjuncts: 241
+Unifications: 211
+Conjuncts: 1367
+Unifications: 210
+Conjuncts: 1451
+Disjuncts: 32
-- diff/-out/evalalpha<==>+out/eval --
diff old new
Expand Down Expand Up @@ -543,11 +543,11 @@ diff old new
+ ./incomprehension.cue:23:24
+referencesForViaLet."2": conflicting values 8 and 4:
+ ./incomprehension.cue:23:24
+nestedFor."0".X: invalid interpolation: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
+nestedFor."0".X: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
+ ./incomprehension.cue:55:5
+ ./incomprehension.cue:53:15
+ ./incomprehension.cue:53:18
+nestedFor."1".X: invalid interpolation: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
+nestedFor."1".X: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
+ ./incomprehension.cue:55:5
+ ./incomprehension.cue:53:15
+ ./incomprehension.cue:53:18
Expand Down Expand Up @@ -752,14 +752,14 @@ diff old new
- "2": (int){ 2 }
+ }]]]]
+ "0": (_|_){
+ // [eval] nestedFor."0".X: invalid interpolation: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
+ // [eval] nestedFor."0".X: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
+ // ./incomprehension.cue:55:5
+ // ./incomprehension.cue:53:15
+ // ./incomprehension.cue:53:18
+ let X#1Fmulti = &[&[&[&[&[&[&[&[〈1;x〉]]]]]]]]
+ }
+ "1": (_|_){
+ // [eval] nestedFor."1".X: invalid interpolation: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
+ // [eval] nestedFor."1".X: invalid interpolation: invalid interpolation: invalid interpolation: conflicting values 2 and 1:
+ // ./incomprehension.cue:55:5
+ // ./incomprehension.cue:53:15
+ // ./incomprehension.cue:53:18
Expand Down
Expand Up @@ -127,6 +127,7 @@ diff old new
}
#A: (#struct){
-- diff/explanation --
The new error is a correct error, as the pattern constraint is invalid.
Seems reasonable to report error at connection as well.
-- out/eval --
(struct){
Expand Down
2 changes: 1 addition & 1 deletion internal/core/adt/eval_test.go
Expand Up @@ -78,7 +78,7 @@ func TestEvalAlpha(t *testing.T) {
"cycle/chain": "hang",
"cycle/evaluate": "hang",

// Later
// Later: all good, just much cruft.
"benchmarks/issue2176": "fails to remove errors",

// Performance
Expand Down

0 comments on commit 4abbb53

Please sign in to comment.