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

strictFuncs: cannot import critbits #16873

Closed
ee7 opened this issue Jan 30, 2021 · 0 comments · Fixed by #16877
Closed

strictFuncs: cannot import critbits #16873

ee7 opened this issue Jan 30, 2021 · 0 comments · Fixed by #16877

Comments

@ee7
Copy link
Contributor

ee7 commented Jan 30, 2021

Example

Compile the below with nim c --experimental:strictFuncs

import critbits

Current Output

/nim/pure/collections/critbits.nim(529, 6) Error: 'toCritBitTree' can have side effects

Expected Output

No error.

Additional Information

toCritBitTree is defined here:

func toCritBitTree*[T](pairs: openArray[(string, T)]): CritBitTree[T] {.since: (1, 3).} =
## Creates a new `CritBitTree` that contains the given `pairs`.
runnableExamples:
doAssert {"a": "0", "b": "1", "c": "2"}.toCritBitTree is CritBitTree[string]
doAssert {"a": 0, "b": 1, "c": 2}.toCritBitTree is CritBitTree[int]
for item in pairs: result.incl item[0], item[1]
func toCritBitTree*(items: openArray[string]): CritBitTree[void] {.since: (1, 3).} =
## Creates a new `CritBitTree` that contains the given `items`.
runnableExamples:
doAssert ["a", "b", "c"].toCritBitTree is CritBitTree[void]
for item in items: result.incl item

Nim version

This issue occurs with the latest devel commit (111092e), but not in Nim 1.4.2.

Edit: I have confirmed that this issue was introduced by 2aed418.

ee7 added a commit to ee7/Nim that referenced this issue Jan 30, 2021
Previously, compiling a file containing just `import critbits` with
`nim c --experimental:strictFuncs` would produce the following error:
    critbits.nim(529, 6) Error: 'toCritBitTree' can have side effects

This was introduced by 2aed418 (nim-lang#16564).

Fixes: nim-lang#16873
Araq pushed a commit that referenced this issue Feb 1, 2021
Previously, compiling a file containing just `import critbits` with
`nim c --experimental:strictFuncs` would produce the following error:
    critbits.nim(529, 6) Error: 'toCritBitTree' can have side effects

This was introduced by 2aed418 (#16564).

Fixes: #16873
ee7 added a commit to ee7/Nim that referenced this issue Feb 1, 2021
This commit attempts to improve testing of strictFuncs and views, and
prevent regressions like nim-lang#16873 (resolved by 0b01edd).

We previously only explicitly tested strictFuncs and views with a
smaller number of stdlib modules, mostly in:
- tests/effects/tstrict_funcs.nim
- tests/views/tcan_compile_nim.nim

Note that this commit leaves the `pegs` module commented out; it
cannot currently be compiled with `--experimental:views` (see nim-lang#16892).

Note also that this commit is not sufficient to test strictFuncs and
views, but it does detect a subset of problems.
Araq pushed a commit that referenced this issue Feb 3, 2021
This commit attempts to improve testing of strictFuncs and views, and
prevent regressions like #16873 (resolved by 0b01edd).

We previously only explicitly tested strictFuncs and views with a
smaller number of stdlib modules, mostly in:
- tests/effects/tstrict_funcs.nim
- tests/views/tcan_compile_nim.nim

Note that this commit leaves the `pegs` module commented out; it
cannot currently be compiled with `--experimental:views` (see #16892).

Note also that this commit is not sufficient to test strictFuncs and
views, but it does detect a subset of problems.
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
Previously, compiling a file containing just `import critbits` with
`nim c --experimental:strictFuncs` would produce the following error:
    critbits.nim(529, 6) Error: 'toCritBitTree' can have side effects

This was introduced by 2aed418 (nim-lang#16564).

Fixes: nim-lang#16873
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
This commit attempts to improve testing of strictFuncs and views, and
prevent regressions like nim-lang#16873 (resolved by 0b01edd).

We previously only explicitly tested strictFuncs and views with a
smaller number of stdlib modules, mostly in:
- tests/effects/tstrict_funcs.nim
- tests/views/tcan_compile_nim.nim

Note that this commit leaves the `pegs` module commented out; it
cannot currently be compiled with `--experimental:views` (see nim-lang#16892).

Note also that this commit is not sufficient to test strictFuncs and
views, but it does detect a subset of problems.
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 a pull request may close this issue.

1 participant