Skip to content

Commit

Permalink
internal/core/adt: improve disjunction of scalars
Browse files Browse the repository at this point in the history
This CL fixes several related issues at once.
They needed to be fixed all at once as the
individual changes would introduce new errors.

The problem with Issue #3415 was that an
expression task was dropped if it triggered
the evaluation of a disjunction. Expression
tasks are now copied upon such a split.

Another issue was that unify could do a more
thorough evaluation even when only a scalar
was needed that was already known. This was
fixed by bailing out of unify sooner.

Conversely, when evaluating arguments for
builtins with concrete arguments, the
requested evaluation was often not strict
enough.

This new behavior mimics the V2 evaluator
much more closely. This is why some of the
error message changes, even when correct
in V3, now mimic more closely the V2
error messages.

Notes on test changes:
- Several p1 and p0 todos are fixed.
-chains.txtar: still broken, changes are
  immaterial to this

Fixes #3415

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I8ecd339f4672463588cafe7cf66cfa539c9210b0
Dispatch-Trailer: {"type":"trybot","CL":1206123,"patchset":1,"ref":"refs/changes/23/1206123/1","targetBranch":"master"}
  • Loading branch information
mpvl authored and cueckoo committed Dec 19, 2024
1 parent 10907da commit 7827aa8
Show file tree
Hide file tree
Showing 25 changed files with 525 additions and 1,030 deletions.
21 changes: 8 additions & 13 deletions cue/testdata/basicrewrite/018_self-reference_cycles.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ Disjuncts: 7
-- out/evalalpha --
(struct){
a: (_|_){
// [incomplete] b: non-concrete value _ in operand to +:
// [cycle] cycle error:
// ./in.cue:2:4
// ./in.cue:1:4
}
b: (_|_){
// [incomplete] b: non-concrete value _ in operand to +:
// [cycle] cycle error:
// ./in.cue:2:4
// ./in.cue:1:4
}
c: (#list){
0: (_){ _ }
Expand All @@ -52,23 +50,20 @@ Disjuncts: 7
diff old new
--- old
+++ new
@@ -1,10 +1,12 @@
@@ -1,11 +1,11 @@
(struct){
a: (_|_){
- // [cycle] cycle error:
+ // [incomplete] b: non-concrete value _ in operand to +:
// [cycle] cycle error:
- // ./in.cue:1:4
+ // ./in.cue:2:4
// ./in.cue:1:4
}
b: (_|_){
- // [cycle] cycle error:
+ // [incomplete] b: non-concrete value _ in operand to +:
// [cycle] cycle error:
- // ./in.cue:1:4
+ // ./in.cue:2:4
// ./in.cue:1:4
}
c: (#list){
-- diff/explanation --
More useful error messages.
0: (_){ _ }
-- out/eval --
(struct){
a: (_|_){
Expand Down
176 changes: 28 additions & 148 deletions cue/testdata/benchmarks/issue3517.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -74,35 +74,17 @@ Result:
// [eval]
#TimeSpan: (#struct){
start: (_|_){
// [incomplete] #TimeSpan.start: non-concrete value end for bound <=:
// ./main.cue:12:11
// #TimeSpan.start: non-concrete value float in operand to -:
// ./main.cue:8:12
// ./main.cue:6:12
// ./main.cue:10:12
// #TimeSpan.duration: non-concrete value float in operand to -:
// [cycle] cycle error:
// ./main.cue:9:12
// ./main.cue:6:12
// cycle error:
// ./main.cue:10:12
}
duration: (_|_){
// [incomplete] #TimeSpan.start: non-concrete value end for bound <=:
// ./main.cue:12:11
// #TimeSpan.duration: non-concrete value float in operand to -:
// [cycle] cycle error:
// ./main.cue:9:12
// ./main.cue:6:12
// ./main.cue:10:12
}
end: (_|_){
// [incomplete] #TimeSpan.start: non-concrete value end for bound <=:
// ./main.cue:12:11
// #TimeSpan.start: non-concrete value float in operand to -:
// ./main.cue:8:12
// ./main.cue:6:12
// ./main.cue:10:12
// #TimeSpan.duration: non-concrete value float in operand to -:
// ./main.cue:9:12
// ./main.cue:6:12
// [cycle] cycle error:
// ./main.cue:10:12
}
}
Expand All @@ -122,57 +104,27 @@ Result:
action: (string){ "Task 1" }
timeSpan: (#struct){
duration: (_|_){
// [incomplete] #T1.timeSpan.start: non-concrete value end for bound <=:
// ./main.cue:12:11
// #T1.timeSpan.start: non-concrete value float in operand to -:
// ./main.cue:8:12
// ./main.cue:6:12
// ./main.cue:10:12
// [cycle] cycle error
}
start: (_|_){
// [incomplete] #T1.timeSpan.start: non-concrete value end for bound <=:
// ./main.cue:12:11
// #T1.timeSpan.start: non-concrete value float in operand to -:
// ./main.cue:8:12
// ./main.cue:6:12
// ./main.cue:10:12
// [cycle] cycle error
}
end: (_|_){
// [incomplete] #T1.timeSpan.start: non-concrete value end for bound <=:
// ./main.cue:12:11
// #T1.timeSpan.start: non-concrete value float in operand to -:
// ./main.cue:8:12
// ./main.cue:6:12
// ./main.cue:10:12
// [cycle] cycle error
}
}
}
#T2: (#struct){
action: (string){ "Task 2" }
timeSpan: (#struct){
duration: (_|_){
// [incomplete] #T2.timeSpan.start: non-concrete value end for bound <=:
// ./main.cue:12:11
// #T2.timeSpan.start: non-concrete value float in operand to -:
// ./main.cue:8:12
// ./main.cue:6:12
// ./main.cue:10:12
// [cycle] cycle error
}
start: (_|_){
// [incomplete] #T2.timeSpan.start: non-concrete value end for bound <=:
// ./main.cue:12:11
// #T2.timeSpan.start: non-concrete value float in operand to -:
// ./main.cue:8:12
// ./main.cue:6:12
// ./main.cue:10:12
// [cycle] cycle error
}
end: (_|_){
// [incomplete] #T2.timeSpan.start: non-concrete value end for bound <=:
// ./main.cue:12:11
// #T2.timeSpan.start: non-concrete value float in operand to -:
// ./main.cue:8:12
// ./main.cue:6:12
// ./main.cue:10:12
// [cycle] cycle error
}
}
}
Expand All @@ -196,9 +148,7 @@ Result:
// ./main.cue:50:19
}
start: (_|_){
// [eval] ts.#tasks.t2.timeSpan.end: conflicting values 119 and float (mismatched types int and float):
// ./main.cue:6:12
// ./main.cue:50:19
// [cycle] cycle error
}
}
action: (string){ "Task 1" }
Expand Down Expand Up @@ -265,45 +215,19 @@ diff old new
./main.cue:50:19

Result:
@@ -11,32 +8,41 @@
@@ -11,7 +8,10 @@
// [eval]
#TimeSpan: (#struct){
start: (_|_){
- // [cycle] cycle error
+ // [incomplete] #TimeSpan.start: non-concrete value end for bound <=:
+ // ./main.cue:12:11
+ // #TimeSpan.start: non-concrete value float in operand to -:
+ // ./main.cue:8:12
+ // ./main.cue:6:12
+ // ./main.cue:10:12
+ // #TimeSpan.duration: non-concrete value float in operand to -:
+ // [cycle] cycle error:
+ // ./main.cue:9:12
+ // ./main.cue:6:12
+ // cycle error:
+ // ./main.cue:10:12
}
duration: (_|_){
- // [cycle] cycle error:
- // ./main.cue:9:12
+ // [incomplete] #TimeSpan.start: non-concrete value end for bound <=:
+ // ./main.cue:12:11
+ // #TimeSpan.duration: non-concrete value float in operand to -:
+ // ./main.cue:9:12
+ // ./main.cue:6:12
+ // ./main.cue:10:12
}
end: (_|_){
- // [cycle] cycle error:
+ // [incomplete] #TimeSpan.start: non-concrete value end for bound <=:
+ // ./main.cue:12:11
+ // #TimeSpan.start: non-concrete value float in operand to -:
+ // ./main.cue:8:12
+ // ./main.cue:6:12
+ // ./main.cue:10:12
+ // #TimeSpan.duration: non-concrete value float in operand to -:
+ // ./main.cue:9:12
+ // ./main.cue:6:12
// ./main.cue:10:12
}
// [cycle] cycle error:
@@ -24,19 +24,7 @@
}
#Task: (#struct){
action: (string){ string }
Expand All @@ -324,7 +248,7 @@ diff old new
}
#TaskSet: (#struct){
action: (string){ string }
@@ -44,32 +50,34 @@
@@ -44,29 +32,16 @@
}
tasks: (#list){
}
Expand Down Expand Up @@ -352,36 +276,15 @@ diff old new
- duration: (_|_){
- // [cycle] cycle error:
- // ./main.cue:9:12
- }
- end: (_|_){
- // [cycle] cycle error
+ duration: (_|_){
+ // [incomplete] #T1.timeSpan.start: non-concrete value end for bound <=:
+ // ./main.cue:12:11
+ // #T1.timeSpan.start: non-concrete value float in operand to -:
+ // ./main.cue:8:12
+ // ./main.cue:6:12
+ // ./main.cue:10:12
+ // [cycle] cycle error
+ }
+ start: (_|_){
+ // [incomplete] #T1.timeSpan.start: non-concrete value end for bound <=:
+ // ./main.cue:12:11
+ // #T1.timeSpan.start: non-concrete value float in operand to -:
+ // ./main.cue:8:12
+ // ./main.cue:6:12
+ // ./main.cue:10:12
+ }
+ end: (_|_){
+ // [incomplete] #T1.timeSpan.start: non-concrete value end for bound <=:
+ // ./main.cue:12:11
+ // #T1.timeSpan.start: non-concrete value float in operand to -:
+ // ./main.cue:8:12
+ // ./main.cue:6:12
+ // ./main.cue:10:12
+ // [cycle] cycle error
}
}
}
@@ -76,15 +84,29 @@
end: (_|_){
// [cycle] cycle error
@@ -76,12 +51,11 @@
#T2: (#struct){
action: (string){ "Task 2" }
timeSpan: (#struct){
Expand All @@ -391,36 +294,15 @@ diff old new
- duration: (_|_){
- // [cycle] cycle error:
- // ./main.cue:9:12
- }
- end: (_|_){
- // [cycle] cycle error
+ duration: (_|_){
+ // [incomplete] #T2.timeSpan.start: non-concrete value end for bound <=:
+ // ./main.cue:12:11
+ // #T2.timeSpan.start: non-concrete value float in operand to -:
+ // ./main.cue:8:12
+ // ./main.cue:6:12
+ // ./main.cue:10:12
+ // [cycle] cycle error
+ }
+ start: (_|_){
+ // [incomplete] #T2.timeSpan.start: non-concrete value end for bound <=:
+ // ./main.cue:12:11
+ // #T2.timeSpan.start: non-concrete value float in operand to -:
+ // ./main.cue:8:12
+ // ./main.cue:6:12
+ // ./main.cue:10:12
+ }
+ end: (_|_){
+ // [incomplete] #T2.timeSpan.start: non-concrete value end for bound <=:
+ // ./main.cue:12:11
+ // #T2.timeSpan.start: non-concrete value float in operand to -:
+ // ./main.cue:8:12
+ // ./main.cue:6:12
+ // ./main.cue:10:12
+ // [cycle] cycle error
}
}
}
@@ -93,66 +115,73 @@
end: (_|_){
// [cycle] cycle error
@@ -93,66 +67,71 @@
action: (string){ "Task 1 and Task 2" }
#tasks: (_|_){
// [eval]
Expand All @@ -440,9 +322,7 @@ diff old new
+ // ./main.cue:50:19
+ }
+ start: (_|_){
+ // [eval] ts.#tasks.t2.timeSpan.end: conflicting values 119 and float (mismatched types int and float):
+ // ./main.cue:6:12
+ // ./main.cue:50:19
+ // [cycle] cycle error
+ }
+ }
action: (string){ "Task 1" }
Expand Down
10 changes: 0 additions & 10 deletions cue/testdata/benchmarks/sort.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,6 @@ out: list.Sort(list.FlattenN(_c, 4), {x: _, y: _, less: x.name < y.name})
less: (〈0;x〉.name < 〈0;y〉.name)
})
}
-- out/eval/stats --
Leaks: 0
Freed: 7529
Reused: 7523
Allocs: 6
Retain: 1

Unifications: 7529
Conjuncts: 12154
Disjuncts: 7530
-- out/evalalpha --
(struct){
_a: (#list){
Expand Down
Loading

0 comments on commit 7827aa8

Please sign in to comment.