Skip to content

internal/core: inconsistent default value resolution depending on ordering and marks #1317

@verdverm

Description

@verdverm

What version of CUE are you using (cue version)?

0.4.0

What did you do?

exec cue eval defaults.cue

-- defaults.cue --
a: [{
	x: *(1|2) | (1|*2)
	y: *(1|2) | (*1|2)
}, {
	x: (1|*2) | *(1|2)
	y: (*1|2) | *(1|2)
}, {
	x: (1|2) | (1|*2)
	y: (1|2) | (*1|2)
}]

b: [{
	x: *1 | (1|*2)
	y: *1 | (*1|2)
}, {
	x: (1|*2) | *1
	y: (*1|2) | *1
}, {
	x: 1 | (1|*2)
	y: 1 | (*1|2)
}]

c: [{
	x: (*1|2) | (*1|2)
	y: *(*1|2) | (*1|2)
	z: (*1|2) | *(*1|2)
}]

What did you see?

a: [{
    x: 1
    y: 2
}, {
    x: 1 | 2
    y: 1 | 2
}, {
    x: 2
    y: 1
}]
b: [{
    x: 1
    y: 1 | 2
}, {
    x: 1
    y: 1
}, {
    x: 2
    y: 1
}]
c: [{
    x: 1
    y: 1 | 2
    z: 1
}]

What did you expect to see?

Not exactly sure on the rules for how these defaults should be eliminated and what the results should be.

There are certain inconsistencies

  • a.0 I would expect x and y to be the other, i.e. match a.2
  • a.0 vs a.1 I would expect the same answer for both, as the L/R top-level have switch sides
  • same for b.0 vs b.1
  • c.0 I would expect all to be the same, 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixdefaultsdisjunctionsorderingBugs where the evaluator behaves differently depending on the order of fields, files, etc.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions