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

Array modification doesn't propagate for indexing after change the values for var array #16017

Open
ynfle opened this issue Nov 17, 2020 · 2 comments

Comments

@ynfle
Copy link
Contributor

ynfle commented Nov 17, 2020

When resetting an entire var array using the values in the original array and then using [] to access the elements, some of the old values are still there.

Example

var a = [1, 2, 3, 4, 5]
echo a
echo [a[2], a[3], a[0], a[1], a[4]]
a = [a[2], a[3], a[0], a[1], a[4]]
echo a

Current Output

[1, 2, 3, 4, 5]
[3, 4, 1, 2, 5]
[3, 4, 3, 4, 5]

Expected Output

[1, 2, 3, 4, 5]
[3, 4, 1, 2, 5]
[3, 4, 1, 2, 5]

Possible Solution

🤷‍♂️ Possibly some optimization issue

Additional Information

Doesn't work from the current devel build all the way back until 0.18.x. Before that, there is some issue with array constructors that I am not familiar with and therefore couldn't test

I tested on latest back until 0.18.x on play.nim-lang.org and 1.5.1 with choosenim on my local machine (Mac OSX)

@cooldome
Copy link
Member

Looks like an aliasing problem

@ynfle
Copy link
Contributor Author

ynfle commented Nov 20, 2020

Any idea where I'd look to fix it or to even see if that's the issue and I'll give it a go?

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

2 participants