summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-07-19 21:20:41 +0800
committerGitHub <noreply@github.com>2023-07-19 15:20:41 +0200
commit5ed44e1ec463b68180e17cfe59c8c68d8c55d406 (patch)
tree67f91ee4d68edf884fb3b66f53896f3244cd4bd1
parent0d3bde95f578576d2e84d422d5694ee0e0055cbc (diff)
downloadNim-5ed44e1ec463b68180e17cfe59c8c68d8c55d406.tar.gz
fixes #22254; fixes #22253; stricteffects bugs on recursive calls (#22294)
-rw-r--r--lib/pure/json.nim5
-rw-r--r--tests/effects/tstrict_effects3.nim11
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()
+