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

Consts that call templates cannot evaluate whilst in procedure bodies #13795

Closed
awr1 opened this issue Mar 28, 2020 · 4 comments · May be fixed by timotheecour/Nim#795
Closed

Consts that call templates cannot evaluate whilst in procedure bodies #13795

awr1 opened this issue Mar 28, 2020 · 4 comments · May be fixed by timotheecour/Nim#795

Comments

@awr1
Copy link
Contributor

awr1 commented Mar 28, 2020

import std / sequtils
type SomeEnum = enum
  Foo = "foo", Bar, Baz
proc someProc() =
  const y = SomeEnum.toSeq

fails with:

sequtils.nim(623, 9) Error: cannot evaluate at compile time: result`gensym144407

However, the following passes compilation:

import std / sequtils
type SomeEnum = enum
  Foo = "foo", Bar, Baz
const x = SomeEnum.toSeq 
@juancarlospaco
Copy link
Collaborator

Can repro.

@timotheecour
Copy link
Member

@awr1 the title needs to be changed, see reduced example below:

when true: # D20200508T215154:here gitissue
  template fun(): untyped =
    var c = 0
    c

  proc main() =
    const c = fun()

  main()

@awr1 awr1 changed the title Cannot evaluate const toSeq() on enums inside proc body Consts that call templates cannot evaluate whilst in procedure bodies May 9, 2020
@awr1
Copy link
Contributor Author

awr1 commented May 9, 2020

@timotheecour Done

@timotheecour
Copy link
Member

this sounds like an exact duplicate of #12172, see #12172 (comment)

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.

3 participants