Skip to content

Top level variables are moved sometimes #23524

@beef331

Description

@beef331

Description

Depending on what hooks exist for a type top level variables might be moved instead of copied:

type MyType = object a: int proc `=destroy`(typ: MyType) = echo "Destroyed: ", typ.a var t1 = MyType(a: 100) var t2 = t1 # Should be a copy? proc main() = t2 = t1 echo t1 echo t2 main()

Nim Version

2.0.4 and devel

Current Output

(a: 0) (a: 0) Destroyed: 0 Destroyed: 0 

Expected Output

(a: 100) (a: 100) Destroyed: 100 Destroyed: 100 

Possible Solution

No response

Additional Information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions