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

Copying of a sink parameter into a variable not allowed #16119

Closed
planetis-m opened this issue Nov 24, 2020 · 0 comments
Closed

Copying of a sink parameter into a variable not allowed #16119

planetis-m opened this issue Nov 24, 2020 · 0 comments

Comments

@planetis-m
Copy link
Contributor

planetis-m commented Nov 24, 2020

Example

module A

type
  Foo*[T] = object
    v*: T
proc `=destroy`*[T](f: var Foo[T]) =
  echo "destroyed ", f.v
proc `=copy`*[T](f: var Foo[T], s: Foo[T]) =
  echo "copied ", f.v

proc foo*[T](t: sink Foo[T]) =
  var t = t #same for let
  t.v = T(2)

module B

import a

var a = Foo[int](v: 1)
foo(a)
echo a

Current Output

b.nim(4, 4) template/generic instantiation of foo from here
a.nim(10, 7) Error: invalid type: 'sink Foo[system.int]' for var

Additional Information

Introduced in #15690

$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2020-11-24
git hash: d306a04466b7f1129620dc3ab35443119ed4c867
Araq added a commit that referenced this issue Nov 26, 2020
narimiran pushed a commit that referenced this issue Nov 27, 2020
(cherry picked from commit 9f1c5f6)
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant