Skip to content

Commit

Permalink
internal/core/adt: add test for dropped field issue
Browse files Browse the repository at this point in the history
Currently, inline struct were reapproriated
by linking them into the destination struct
by setting the parent and label. However,
labels are used to look up fields. This resulted
in fields being dropped.

This test exposes that.

Issue #3601

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Icdfd3e9edac458ffb08a3759a2fd350e3cfdf363
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1205231
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Matthew Sackman <matthew@cue.works>
  • Loading branch information
mpvl committed Dec 7, 2024
1 parent dc1ef63 commit 4c7ee01
Showing 1 changed file with 91 additions and 9 deletions.
100 changes: 91 additions & 9 deletions cue/testdata/eval/sharing.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ issue3062: ok1: {
A: "a"
}

issue3601: ok1: {
Y: (X & __no_sharing).a
X: a: b: a.b
out: Y & __no_sharing
}

// Test debug facilities to turn of sharing.
debug: {
sharingOn: {
Expand All @@ -32,15 +38,15 @@ debug: {
}
}
-- out/eval/stats --
Leaks: 0
Freed: 33
Reused: 26
Allocs: 7
Retain: 7
Leaks: 2
Freed: 40
Reused: 33
Allocs: 9
Retain: 10

Unifications: 33
Conjuncts: 49
Disjuncts: 38
Unifications: 42
Conjuncts: 64
Disjuncts: 48
-- out/evalalpha --
(struct){
issue3062: (struct){
Expand All @@ -58,6 +64,24 @@ Disjuncts: 38
A: (string){ "a" }
}
}
issue3601: (struct){
ok1: (struct){
Y: (struct){
b: (_){ _ }
}
X: (struct){
a: (struct){
b: (_){ _ }
}
}
out: (struct){
b: (_|_){
// [incomplete] issue3601.ok1.out.b: undefined field: a:
// ./in.cue:12:11
}
}
}
}
debug: (struct){
sharingOn: (struct){
a: ~(debug.sharingOn.b)
Expand Down Expand Up @@ -108,12 +132,42 @@ diff old new
issue3062: (struct){
ok1: (struct){
#S: (string){ "a" }
@@ -19,42 +14,32 @@
@@ -19,12 +14,10 @@
A: (string){ "a" }
}
}
- issue3601: (_|_){
- // [eval]
- ok1: (_|_){
- // [eval]
- Y: (_|_){
- // [eval] no sharing
+ issue3601: (struct){
+ ok1: (struct){
+ Y: (struct){
+ b: (_){ _ }
}
X: (struct){
a: (struct){
@@ -31,47 +24,40 @@
b: (_){ _ }
}
}
- out: (_|_){
- // [eval] no sharing
- }
- }
- }
- debug: (_|_){
- // [eval]
+ out: (struct){
+ b: (_|_){
+ // [incomplete] issue3601.ok1.out.b: undefined field: a:
+ // ./in.cue:12:11
+ }
+ }
+ }
+ }
+ debug: (struct){
sharingOn: (struct){
- a: (struct){
Expand Down Expand Up @@ -194,6 +248,23 @@ Result:
A: (string){ "a" }
}
}
issue3601: (_|_){
// [eval]
ok1: (_|_){
// [eval]
Y: (_|_){
// [eval] no sharing
}
X: (struct){
a: (struct){
b: (_){ _ }
}
}
out: (_|_){
// [eval] no sharing
}
}
}
debug: (_|_){
// [eval]
sharingOn: (struct){
Expand Down Expand Up @@ -256,6 +327,17 @@ Result:
A: "a"
}
}
issue3601: {
ok1: {
Y: (〈0;X〉 & _|_(no sharing)).a
X: {
a: {
b: 〈1;a〉.b
}
}
out: (〈0;Y〉 & _|_(no sharing))
}
}
debug: {
sharingOn: {
a: 〈0;b〉
Expand Down

0 comments on commit 4c7ee01

Please sign in to comment.