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

set __ghcjsArray when slicing array #45

Merged
merged 1 commit into from
Mar 20, 2018
Merged

Conversation

bitonic
Copy link
Contributor

@bitonic bitonic commented Dec 20, 2017

I was not able to test this properly, but intuitively the old copying operations are wrong since they lose the __ghcjsArray property.

This PR together with ghcjs/ghcjs#619 fixes ghcjs/ghcjs#463 .

@achirkin
Copy link

achirkin commented Dec 20, 2017

I was looking at this commit and found a piece of unrelated code nearby that I do not understand:
if(e === null) e = r; creates an infinitely recursive array if the second argument of the function is null, e.g. h$newArray(3, null).
Is this an intended behavior? :) I see this is used in NewArrayArrayOp primop, but that implies if one of the subarrays is updated, all others get updated too, because they all point to the same array.
e.g.
x = h$newArray(3, null); x[0][1] = 2; does quite crazy stuff :)

@luite luite merged commit de9560e into ghcjs:master Mar 20, 2018
@luite
Copy link
Member

luite commented Mar 20, 2018

@achirkin yes that's intentional. This is for arrays of arrays, where the initial element value is the array itself (from compiler/prelude/primops.txt.pp):

primop  NewArrayArrayOp "newArrayArray#" GenPrimOp
   Int# -> State# s -> (# State# s, MutableArrayArray# s #)
   {Create a new mutable array of arrays with the specified number of elements,
    in the specified state thread, with each element recursively referring to the
    newly created array.}
   with
   out_of_line = True
   has_side_effects = True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Another problem with weak references and reactive-banana (different behavior in GHC vs GHCJS)
3 participants