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

sequtils.nim: Change some func back to proc #16309

Merged
merged 1 commit into from
Dec 14, 2020

Conversation

ee7
Copy link
Contributor

@ee7 ee7 commented Dec 10, 2020

This PR is a partial revert of commit 6f57eba (#16293), in case that's preferred to a full revert.

It changes the funcs that take a proc parameter back to procs.

See: #16303 and #16304 (comment):

To confirm: do we want to change a proc that has a proc parameter into a func?

No, it was an oversight by me. We don't want that. Callbacks can have effects.

Note that this PR doesn't fix regressions that @timotheecour mentions in #16305. For example:

import std/sequtils
type Foo = ref object
  x: int
let a1 = zip(@[1,2], @[1,2]) # ok
let a2 = zip(@[Foo(x: 1)], @[Foo(x: 2)]) # error

still produces this error when compiling with --experimental:strictFuncs:

/Nim/lib/pure/collections/sequtils.nim(248, 8) Error: 'zip' can have side effects
an object reachable from 's1' is potentially mutated
/Nim/lib/pure/collections/sequtils.nim(284, 17) the mutation is here
/Nim/lib/pure/collections/sequtils.nim(284, 17) is the statement that connected the mutation to the parameter

@ringabout
Copy link
Member

I think adding module to tests/effects/tstrict_funcs.nim isn't enough to cover all functionse. It needs more care to change them. Maybe add --experimental:strictFuncs matrix to the single test of this module(testament).

@ee7
Copy link
Contributor Author

ee7 commented Dec 10, 2020

CI failure is unrelated:

   Compiling /home/runner/work/Nim/Nim/pkgstemp/fidget/tests/test (from package fidget) using c backend
  /home/runner/.nimble/pkgs/typography-0.6.0/typography/font.nim(25, 22) Error: undeclared identifier: 'Segment'

Reported here treeform/fidget#121

@timotheecour
Copy link
Member

No, it was an oversight by me. We don't want that. Callbacks can have effects.

There's a disagreement here, so maybe this revert should wait until this is clarified. The current nim implementation allows func(cb: proc(): int): int, and I'm arguing the current nim implementation is the correct, useful, safe behavior, see #16303 (comment)

@ee7
Copy link
Contributor Author

ee7 commented Dec 10, 2020

There's a disagreement here, so maybe this revert should wait until this is clarified.

Sure. I just made this PR so it's easily available if it's what we want.

I think adding module to tests/effects/tstrict_funcs.nim isn't enough to cover all functions

I was thinking this too. It's true, given that CI is green despite devel having a strictFuncs regression with e.g. zip and ref types.

@ee7
Copy link
Contributor Author

ee7 commented Dec 11, 2020

Now that fidget was fixed, could somebody restart the two failed package CI jobs? I don't have the permissions to do it.

This commit changes the funcs that take a `proc` parameter back to
procs.

This reverts some of commit 6f57eba:
  sequtils.nim: Use `func` (nim-lang#16293)

See also:
- nim-lang#16303
- nim-lang#16304
@ee7 ee7 force-pushed the sequtils-partial-revert-funcs branch from 9137bd2 to a600751 Compare December 14, 2020 16:52
@ee7
Copy link
Contributor Author

ee7 commented Dec 14, 2020

Rebased on devel to resolve a merge conflict due to 8f6e07a.

The relevant diff is only:

 template applyIt*(varSeq, op: untyped) =
-  ## Convenience template around the mutable ``apply`` proc to reduce typing.
+  ## Convenience template around the mutable `apply` proc to reduce typing.

@Araq Araq merged commit 38eb021 into nim-lang:devel Dec 14, 2020
@ee7 ee7 deleted the sequtils-partial-revert-funcs branch December 15, 2020 11:55
mildred pushed a commit to mildred/Nim that referenced this pull request Jan 11, 2021
This commit changes the funcs that take a `proc` parameter back to
procs.

This reverts some of commit 6f57eba:
  sequtils.nim: Use `func` (nim-lang#16293)

See also:
- nim-lang#16303
- nim-lang#16304
ardek66 pushed a commit to ardek66/Nim that referenced this pull request Mar 26, 2021
This commit changes the funcs that take a `proc` parameter back to
procs.

This reverts some of commit 6f57eba:
  sequtils.nim: Use `func` (nim-lang#16293)

See also:
- nim-lang#16303
- nim-lang#16304
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.

4 participants