Nim
                                
                                
                                
                                    Nim copied to clipboard
                            
                            
                            
                        make var, let work in static, const sections
refs https://github.com/nim-lang/RFCs/issues/276
see tests tests/misc/trfc_276.nim
for static: this PR should fix existing issues
- fix https://github.com/nim-lang/Nim/issues/10938
 - fix https://github.com/nim-lang/Nim/issues/13312
 - fix https://github.com/nim-lang/Nim/issues/13887
 
for const: this PR should improve existing issues
- refs https://github.com/nim-lang/Nim/issues/13918
 - refs https://github.com/nim-lang/Nim/issues/12172
 - refs https://github.com/nim-lang/Nim/issues/13795 [1]
 
note 1
this PR uses the genPNode introduced in https://github.com/nim-lang/Nim/pull/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, https://github.com/nim-lang/Nim/issues/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 https://github.com/nim-lang/Nim/pull/18637 for an alternative that doesn't use intermediate procs, it almost works but has some issues; ... it's hard
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.