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

Last read of a var parameter generates sink instead of assignment #11633

Closed
jwollen opened this issue Jul 1, 2019 · 0 comments

Comments

@jwollen
Copy link
Contributor

commented Jul 1, 2019

In the following, y = x becomes a sink, leaving the parameter zeroed.

This is a regression introduced some time after 0.19.4. (both with and without --newruntime)

type 
  Foo = object

proc `=`*(self: var Foo; other: Foo) = 
  echo "a"

proc `=sink`*(self: var Foo; other: Foo) = 
  echo "s"

proc test(x: var Foo) =
  let y = x

var foo: Foo
test(foo)
echo foo

Also, less importantly, if x is not var, it instead becomes an assignment, but should probably become a sink when x is passed by ref?

@jwollen jwollen changed the title Last read of a var parameter generates sink instead of assigment Last read of a var parameter generates sink instead of assignment Jul 1, 2019

@Araq Araq added the Destructors label Jul 1, 2019

@Araq Araq closed this in cce8a73 Jul 1, 2019

narimiran added a commit that referenced this issue Jul 2, 2019

fixes #11633
(cherry picked from commit cce8a73)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.