Skip to content

Commit d50ef8c

Browse files
committed
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: cue-lang#3861 Signed-off-by: Graham Dennis <[email protected]>
1 parent 1856281 commit d50ef8c

File tree

3 files changed

+567
-231
lines changed

3 files changed

+567
-231
lines changed

Diff for: internal/core/subsume/subsume.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,9 @@ func (s *subsumer) getError() (err errors.Error) {
120120
if s.gt != nil && s.lt != nil {
121121
// src := binSrc(token.NoPos, opUnify, s.gt, s.lt)
122122
if s.missing != 0 {
123-
s.errf("missing field %q", s.missing.SelectorString(c))
124-
} else if b, ok := unifyValue(c, s.gt, s.lt).(*adt.Bottom); !ok {
125-
s.errf("value not an instance")
123+
s.errf("field %q not present in %v", s.missing.SelectorString(c), s.lt)
126124
} else {
127-
s.errs = errors.Append(s.errs, b.Err)
125+
s.errf("%v does not subsume %v", s.gt, s.lt)
128126
}
129127
}
130128
if s.errs == nil {

0 commit comments

Comments
 (0)