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

Recursion in the VM under orc/arc mutates contents of a seq to their default values #17294

Closed
deech opened this issue Mar 7, 2021 · 1 comment
Labels
VM see also `const` label

Comments

@deech
Copy link
Contributor

deech commented Mar 7, 2021

Recursion mutates the contents of an immutable seq argument to their default values.

Example

proc recurse(strings:seq[string],recursionsLeft:int) =
  if recursionsLeft != 0:
    echo "Before call: " & $strings
    recurse(strings & @["another string"],recursionsLeft-1)
    echo "After call: " & $strings
  else:
    discard

static:
  recurse(@["string"],1)

Current Output

Before call: @["string"]
After call: @[""]

Expected Output

Before call: @["string"]
After call: @["string"]

Compile Command

nim cpp --forceBuild:on --gc:orc -r --verbosity\:0 --hint\[Processing\]\:off --excessiveStackTrace\:on /home/deech/NimScratch/recbug.nim
$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-03-07
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: d1e093207acdd10ad375705bd1732fc6f0db9f55
active boot switches: -d:release
@deech deech changed the title Recursion in the VM under orc/arc "zero's" out function argument Recursion in the VM under orc/arc mutates contents of a seq to their default values Mar 7, 2021
@ghost
Copy link

ghost commented Mar 8, 2021

Duplicate of #17199

@ghost ghost marked this as a duplicate of #17199 Mar 8, 2021
@ghost ghost closed this as completed Mar 8, 2021
@ghost ghost added the VM see also `const` label label Mar 8, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VM see also `const` label
Projects
None yet
Development

No branches or pull requests

1 participant