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
Arc sink arg crash #15238
Comments
Another interesting question. |
I think |
@Clyybber, your answer is surprise for me. var param into sink should produce copy. Is this your the statement? |
This is how that should work from what I can tell: proc sinkArg(x: sink seq[string]) =
discard
proc varArg(lst: var seq[string]) =
# `lst` is `a`
sinkArg(lst) # analyze if `lst` can be moved
# last call in scope, switch to analyze `a` lifetime.
var a = @["a", "b"]
varArg(a) # analysis start
echo a # `a` is used after call to varArg() => `a` can't be moved => `lst` can't be moved. I'm not too familiar with how Nim actually does the analysis, so this might not be the desired result, though IMO it's the least surprising. |
If Nim will pass Question: what is the correct behavior according to our spec? to copy or not to copy. |
Yeah, it should copy. |
OK, then the issue is that |
* fix_15238 * fix test
Compile with
--gc:arc -d:danger
Example
Should crash
The issue caused by the fact that in generated c code the sinkArg argument is passed by value not by pointer/reference
The text was updated successfully, but these errors were encountered: