Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
internal/core/adt: fix null values equality
Browse files Browse the repository at this point in the history
`Value.Equals()` should return true when comparing two `null`
values.

Change-Id: I5dd8c0a84061374a354f15dc514d9a604ebb5f28
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9401
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
eonpatapon authored and mpvl committed Apr 28, 2021
1 parent b49cbbd commit 1ad66ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/core/adt/equality.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func equalTerminal(ctx *OpContext, v, w Value, flags Flag) bool {
}

switch x := v.(type) {
case *Num, *String, *Bool, *Bytes:
case *Num, *String, *Bool, *Bytes, *Null:
if b, ok := BinOp(ctx, EqualOp, v, w).(*Bool); ok {
return b.B
}
Expand Down
3 changes: 3 additions & 0 deletions internal/diff/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func TestDiff(t *testing.T) {
b: 2
s: 4
d: 1
e: null
}
`,
y: `
Expand All @@ -79,6 +80,7 @@ func TestDiff(t *testing.T) {
c: 3
s: 4
d: int
e: null
}
`,
kind: Modified,
Expand All @@ -90,6 +92,7 @@ func TestDiff(t *testing.T) {
s: 4
- d: 1
+ d: int
e: null
}
`,
}, {
Expand Down

0 comments on commit 1ad66ab

Please sign in to comment.