-
Notifications
You must be signed in to change notification settings - Fork 327
fix: Improve error message returned by Subsume #3862
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
base: master
Are you sure you want to change the base?
fix: Improve error message returned by Subsume #3862
Conversation
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 |
Signed-off-by: Graham Dennis <graham.dennis@gmail.com>
023fd6d
to
0acd636
Compare
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:
After the second commit, the updated error message is:
edit: I fixed a bug in my change with the error messages generated by the v3 evaluator vs the v2 evaluator. |
3262af0
to
63e5fcd
Compare
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: cue-lang#3861 Signed-off-by: Graham Dennis <graham.dennis@gmail.com>
63e5fcd
to
d50ef8c
Compare
internal/core/subsume/vertex.go
Outdated
s.missing = f | ||
s.gt = a | ||
s.lt = y | ||
if b == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct. I have removed this and also set the s.missing
et al fields inside the block above.
internal/core/subsume/vertex.go
Outdated
s.missing = f | ||
s.gt = a | ||
s.lt = y | ||
if b == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unclear how this condition can ever be true: if b == nil, b will be set to a non-nil value in the block above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct. I have removed this and also set the s.missing
et al fields inside the block above.
@@ -0,0 +1,4837 @@ | |||
-- out/TestValues/0/__⊑__/v2 -- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any test inputs here. Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is driven by the existing test cases in https://github.com/cue-lang/cue/pull/3862/files#diff-5c570d819733910b5664134701d7cb95c9efbf2261b72b32b3ff5339ef18bb27L52-R77.
What I wanted to do was re-use all of those test cases and then use the txtar tooling for rendering the error messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically want to keep the tests together. So either put input an output in txtar, or do everything in a table.
Also, we prefer not to change the general design of test. It is a lot of code to review! Finally, we want to separate out semantic from structural changes. So if we want to change the generic test structure, this should be a separate CL.
Signed-off-by: Graham Dennis <graham.dennis@gmail.com>
26551a3
to
d27ca9c
Compare
s.lt = y | ||
s.lt = b | ||
|
||
s.errf("%v%s does not subsume %v%s", a, a.ArcType.Suffix(), b, b.ArcType.Suffix()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been modified to improve the error for situations like: {foo:_1}_⊑_{foo?:_1}
. Currently the error is:
1 does not subsume 1
But there will now be a new error of
1 does not subsume 1?
This may be considered an abuse of syntax, but it's a starting point for discussion.
@@ -0,0 +1,4837 @@ | |||
-- out/TestValues/0/__⊑__/v2 -- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is driven by the existing test cases in https://github.com/cue-lang/cue/pull/3862/files#diff-5c570d819733910b5664134701d7cb95c9efbf2261b72b32b3ff5339ef18bb27L52-R77.
What I wanted to do was re-use all of those test cases and then use the txtar tooling for rendering the error messages.
internal/core/subsume/vertex.go
Outdated
s.missing = f | ||
s.gt = a | ||
s.lt = y | ||
if b == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct. I have removed this and also set the s.missing
et al fields inside the block above.
internal/core/subsume/vertex.go
Outdated
s.missing = f | ||
s.gt = a | ||
s.lt = y | ||
if b == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct. I have removed this and also set the s.missing
et al fields inside the block above.
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? |
Thanks; we haven't forgotten about this. Please understand that we have a number of competing priorities at the moment, and a small team. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your updates and pardon the delay.
Firstly, this is quite a complex change. For anything but trivial changes we typically require moving over to Gerrit, for several reasons:
- all reviews documented in a single place,
- code review capabilities of GH are rather poor (for instance no fine-grained colored diffing), which makes it really hard to review,
- allow commenting on commit messages (for instance, headers do not follow our pattern).
I made some comments, but I suggest moving over to Gerrit henceforth.
@@ -0,0 +1,4837 @@ | |||
-- out/TestValues/0/__⊑__/v2 -- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically want to keep the tests together. So either put input an output in txtar, or do everything in a table.
Also, we prefer not to change the general design of test. It is a lot of code to review! Finally, we want to separate out semantic from structural changes. So if we want to change the generic test structure, this should be a separate CL.
s.errf("missing field %q", s.missing.SelectorString(c)) | ||
} else if b, ok := unifyValue(c, s.gt, s.lt).(*adt.Bottom); !ok { | ||
s.errf("value not an instance") | ||
s.errf("field %q not present in %v", s.missing.SelectorString(c), s.lt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit contains rephrasing of error messages, as well as logic changes. This makes it non-trivial to see which tests change because of what. These should be separated out in different CLs.
I've updated the testing setup for TestValues. It now tests for the particular error message. You can run
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. |
Previously when Subsume determined that a field did not subsume a previous field, the error returned was:
which is simply not true. Now a more useful error is returned in this scenario:
Resolves: #3861