Skip to content

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

Open
@timotheecour

Description

@timotheecour

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions