-
Notifications
You must be signed in to change notification settings - Fork 311
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 <[email protected]>
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 <[email protected]>
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.
Signed-off-by: Graham Dennis <[email protected]>
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.
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