Skip to content

Commit

Permalink
internal/core/adt: use ? in debug output
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I85e7bdbd4f3a74f1f2601a3b1aaa3d3915141331
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/551105
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
mpvl committed Mar 17, 2023
1 parent 19bfdb9 commit 5fe040a
Show file tree
Hide file tree
Showing 19 changed files with 152 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/cue/cmd/testdata/script/vet_yaml.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
cmp stderr expect-stderr

-- expect-stderr --
phrases: invalid value "phrases:\n # A quote from Mark Twain.\n quote1:\n lang: en\n attribution: Mark Twain\n\n # A Norwegian proverb.\n proverb:\n lang: no\n text: Stemmen som sier at du ikke klarer det, lyver." (does not satisfy encoding/yaml.Validate({phrases:{},#Phrase:{lang:=~"^[a-zA-Z0-9-_]{2,}$" | false,text:!="",},#LanguageTag:=~"^[a-zA-Z0-9-_]{2,}$" | false})): error in call to encoding/yaml.Validate: incomplete value !="":
phrases: invalid value "phrases:\n # A quote from Mark Twain.\n quote1:\n lang: en\n attribution: Mark Twain\n\n # A Norwegian proverb.\n proverb:\n lang: no\n text: Stemmen som sier at du ikke klarer det, lyver." (does not satisfy encoding/yaml.Validate({phrases:{},#Phrase:{lang:=~"^[a-zA-Z0-9-_]{2,}$" | false,text:!="",attribution?:!=""},#LanguageTag:=~"^[a-zA-Z0-9-_]{2,}$" | false})): error in call to encoding/yaml.Validate: incomplete value !="":
./yaml.cue:19:10
./yaml.cue:11:17
./yaml.cue:21:10
Expand Down
13 changes: 13 additions & 0 deletions cue/testdata/cycle/compbottom2.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ Disjuncts: 205
foo: (struct){
a: (int){ 1 }
}
raises?: (struct){
}
}
b: (struct){
foo: (struct){
Expand All @@ -412,6 +414,8 @@ Disjuncts: 205
ret: (struct){
a: (int){ 1 }
}
raises?: (struct){
}
}
}
cycleFail: (struct){
Expand All @@ -422,6 +426,8 @@ Disjuncts: 205
ret: (struct){
a: (int){ 1 }
}
raises?: (struct){
}
}
p2: (_|_){
// [cycle] sameStruct.cycleFail.t1.p2: circular dependency in evaluation of conditionals: raises changed after evaluation:
Expand Down Expand Up @@ -475,8 +481,15 @@ Disjuncts: 205
}
defCloseSuccess: (struct){
#Example: (#struct){
raises?: (#struct){
runtime?: (string){ string }
}
ret?: (_){ _ }
}
expr: (#struct){
raises?: (#struct){
runtime?: (string){ string }
}
ret: (int){ 2 }
}
}
Expand Down
6 changes: 6 additions & 0 deletions cue/testdata/cycle/structural.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -1315,11 +1315,17 @@ Result:
listOptOK: (struct){
list: (struct){
head: (int){ int }
tail?: (_|_){
// [structural cycle] listOptOK.list.tail: structural cycle
}
}
a: (struct){
head: (int){ 3 }
tail: (struct){
head: (int){ 2 }
tail?: (_|_){
// [structural cycle] listOptOK.a.tail.tail: structural cycle
}
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions cue/testdata/definitions/036_closing_with_failed_optional.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,40 @@ Disjuncts: 29
(struct){
#k1: (#struct){
a: (int){ int }
b?: (int){ int }
}
#k2: (#struct){
a: (int){ int }
b?: (int){ int }
}
o1: (struct){
a?: (_|_){
// [eval] o1.a: conflicting values 4 and 3:
// ./in.cue:5:10
// ./in.cue:5:20
}
}
#o2: (#struct){
a?: (_|_){
// [eval] #o2.a: conflicting values 4 and 3:
// ./in.cue:8:11
// ./in.cue:8:21
}
}
#d1: (#struct){ |((#struct){
a?: (int){ 2 }
b: (int){ 4 }
}, (#struct){
a?: (int){ 3 }
c: (int){ 5 }
}) }
v1: (#struct){
a?: (_|_){
// [eval] v1.a: conflicting values 2 and 3:
// ./in.cue:10:11
// ./in.cue:12:5
// ./in.cue:12:16
}
b: (int){ 4 }
}
#A: (#struct){
Expand Down
5 changes: 5 additions & 0 deletions cue/testdata/definitions/issue483.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ Disjuncts: 17
}
}
#Type: (#struct){
alpha?: (#struct){
bravo?: (#struct){
charlie?: (bool){ bool }
}
}
}
#Root: (#struct){
}
Expand Down
60 changes: 60 additions & 0 deletions cue/testdata/disjunctions/elimination.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -896,9 +896,13 @@ Result:
}
issue1838: (struct){
t1: (struct){
p?: (#list){
}
a: (null){ null }
}
t2: (struct){
p?: (#list){
}
a: (null){ null }
}
}
Expand Down Expand Up @@ -1057,9 +1061,17 @@ Result:
spec: (#struct){ |(*(#struct){
minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
minBar?: (null){ null }
maxBar?: (null){ null }
hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
fuga?: (null){ null }
}, (#struct){
minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
minBar?: (null){ null }
maxBar?: (null){ null }
hoge?: (null){ null }
fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
}) }
_X: (#struct){
spec: (#struct){ |(*(#struct){
Expand Down Expand Up @@ -1157,6 +1169,8 @@ Result:
// [eval] issue2209.full.Bar.resource.spec.maxBar: undefined field: max:
// ./issue2209full.cue:78:25
}
hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
}
_X: (#struct){
spec: (#struct){ |(*(#struct){
Expand Down Expand Up @@ -1191,9 +1205,17 @@ Result:
spec: (#struct){ |(*(#struct){
minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
minBar?: (null){ null }
maxBar?: (null){ null }
hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
fuga?: (null){ null }
}, (#struct){
minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
minBar?: (null){ null }
maxBar?: (null){ null }
hoge?: (null){ null }
fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
}) }
_X: (#struct){
spec: (#struct){ |(*(#struct){
Expand Down Expand Up @@ -1237,35 +1259,73 @@ Result:
spec: (#struct){ |(*(#struct){
minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
minBar?: (null){ null }
maxBar?: (null){ null }
hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
fuga?: (null){ null }
}, *(#struct){
minFoo?: (null){ null }
maxFoo?: (null){ null }
minBar: (int){ |(*(int){ 30 }, (int){ int }) }
maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
fuga?: (null){ null }
}, (#struct){
minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
minBar?: (null){ null }
maxBar?: (null){ null }
hoge?: (null){ null }
fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
}, (#struct){
minFoo?: (null){ null }
maxFoo?: (null){ null }
minBar: (int){ |(*(int){ 30 }, (int){ int }) }
maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
hoge?: (null){ null }
fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
}) }
_X: (_){ _ }
}
#Constrained: (#struct){
spec: (#struct){ |(*(#struct){
minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
minBar?: (null){ null }
maxBar?: (null){ null }
hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
fuga?: (null){ null }
}, *(#struct){
minFoo?: (null){ null }
maxFoo?: (null){ null }
minBar: (int){ |(*(int){ 30 }, (int){ int }) }
maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
fuga?: (null){ null }
}, (#struct){
minFoo: (int){ |(*(int){ 10 }, (int){ int }) }
maxFoo: (int){ |(*(int){ 20 }, (int){ int }) }
minBar?: (null){ null }
maxBar?: (null){ null }
hoge?: (null){ null }
fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
}, (#struct){
minFoo?: (null){ null }
maxFoo?: (null){ null }
minBar: (int){ |(*(int){ 30 }, (int){ int }) }
maxBar: (int){ |(*(int){ 40 }, (int){ int }) }
hoge?: (null){ null }
fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
}) }
}
#Base: (#struct){
spec: (#struct){
minFoo?: ((null|int)){ |((null){ null }, (int){ int }) }
maxFoo?: ((null|int)){ |((null){ null }, (int){ int }) }
minBar?: ((null|int)){ |((null){ null }, (int){ int }) }
maxBar?: ((null|int)){ |((null){ null }, (int){ int }) }
hoge?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
fuga?: ((null|bool)){ |((null){ null }, (bool){ bool }) }
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions cue/testdata/disjunctions/errors.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Result:
result: (list){
}
}, (#struct){
result?: (list){
}
error: (string){ string }
}) }
}
Expand Down
9 changes: 9 additions & 0 deletions cue/testdata/eval/closed_disjunction.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,16 @@ Result:
(_|_){
// [eval]
#A: (#struct){ |(*(#struct){
b?: (int){ int }
}, (#struct){
b?: (int){ int }
c?: (int){ int }
}, (#struct){
b?: (int){ int }
d?: (int){ int }
}, (#struct){
b?: (int){ int }
e?: (int){ int }
}) }
a: (#struct){
b: (int){ 3 }
Expand All @@ -65,6 +72,7 @@ Result:
// ./in.cue:3:8
// ./in.cue:11:4
// ./in.cue:13:2
b?: (int){ int }
c: (_|_){
// [eval] b.c: field not allowed:
// ./in.cue:1:5
Expand All @@ -81,6 +89,7 @@ Result:
// ./in.cue:11:4
// ./in.cue:13:2
}
e?: (int){ int }
}
}
-- out/compile --
Expand Down
14 changes: 14 additions & 0 deletions cue/testdata/eval/issue2146.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Disjuncts: 206
(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: (_|_){
Expand All @@ -65,6 +69,8 @@ Disjuncts: 206
0: (int){ 1 }
}
}, (#struct){
x?: (int){ int }
y?: (int){ int }
let list#1 = (#list){
0: (_|_){
// [incomplete] p1.#A.list.0: cannot reference optional field: x:
Expand All @@ -80,6 +86,7 @@ Disjuncts: 206
}) }
a: (#struct){
x: (int){ 3 }
y?: (int){ int }
let list#1 = (#list){
0: (int){ 3 }
1: (_|_){
Expand All @@ -93,6 +100,7 @@ Disjuncts: 206
}
b: (#struct){
x: (int){ 3 }
y?: (int){ int }
let list#1multi = [
〈1;x〉,
〈1;y〉,
Expand All @@ -104,6 +112,10 @@ Disjuncts: 206
}
p2: (struct){
#A: (#struct){ |(*(#struct){
x?: (_|_){
// [user] explicit error (_|_ literal) in source:
// ./in.cue:27:8
}
y: (int){ 1 }
let list#2 = (#list){
0: (_|_){
Expand All @@ -116,6 +128,8 @@ Disjuncts: 206
0: (int){ 1 }
}
}, (#struct){
x?: (int){ int }
y?: (int){ int }
let list#2 = (#list){
0: (_|_){
// [incomplete] p2.#A.list.0: cannot reference optional field: x:
Expand Down
4 changes: 4 additions & 0 deletions cue/testdata/eval/issue353.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ Disjuncts: 15
(struct){
e: (#struct){ |((#struct){
a: (string){ "hello" }
value?: (string){ string }
}, (#struct){
a: (string){ "hello" }
externalValue?: (string){ string }
}) }
#Example: (#struct){ |((#struct){
a: (string){ string }
value?: (string){ string }
}, (#struct){
a: (string){ string }
externalValue?: (string){ string }
}) }
}
-- out/compile --
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,20 @@ Disjuncts: 14
(struct){
d: (struct){ |((struct){
a: (int){ 1 }
b?: (int){ 3 }
}, (struct){
a: (int){ 2 }
}) }
c: (struct){ |((struct){
b?: (_|_){
// [eval] c.b: conflicting values 3 and 4:
// ./in.cue:1:15
// ./in.cue:4:4
// ./in.cue:4:13
}
a: (int){ 1 }
}, (struct){
b?: (int){ 4 }
a: (int){ 2 }
}) }
}
Loading

0 comments on commit 5fe040a

Please sign in to comment.