diff options
-rw-r--r-- | lib/pure/json.nim | 5 | ||||
-rw-r--r-- | tests/effects/tstrict_effects3.nim | 11 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 2e448dba7..fcb9eae41 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -438,7 +438,7 @@ macro `%*`*(x: untyped): untyped = ## `%` for every element. result = toJsonImpl(x) -proc `==`*(a, b: JsonNode): bool {.noSideEffect.} = +proc `==`*(a, b: JsonNode): bool {.noSideEffect, raises: [].} = ## Check two nodes for equality if a.isNil: if b.isNil: return true @@ -458,7 +458,8 @@ proc `==`*(a, b: JsonNode): bool {.noSideEffect.} = of JNull: result = true of JArray: - result = a.elems == b.elems + {.cast(raises: []).}: # bug #19303 + result = a.elems == b.elems of JObject: # we cannot use OrderedTable's equality here as # the order does not matter for equality here. diff --git a/tests/effects/tstrict_effects3.nim b/tests/effects/tstrict_effects3.nim index 027b46474..0d98a0343 100644 --- a/tests/effects/tstrict_effects3.nim +++ b/tests/effects/tstrict_effects3.nim @@ -44,3 +44,14 @@ proc fail() = discard f1() f2() +import std/json + +# bug #22254 +proc senri(a, b: seq[JsonNode]) {.raises: [].} = discard a == b + +# bug #22253 +proc serika() {.raises: [].} = discard default(JsonNode) == nil + +senri(@[newJBool(true)], @[newJBool(false)]) +serika() + |