blob: 6e30441d7614425e4ed2e4cbf0f39211f077a832 [file] [log] [blame]
-- in.cue --
a: *1 | int
aa: *1 | *2 | int
b: {
name: "int"
val: int
} | {
name: "str"
val: string
}
d: b & { val: 3 }
c: b & { name: "int", val: 3 }
e: b & { val: "foo" }
f: b & { name: "str", val: 3 }
// Disjunct elimination based on type.
e1: {
a: null | {bar: 2}
b: (a&{}).bar
}
d1: {
a: (null | {c: 1}) & {}
b: {} & (null | {c: 1})
}
d2: {
a: ([...] | {c: 1}) & {}
b: {} & ([...] | {c: 1})
}
d3: {
a: (string | {c: 1}) & {}
b: {} & (string | {c: 1})
}
d4: {
a: (string | {c: 1}) & {}
b: {} & (string | {c: 1})
}
d5: {
a: (number | {c: 1}) & {}
b: {} & (number | {c: 1})
}
d6: {
a: (int | {c: 1}) & {}
b: {} & (int | {c: 1})
}
d100: {
// Should we allow a selector to imply a struct or list? Would be convenient.
// This would be a spec change. Disallow for now.
i: null | {bar: 2}
j: i.bar
}
-- out/eval --
Errors:
f.val: conflicting values 3 and string (mismatched types int and string)
Result:
(_|_){
// [eval]
a: (int){ |(*(int){ 1 }, (int){ int }) }
aa: (int){ |(*(int){ 1 }, *(int){ 2 }, (int){ int }) }
b: (struct){ |((struct){
name: (string){ "int" }
val: (int){ int }
}, (struct){
name: (string){ "str" }
val: (string){ string }
}) }
d: (struct){
val: (int){ 3 }
name: (string){ "int" }
}
c: (struct){
name: (string){ "int" }
val: (int){ 3 }
}
e: (struct){
val: (string){ "foo" }
name: (string){ "str" }
}
f: (_|_){
// [eval]
name: (string){ "str" }
val: (_|_){
// [eval] f.val: conflicting values 3 and string (mismatched types int and string)
}
}
e1: (struct){
a: ((null|struct)){ |((null){ null }, (struct){
bar: (int){ 2 }
}) }
b: (int){ 2 }
}
d1: (struct){
a: (struct){
c: (int){ 1 }
}
b: (struct){
c: (int){ 1 }
}
}
d2: (struct){
a: (struct){
c: (int){ 1 }
}
b: (struct){
c: (int){ 1 }
}
}
d3: (struct){
a: (struct){
c: (int){ 1 }
}
b: (struct){
c: (int){ 1 }
}
}
d4: (struct){
a: (struct){
c: (int){ 1 }
}
b: (struct){
c: (int){ 1 }
}
}
d5: (struct){
a: (struct){
c: (int){ 1 }
}
b: (struct){
c: (int){ 1 }
}
}
d6: (struct){
a: (struct){
c: (int){ 1 }
}
b: (struct){
c: (int){ 1 }
}
}
d100: (struct){
i: ((null|struct)){ |((null){ null }, (struct){
bar: (int){ 2 }
}) }
j: (_|_){
// [incomplete] d100.j: unresolved disjunction null | {bar:2} (type (null|struct)):
// ./in.cue:58:6
}
}
}
-- out/compile --
--- in.cue
{
a: (*1|int)
aa: (*1|*2|int)
b: ({
name: "int"
val: int
}|{
name: "str"
val: string
})
d: (〈0;b & {
val: 3
})
c: (〈0;b & {
name: "int"
val: 3
})
e: (〈0;b & {
val: "foo"
})
f: (〈0;b & {
name: "str"
val: 3
})
e1: {
a: (null|{
bar: 2
})
b: (〈0;a & {}).bar
}
d1: {
a: ((null|{
c: 1
}) & {})
b: ({} & (null|{
c: 1
}))
}
d2: {
a: (([
...,
]|{
c: 1
}) & {})
b: ({} & ([
...,
]|{
c: 1
}))
}
d3: {
a: ((string|{
c: 1
}) & {})
b: ({} & (string|{
c: 1
}))
}
d4: {
a: ((string|{
c: 1
}) & {})
b: ({} & (string|{
c: 1
}))
}
d5: {
a: ((number|{
c: 1
}) & {})
b: ({} & (number|{
c: 1
}))
}
d6: {
a: ((int|{
c: 1
}) & {})
b: ({} & (int|{
c: 1
}))
}
d100: {
i: (null|{
bar: 2
})
j: 0;i〉.bar
}
}