diff options
author | Antonis Geralis <43617260+planetis-m@users.noreply.github.com> | 2023-02-28 15:17:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-28 14:17:21 +0100 |
commit | 83e33207250643dedc541e44ecf32d58f3edd097 (patch) | |
tree | 4663e69fe449d693e85790ba9995cb41c43af9b0 /lib/pure | |
parent | 6fea221d65c999ef7923bf51bbdaa8421cb2e9df (diff) | |
download | Nim-83e33207250643dedc541e44ecf32d58f3edd097.tar.gz |
Use a cast to suppress KeyError raises (#21451)
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/json.nim | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim index e881fbff7..d91da3545 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -465,11 +465,12 @@ proc `==`*(a, b: JsonNode): bool {.noSideEffect.} = if a.fields.len != b.fields.len: return false for key, val in a.fields: if not b.fields.hasKey(key): return false - when defined(nimHasEffectsOf): - {.noSideEffect.}: + {.cast(raises: []).}: + when defined(nimHasEffectsOf): + {.noSideEffect.}: + if b.fields[key] != val: return false + else: if b.fields[key] != val: return false - else: - if b.fields[key] != val: return false result = true proc hash*(n: OrderedTable[string, JsonNode]): Hash {.noSideEffect.} |