Skip to content

Commit 478fc28

Browse files
committed
fix nil schema type not being deduced to whatever the other operand is
1 parent 0f66c33 commit 478fc28

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

typed/merge.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ func (w *mergingWalker) merge(prefixFn func() string) (errs ValidationErrors) {
8080

8181
alhs := deduceAtom(a, w.lhs)
8282
arhs := deduceAtom(a, w.rhs)
83-
if alhs.Equals(&arhs) {
83+
84+
// deduceAtom does not fix the type for nil values
85+
// nil is a wildcard and will accept whatever form the other operand takes
86+
if w.rhs == nil {
87+
errs = append(errs, handleAtom(alhs, w.typeRef, w)...)
88+
} else if w.lhs == nil || alhs.Equals(&arhs) {
8489
errs = append(errs, handleAtom(arhs, w.typeRef, w)...)
8590
} else {
8691
w2 := *w

0 commit comments

Comments
 (0)