Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsetoml: support compiling with strictFuncs again #62

Merged
merged 1 commit into from
Aug 5, 2023

Conversation

ee7
Copy link
Contributor

@ee7 ee7 commented May 26, 2023

Nim 1.6.0 added an opt-in for the strictEffects behavior, which will become the default in Nim 2.0.

Commit bb90361 allowed Nim to compile parsetoml with strictEffects, 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.

Closes: #61


I've checked that this works for every combination of strictEffects and strictFuncs, with both Nim 1.6.12 and devel. I don't know if we want to make a change in times.nim too, but I think we want this PR either way (so that we can compile parsetoml with strictFuncs without waiting for a new Nim release).

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: NimParsers#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
@ee7
Copy link
Contributor Author

ee7 commented Aug 2, 2023

@PMunch Could you please take another look at this? It should be safe as a workaround, even if there may or may not be a better change in upstream std/tables.

I've checked that nim c --experimental:strictFuncs src/parsetoml.nim doesn't work with Nim 2.0.

@PMunch PMunch merged commit d089098 into NimParsers:master Aug 5, 2023
@ee7 ee7 deleted the support-strictFuncs branch August 6, 2023 06:28
@ee7
Copy link
Contributor Author

ee7 commented Aug 6, 2023

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

can no longer compile with strictFuncs
2 participants