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

make var, let work in static, const sections #18637

Closed

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Aug 3, 2021

refs nim-lang/RFCs#276

see tests tests/misc/trfc_276.nim

for static: this PR should fix existing issues

for const: this PR should improve existing issues

note 1

this PR uses the genPNode introduced in #17938

[1]

import std / sequtils
type SomeEnum = enum
  Foo = "foo", Bar, Baz
proc someProc() =
  static:
    let y1 = SomeEnum.toSeq # now works
  const y2 = SomeEnum.toSeq # doesn't work, it'd require to make `needConstWrap` smarter in this PR

likewise, #14645 works with:

      static:
        let rx = re(&"")

but not yet with const rx = re(&"") for same reason

note 2

I'm not sure how to get rid of needConstWrap (only needed for const, not static); without it some tests fail, see the test with: const SymChars: set[char] = {'a' .. 'b'}

note 3

still fails with some tests...
see #18637 for an alternative that doesn't use intermediate procs, it almost works but has some issues; ... it's hard

@stale
Copy link

stale bot commented Aug 10, 2022

This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions.

@stale stale bot added the stale Staled PR/issues; remove the label after fixing them label Aug 10, 2022
@stale stale bot closed this Sep 20, 2022
@ringabout ringabout self-assigned this Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Staled PR/issues; remove the label after fixing them
Projects
2 participants