Skip to content

regression(1.04): reset broken in VM; incorrect VM handling of var params #12994

Closed
@timotheecour

Description

@timotheecour

This regression was introduced in the recent reset PR (system.reset is no longer magic (#12937)) (the 2nd regression i found for this PR although this one is more serious).
The root cause is probably not #12937 per se, but what may be a bug in VM regarding var parameters / moves.

Example

type Atom* = object
  bar: int

proc main() =
  var s: seq[Atom]
  var atom: Atom
  for i in 0..<2:
    atom.bar = 5
    s.add atom
    atom.reset # BUG
    # atom = default(type(atom)) # works
    echo s

static: main()
main()

Current Output

nim c -r -f --warnings:off t0855.nim

@[(bar: 5)]
@[(bar: 5), (bar: 0)] # BUG HERE
Hint: operation successful (52766 lines compiled; 0.386 sec total; 58.273MiB peakmem; Debug Build) [SuccessX]
@[(bar: 5)]
@[(bar: 5), (bar: 5)]

Expected Output

@[(bar: 5)]
@[(bar: 5), (bar: 5)]
Hint: operation successful (52766 lines compiled; 0.386 sec total; 58.273MiB peakmem; Debug Build) [SuccessX]
@[(bar: 5)]
@[(bar: 5), (bar: 5)]

Possible Solution

Additional Information

D20191230T155433

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions