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

`=sink` gets called on `result` when not used explicitly #9594

jwollen opened this issue Nov 1, 2018 · 0 comments


None yet
1 participant
Copy link

commented Nov 1, 2018

The following assertion fails since result will be moved into temp implicitly, even when returning result explicitly. Otherwise using result explicitly works.

  Foo = object
    i: int

proc `=`(self: var Foo; other: Foo) =
  self.i = other.i + 1

proc `=sink`(self: var Foo; other: Foo) =
  self.i = other.i

proc `=destroy`(self: var Foo) = discard

proc test(): Foo =
  result = Foo()
  let temp = result
  assert temp.i > 0
  # return result

discard test()

@Araq Araq closed this in 234bed1 Nov 2, 2018

Araq added a commit that referenced this issue Nov 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.