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

Compiler replaces =sink for =copy #20572

Closed
planetis-m opened this issue Oct 15, 2022 · 2 comments
Closed

Compiler replaces =sink for =copy #20572

planetis-m opened this issue Oct 15, 2022 · 2 comments

Comments

@planetis-m
Copy link
Contributor

planetis-m commented Oct 15, 2022

What happened?

Explicitly calling =sink doesn't work. It's rewritten as copy.

proc main =
  var a = "abc"
  var b = "de"
  `=sink`(a, b)
  echo a

main()

Nim Version

Nim Compiler Version 1.7.3 [Linux: amd64]
Compiled at 2022-10-15
Copyright (c) 2006-2022 by Andreas Rumpf

git hash: 0510a2b
active boot switches: -d:release --gc:markAndSweep

Current Standard Output Logs

# --expandArc:main

var
  a
  b_cursor
try:
  a = "abc"
  b_cursor = "de"
  `=copy`(a, b_cursor)
  echo [a]
finally:
  `=destroy`(a)

Expected Standard Output Logs

No response

Possible Solution

No response

Additional Information

std/isolation is affected from this bug because in:

proc `=sink`*[T](dest: var Isolated[T]; src: Isolated[T]) {.inline.} =
  # delegate to value's sink operation
  `=sink`(dest.value, src.value)

It's replaced by =copy!

@beef331
Copy link
Collaborator

beef331 commented Oct 15, 2022

You dont call =sink you do move so a = move b and dest.value = move src.value. Though given these are string literals copying the cursor is the same as a move afaik.

@Araq
Copy link
Member

Araq commented Oct 15, 2022

@beef331 In this case move cannot be used.

Araq added a commit that referenced this issue Oct 17, 2022
@Araq Araq closed this as completed in 81087c9 Oct 17, 2022
capocasa pushed a commit to capocasa/Nim that referenced this issue Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants