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

evalv3: "conflicting values" error regression when a disjunction involves missing fields #3600

Closed
mvdan opened this issue Nov 27, 2024 · 3 comments
Labels
evaluator evalv3 issues affecting only the evaluator version 3

Comments

@mvdan
Copy link
Member

mvdan commented Nov 27, 2024

# With the old evaluator.
env CUE_EXPERIMENT=evalv3=0
exec cue vet -c=false

# With the new evaluator.
env CUE_EXPERIMENT=evalv3=1
exec cue vet -c=false

-- input.cue --
package p

#PatchOp: {
	op:    "replace"
	value: _
} | {
	op:   "remove"
} | {
	op:   "copy"
	from: string
}
#Patch: {
	input:  #PatchOp
	output: input
}

params: {}
patched: (#Patch & {
	input: {
		op:    "replace"
		value: "\(params.missing)"
	}
}).output

As of c29fd02:

# With the old evaluator. (0.010s)
> env CUE_EXPERIMENT=evalv3=0
> exec cue vet -c=false
# With the new evaluator. (0.028s)
> env CUE_EXPERIMENT=evalv3=1
> exec cue vet -c=false
[stderr]
output.op: conflicting values "copy" and "replace":
    ./input.cue:9:8
    ./input.cue:20:10
output.op: conflicting values "remove" and "replace":
    ./input.cue:7:8
    ./input.cue:20:10

The config is incomplete, as params.missing is not a field that exists, but still - I think v2 was correct in not reporting the "conflicting values" errors which do not matter here.

@mvdan
Copy link
Member Author

mvdan commented Nov 28, 2024

Slightly smaller testscript:

# With the old evaluator.
env CUE_EXPERIMENT=evalv3=0
exec cue vet -c=false

# With the new evaluator.
env CUE_EXPERIMENT=evalv3=1
exec cue vet -c=false

-- input.cue --
package p

#PatchOp: {
	op:    "replace"
	value: _
} | {
	op:   "remove"
} | {
	op:   "copy"
	from: string
}

params: {}
patched: #PatchOp & {
	op:    "replace"
	value: "\(params.missing)"
}

@mvdan mvdan added the evalv3 issues affecting only the evaluator version 3 label Dec 10, 2024
@mpvl
Copy link
Member

mpvl commented Dec 23, 2024

This issue is fixed by https://cuelang.org/cl/1206284.

However, the above code still outputs a somewhat misleading value for cue eval, where the value of patched.value is input. Similarly, for cue def this suffers from the let at wrong scope issue.

I'll keep this open to address these issue.

cueckoo pushed a commit that referenced this issue Dec 23, 2024
V3 used CombineErrors to combine errors from
the various disjuncts into a single Bottom value.
CombineErrors takes the code of the worst error.
However, for disjunctions we actually want the
code of the least worst error.

This change makes V3 use the same error creation
logic as V2, using some wrapper code. As a result,
V3 now also produces the "empty disjunction"
messages which were previously missing.

Note that now we have the "empty disjunction"
messages, we can see that the reported count
of failed disjunctions is somewhat off in some
tests. diff/todos are added where appropriate.

Issue #3600
Fixes #3581

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I0ca92c190976d51fffddac6010e11a88505e876b
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206284
Reviewed-by: Daniel Martí <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
@mpvl
Copy link
Member

mpvl commented Jan 17, 2025

I can no longer reproduce the aforementioned issues. They do occur in another Issue, so at least they are still reproducible elsewhere.

Note that the original issue was already fixed.

@mpvl mpvl closed this as completed Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
evaluator evalv3 issues affecting only the evaluator version 3
Projects
None yet
Development

No branches or pull requests

2 participants