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

addr doesn't work inside static at proc scope #18641

Closed
timotheecour opened this issue Aug 3, 2021 · 0 comments · Fixed by #19902 · May be fixed by timotheecour/Nim#795
Closed

addr doesn't work inside static at proc scope #18641

timotheecour opened this issue Aug 3, 2021 · 0 comments · Fixed by #19902 · May be fixed by timotheecour/Nim#795
Labels
const `const x=expr` or `static: stmt`

Comments

@timotheecour
Copy link
Member

Example

when true:
  type A = object
    ha1: int
  static:
    var a = A()
    var a2 = a.addr
    a2.ha1 = 11
    doAssert a2.ha1 == 11
    a.ha1 = 12
    doAssert a.ha1 == 12
    doAssert a2.ha1 == 12 # ok
  static:
    proc fn() =
      var a = A()
      var a2 = a.addr
      a2.ha1 = 11
      doAssert a2.ha1 == 11
      a.ha1 = 12
      doAssert a.ha1 == 12
      doAssert a2.ha1 == 12 # fails
    fn()

Current Output

the 2nd a2.ha1 == 12 (inside fn) fails
t12680.nim(24, 16) a2.ha1 == 12 [AssertionDefect]

Expected Output

works

Additional Information

1.5.1 6b3c77e

@timotheecour timotheecour added the const `const x=expr` or `static: stmt` label Aug 3, 2021
timotheecour added a commit to timotheecour/Nim that referenced this issue Aug 3, 2021
ringabout added a commit that referenced this issue Jun 20, 2022
Araq pushed a commit that referenced this issue Jun 22, 2022
 (#19902) [backport]

* revert #12217 since the root problem seems to have been fixed; fix #15974;fix #12551; fix #19464

* fix #16020; fix #16780

* fix tests and #16613

* fix #14553

* fix #19909; skip skipRegisterAddr

* fix #18641
narimiran pushed a commit that referenced this issue Jun 23, 2022
 (#19902) [backport]

* revert #12217 since the root problem seems to have been fixed; fix #15974;fix #12551; fix #19464

* fix #16020; fix #16780

* fix tests and #16613

* fix #14553

* fix #19909; skip skipRegisterAddr

* fix #18641

(cherry picked from commit 3cb2d7a)
capocasa pushed a commit to capocasa/Nim that referenced this issue Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
const `const x=expr` or `static: stmt`
Projects
None yet
1 participant