Skip to content

Commit

Permalink
fixes #22254; fixes #22253; stricteffects bugs on recursive calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed Jul 19, 2023
1 parent 17915d9 commit fafc279
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/pure/json.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions tests/effects/tstrict_effects3.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit fafc279

Please sign in to comment.