Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
verdverm opened this issue Oct 22, 2021 · 3 comments
Labels
disjunctions NeedsFix ordering Bugs where the evaluator behaves differently depending on the order of fields, files, etc.

Comments

@verdverm
Copy link

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
@verdverm verdverm added NeedsInvestigation Triage Requires triage/attention labels Oct 22, 2021
@mpvl mpvl added NeedsFix and removed Triage Requires triage/attention labels Oct 26, 2021
@mpvl mpvl added this to the v0.4.x milestone Oct 26, 2021
@mpvl
Copy link
Member

mpvl commented Oct 26, 2021

There are clearly some bugs here.

@mpvl
Copy link
Member

mpvl commented Nov 15, 2021

Further investigation:

According to the spec, this is what it should be:

a: [{
	x: 1|2 // rule M1 and M3
	y: 1|2 // rule M1 and M3
}, {
	x: 1|2 // rule M1 and M3
	y: 1|2 // rule M1 and M3
}, {
	x: 1|*2 // rule D1
	y: *1|2 // rule D1
}]

b: [{
	x: *1 | 2 // rule M1, M3, D1
	y: *1 | 2 // rule M1, M3, D1
}, {
	x: *1 | 2 // rule M1, M3, D1
	y: *1 | 2 // rule M1, M3, D1
}, {
	x: 1 | *2 // rule D1
	y: *1 | 2 // rule D1
}]

c: [{
	x: *1|2 // rule D2
	y: *1|2
	z: *1|2
}]

So the following are erroneous: a.0.x, a.0.y, b.0.y, c.0.y.

@mpvl
Copy link
Member

mpvl commented Nov 15, 2021

Bug was introduced with a spec change regarding defaults at 87d43b7.

The old semantics coincidentally yielded the same result in many of these cases, but the new implementation doesn't implement the new (much simpler) semantics correctly, evidentally.

@myitcv myitcv changed the title Inconsistent default value resolution depending on ordering and marks internal/core: inconsistent default value resolution depending on ordering and marks Nov 19, 2021
@myitcv myitcv modified the milestones: v0.4.x, v0.5.x Nov 19, 2021
@mpvl mpvl modified the milestones: v0.5.x, v0.6.0 required fields Jan 30, 2023
@myitcv myitcv added the zGarden label Jun 13, 2023
@mvdan mvdan added the ordering Bugs where the evaluator behaves differently depending on the order of fields, files, etc. label Sep 4, 2023
@mvdan mvdan removed the zGarden label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disjunctions NeedsFix ordering Bugs where the evaluator behaves differently depending on the order of fields, files, etc.
Projects
None yet
Development

No branches or pull requests

4 participants