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 has unwanted side effects - duplicates elements #893

Closed
okkero opened this Issue Aug 7, 2017 · 3 comments

Comments

Projects
None yet
5 participants
@okkero

okkero commented Aug 7, 2017

Description

When using Array under certain circumstances, elements in the array are duplicated when they shouldn't be. This makes some array operations impure. I can only guess that this is due to a bug in the code that handles persistent data structures in the runtime (does Array map more or less directly to JavaScript's array under the hood?).

Example that exhibits the problem

Check out this example: https://ellie-app.com/3W8CQfWkjfSa1/4 (I tried making it as short as possible and still keeping the bug)

This is a small portion of an app that I'm working on. It's a relatively unstyled version of a dialog box for configuring a graph, wherein you can select which parameters are shown on which axis.

Steps to reproduce

  1. Compile the example and click the Setup button
  2. Select the abc parameter in the first list, by clicking on it
  3. Move it to the second list by clicking the button labeled v
  4. Click cancel. According to the Elm code the state of the setup dialog should now be reset and abc should be back in the first list.
  5. Click Setup again. Observe how abc has been moved back to the first list, but that it has also been duplicated and still exists in the second list.
  6. Weirder still, if you open Debug and click the ClickMoveTo message, abc will be duplicated again. Keep clicking this message and abc will keep duplicating. This is not expected nor correct behaviour.

Additional information

I have tested the same code with the difference that the Arrays have been replaced with Lists. Now the app works as expected.

I have only tested this on Windows 10, on Google Chrome Version 60.0.3112.90, but I am willing to bet that it happens on all browsers and OSes.

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Aug 7, 2017

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Aug 7, 2017

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@sigurdsa

This comment has been minimized.

Show comment
Hide comment
@sigurdsa

sigurdsa Aug 7, 2017

Able to reproduce on Firefox 54.0.1 also

sigurdsa commented Aug 7, 2017

Able to reproduce on Firefox 54.0.1 also

@Skinney

This comment has been minimized.

Show comment
Hide comment
@Skinney

Skinney Aug 7, 2017

Contributor

This is fixed in the upcoming Elm 0.19.

If you need a working version NOW, then you can use the package Skinney/elm-array-exploration.

Contributor

Skinney commented Aug 7, 2017

This is fixed in the upcoming Elm 0.19.

If you need a working version NOW, then you can use the package Skinney/elm-array-exploration.

@evancz evancz closed this Aug 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment