Skip to content

Commit 1ad66ab

Browse files
eonpataponmpvl
authored andcommitted
internal/core/adt: fix null values equality
`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 <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent b49cbbd commit 1ad66ab

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

internal/core/adt/equality.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func equalTerminal(ctx *OpContext, v, w Value, flags Flag) bool {
139139
}
140140

141141
switch x := v.(type) {
142-
case *Num, *String, *Bool, *Bytes:
142+
case *Num, *String, *Bool, *Bytes, *Null:
143143
if b, ok := BinOp(ctx, EqualOp, v, w).(*Bool); ok {
144144
return b.B
145145
}

internal/diff/diff_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func TestDiff(t *testing.T) {
7171
b: 2
7272
s: 4
7373
d: 1
74+
e: null
7475
}
7576
`,
7677
y: `
@@ -79,6 +80,7 @@ func TestDiff(t *testing.T) {
7980
c: 3
8081
s: 4
8182
d: int
83+
e: null
8284
}
8385
`,
8486
kind: Modified,
@@ -90,6 +92,7 @@ func TestDiff(t *testing.T) {
9092
s: 4
9193
- d: 1
9294
+ d: int
95+
e: null
9396
}
9497
`,
9598
}, {

0 commit comments

Comments
 (0)