diff --git a/json_serialization/types.nim b/json_serialization/types.nim index 66cfdbd..e44b905 100644 --- a/json_serialization/types.nim +++ b/json_serialization/types.nim @@ -136,7 +136,7 @@ func `==`*(lhs, rhs: JsonValueRef): bool = if lhs.isNil and rhs.isNil: return true - if lhs.isNil and rhs.isNil: + if not lhs.isNil and rhs.isNil: return false if lhs.isNil and not rhs.isNil: diff --git a/tests/test_parser.nim b/tests/test_parser.nim index 722cac4..d57c78d 100644 --- a/tests/test_parser.nim +++ b/tests/test_parser.nim @@ -243,6 +243,14 @@ suite "Public parser": if name notin allowedToFail: testParseAsString(fileName) + test "JsonValueRef comparison": + var x = JsonValueRef[uint64](kind: JsonValueKind.Null) + var n = JsonValueRef[uint64](nil) + check x != n + check n != x + check x == x + check n == n + const jsonText = """