Skip to content

Commit

Permalink
parsetoml: support compiling with strictFuncs again
Browse files Browse the repository at this point in the history
Nim 1.6.0 added [1] an opt-in for the `strictEffects` behavior, which
will become the default in Nim 2.0 [2].

Parsetoml was changed to support compiling with strictEffects [3], but
we could no longer compile with strictFuncs:

    $ nim c --experimental:strictFuncs src/parsetoml.nim
    /tmp/parsetoml/src/parsetoml.nim(1742, 6) Error: '==' can have side effects
    > /tmp/parsetoml/src/parsetoml.nim(1769, 22) Hint: '==' calls `.sideEffect` '[]'
    >> /foo/nim-devel/lib/pure/collections/tables.nim(1851, 6) Hint: '[]' called by '=='

Add an override so that strictFuncs doesn't complain about the `func`.
Simply changing the `func` to a `proc` doesn't work.

Note that the definition of strictFuncs was recently changed [4].

Closes: #61

[1] https://nim-lang.org/blog/2021/10/19/version-160-released.html#strict-effects
[2] nim-lang/Nim@1e15f975b839
[3] bb90361, "patches for strict effects", 2022-10-24
[4] https://forum.nim-lang.org/t/9716
  • Loading branch information
ee7 committed May 25, 2023
1 parent ed6ca4e commit 319d2d4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/parsetoml.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1765,7 +1765,8 @@ func `==`* (a, b: TomlValueRef): bool =
if a.tableVal.len != b.tableVal.len: return false
for key, val in a.tableVal:
if not b.tableVal.hasKey(key): return false
if b.tableVal[key] != val: return false
{.noSideEffect.}:
if b.tableVal[key] != val: return false
result = true
of TomlValueKind.DateTime:
result =
Expand Down

0 comments on commit 319d2d4

Please sign in to comment.