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

toSeq / mapIt result cannot be assigned to const #24633

Open
etan-status opened this issue Jan 21, 2025 · 1 comment
Open

toSeq / mapIt result cannot be assigned to const #24633

etan-status opened this issue Jan 21, 2025 · 1 comment

Comments

@etan-status
Copy link
Contributor

Description

import std/sequtils

proc f(a: static openArray[int]) =
  const s1 = a.mapIt(it)
  const s2 = a.toSeq()

f([1,2,3])

Nim Version

% nim -v
Nim Compiler Version 2.0.14 [MacOSX: arm64]
Compiled at 2025-01-06
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: bf4de6a
active boot switches: -d:release

Current Output

/Users/etan/Documents/Repos/nimbus-eth2/vendor/nimbus-build-system/vendor/Nim/lib/pure/collections/sequtils.nim(1024, 13) Error: cannot evaluate at compile time: i`gensym0

Expected Output

Successful compile, no output

Known Workarounds

  • wrap toSeq / mapIt invocation in another proc then assign the output of that proc to the const
  • use let instead of const and put the const at caller site

Additional Information

No response

@metagn
Copy link
Collaborator

metagn commented Jan 21, 2025

Consequence of #8758 #10828 etc

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

No branches or pull requests

2 participants