Skip to content

Extraneous destructor call during environment init #24729

@arnetheduck

Description

@arnetheduck

Description

type NoCopy = object
  v:int

proc `=copy`(x: var NoCopy, y: NoCopy) {.error.}

proc `=destroy`(x: NoCopy) =
  echo "destroy ", x.v

proc caller(f: proc()) =
  f()

proc test2(vv: NoCopy) =
  echo "in here ", vv.v

proc test() =
  debugEcho "1"
  var v = NoCopy(v: 3)
  debugEcho "2"

  caller(proc() = echo v.v)

  debugEcho "4"
  test2(v)

test()

Nim Version

2.2.0

Current Output

1
destroy 0
2
3
4
in here 3
destroy 3

Expected Output

1
2
3
4
in here 3
destroy 3

Known Workarounds

No response

Additional Information

No response

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