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

regression(0.20.0 => devel): move gives wrong results with var params in VM #15975

Open
timotheecour opened this issue Nov 15, 2020 · 1 comment
Labels
Regression VM see also `const` label

Comments

@timotheecour
Copy link
Member

timotheecour commented Nov 15, 2020

move gives wrong results with var params in VM

Example

when true:
  type Foo = object
    f0: int
  proc fn(a: var Foo) =
    var s: Foo
    s = move(a)
    echo s
    echo a
    a = Foo(f0: 2)
    echo s
  proc main()=
    echo "---"
    var a = Foo(f0: 1)
    fn(a)

  static: main()
  main()

Current Output

---
(f0: 0)
(f0: 0)
(f0: 2)
---
(f0: 1)
(f0: 0)
(f0: 1)

Expected Output

---
(f0: 1)
(f0: 0)
(f0: 1)
---
(f0: 1)
(f0: 0)
(f0: 1)

Additional Information

regression:

  • fails with: devel 1.5.1 c39fa0d
  • works with: nim 0.20.0
  • likewise in other cases where you'd have a copy, eg: var s: seq[Foo] and s.add a
  • 2nd root cause for RT vs CT flyx/NimYAML#91 (nimyaml gives wrong results at CT)

note

it's possible that the root cause is the same as #15974, but not obvious to me why it would

@timotheecour timotheecour added Invalid Code Acceptance Everything related to compiler not complaining about invalid code VM see also `const` label Regression and removed Invalid Code Acceptance Everything related to compiler not complaining about invalid code labels Nov 15, 2020
@ringabout
Copy link
Member

Since #17348 is merged, the content of move is not cleared.

---
(f0: 1)
(f0: 1)
(f0: 1)
---
(f0: 1)
(f0: 0)
(f0: 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Regression VM see also `const` label
Projects
None yet
Development

No branches or pull requests

2 participants