status-im / nim-toml-serialization

Flexible TOML serialization [not] relying on run-time type information.
Apache License 2.0
36 stars 7 forks source link

Library errors with devel after stricteffects enabled #56

Closed pietroppeter closed 1 year ago

pietroppeter commented 1 year ago

compiling the first readme example with current devel throws an error.

example file:

import toml_serialization

let rawToml = """
[server]
  name = "TOML Server"
  port = 8005
"""
var x = Toml.decode(rawToml, string, "server.name")
assert x == "TOML Server"

error reported:

C:\Users\ppeterlongo\.nimble\pkgs\toml_serialization-0.2.3\toml_serialization\types.nim(172, 25) template/generic instantiation of `==` from here
C:\Users\ppeterlongo\.choosenim\toolchains\nim-#devel\lib\system\comparisons.nim(309, 6) Error: '==' can have side effects
sideEffect` '=='
>> C:\Users\ppeterlongo\.nimble\pkgs\toml_serialization-0.2.3\toml_serialization\types.nim(144, 6) Hint: '==' called by '=='

see also https://github.com/nim-lang/Nim/pull/20697

it seems adding a noSideEffects annotation to == should fix this. I will check if that is indeed the case and come back with a PR.

pietroppeter commented 1 year ago

the reported error is indeed fixed by annotation all == with noSideEffects, a new error pops out:

C:\Users\ppeterlongo\Documents\toml_serialization\toml_serialization.nim(112, 15) template/generic instantiation of `readValue` from here
C:\Users\ppeterlongo\.nimble\pkgs\serialization-0.1.0\serialization.nim(29, 9) template/generic instantiation of `readValue` from here
C:\Users\ppeterlongo\Documents\toml_serialization\toml_serialization\reader.nim(416, 29) template/generic instantiation from here
C:\Users\ppeterlongo\Documents\toml_serialization\toml_serialization\reader.nim(430, 15) Error: parseValue(r.lex, value) can raise an unlisted exception: Exception