fix: Improve error message returned by Subsume
Previously when Subsume determined that a field did not subsume a previous field, the error returned was:
field x not present in <value>
which is simply not true. Now a more useful error is returned in this scenario:
31 | 33 does not subsume 32:
./schema.cue:2:25
./schema.cue:7:25
Resolves: #3861
Thanks for the patch. Could you add a test? Interestingly, we don't seem to have no tests for "field ... not present in ...". I would imagine this test would go somewhere under cue/testdata. Best if you add the test in a first commit, then the second commit can update the expected output and show the improvement in behavior.
Thanks for the patch. Could you add a test? Interestingly, we don't seem to have no tests for "field ... not present in ...". I would imagine this test would go somewhere under
cue/testdata. Best if you add the test in a first commit, then the second commit can update the expected output and show the improvement in behavior.
Thanks for the feedback. I've done this now.
The first commit contains just the new tests and contains some examples that I think have incorrect error messages:
-- out/TestValues/407/{foo:_1}_⊑_{foo?:_1} --
Errors:
field foo not present in {foo?:1}:
value:1:17
missing field "foo"
Result:
false
After the second commit, the updated error message is:
-- out/TestValues/407/{foo:_1}_⊑_{foo?:_1} --
Errors:
1 does not subsume 1:
value:1:10
value:1:24
1 does not subsume 1?:
value:1:10
value:1:24
Result:
false
edit: I fixed a bug in my change with the error messages generated by the v3 evaluator vs the v2 evaluator.
Ping on this PR?
We haven't forgotten about your PRs; we're just in a bit of a crunch for the v0.13 release with the new evaluator :) Please bear with us, and thank you for your patience!
ping @mvdan ? Any update here now that 0.13 is out?
ping @mvdan / @mpvl ?
Thanks; we haven't forgotten about this. Please understand that we have a number of competing priorities at the moment, and a small team.
I've updated the testing setup for TestValues. It now tests for the particular error message. You can run
CUE_UPDATE=1 go test ./internal/core/subsume
To update the generated error messages.
The reviews for this are still pending, though: https://review.gerrithub.io/c/cue-lang/cue/+/1219851/1
Friendly nudge @GrahamDennis, not sure if you saw Marcel's replies above. You can see https://github.com/cue-lang/cue/blob/master/CONTRIBUTING.md in terms of sending patches on Gerrit.