Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upArray.repeat bug with powers of 32 sizes #176
Comments
TheSeamau5
changed the title from
Array.repeat bug
to
Array.repeat bug with multiples of 32 sizes
Feb 16, 2015
TheSeamau5
changed the title from
Array.repeat bug with multiples of 32 sizes
to
Array.repeat bug with powers of 32 sizes
Feb 16, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
TheSeamau5
Feb 16, 2015
Contributor
This bug seems to affect calling repeat with a size that is a power of 32
For example, the following yields true:
import Array
import List
import Text (asText)
main =
asText <|
(Array.fromList (List.repeat 31 1)) == (Array.repeat 31 1)so, does this:
import Array
import List
import Text (asText)
main =
asText <|
(Array.fromList (List.repeat 33 1)) == (Array.repeat 33 1)But these do not:
import Array
import List
import Text (asText)
main =
asText <|
(Array.fromList (List.repeat 32 1)) == (Array.repeat 32 1)import Array
import List
import Text (asText)
main =
asText <|
(Array.fromList (List.repeat 1024 1)) == (Array.repeat 1024 1)But this one works:
import Array
import List
import Text (asText)
main =
asText <|
(Array.fromList (List.repeat 0 1)) == (Array.repeat 0 1)
|
This bug seems to affect calling repeat with a size that is a power of For example, the following yields true: import Array
import List
import Text (asText)
main =
asText <|
(Array.fromList (List.repeat 31 1)) == (Array.repeat 31 1)so, does this: import Array
import List
import Text (asText)
main =
asText <|
(Array.fromList (List.repeat 33 1)) == (Array.repeat 33 1)But these do not: import Array
import List
import Text (asText)
main =
asText <|
(Array.fromList (List.repeat 32 1)) == (Array.repeat 32 1)import Array
import List
import Text (asText)
main =
asText <|
(Array.fromList (List.repeat 1024 1)) == (Array.repeat 1024 1)But this one works: import Array
import List
import Text (asText)
main =
asText <|
(Array.fromList (List.repeat 0 1)) == (Array.repeat 0 1)
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mgold
Feb 17, 2015
Contributor
Array equality seems to have some issues, and the same fix may resolve a host of problems. In particular, it seems to be comparing tree representations rather than the abstract flattened lists.
|
Array equality seems to have some issues, and the same fix may resolve a host of problems. In particular, it seems to be comparing tree representations rather than the abstract flattened lists. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Cool! Looking forward to the fix. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mgold
Feb 18, 2015
Contributor
I don't have a fix, but a proper implementation of array equality ought to fix both issues.
|
I don't have a fix, but a proper implementation of array equality ought to fix both issues. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
TheSeamau5
Feb 18, 2015
Contributor
Oh...ok... That doesn't matter. I'll still look forward to a fix.
|
Oh...ok... That doesn't matter. I'll still look forward to a fix. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
eeue56
Sep 8, 2015
Contributor
The bug is here is to do with the differences between how initialize creates an array, and how fromList generates an array. fromList will deal with the case where length % M == 0 without adding a parent node. initialize however adds a parent node.
E.g
Array.fromList <| List.repeat n 1will generate
Object {ctor: "_Array", height: 1, table: Array[32], lengths: Array[32]}whereas
Array.repeat n 1will generate
Object {ctor: "_Array", height: 2, table: Array[1], lengths: Array[1]}Whether or not they should generate equally-deep trees or not I don't know, but the fact they don't highlighted this issue.
The Utils.js file assumingly should be comparing Arrays element-by-element, so a fix in tree generation wouldn't be enough to close this issue.
|
The bug is here is to do with the differences between how E.g Array.fromList <| List.repeat n 1will generate Object {ctor: "_Array", height: 1, table: Array[32], lengths: Array[32]}whereas Array.repeat n 1will generate Object {ctor: "_Array", height: 2, table: Array[1], lengths: Array[1]}Whether or not they should generate equally-deep trees or not I don't know, but the fact they don't highlighted this issue. The |
eeue56
referenced this issue
Sep 8, 2015
Closed
Correct tree height generation for arrays of size 32^n #396
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Sep 9, 2015
Member
It looks like the root issue here is using (==) on arrays. This is known to be weird on sets, dicts, and arrays where you do not actually want structural equality, you only care about the leafs.
If that is the root, close this and create a more focused issue about equality on arrays. If there are other relevant issues, please link them here and I will create a meta issue.
|
It looks like the root issue here is using If that is the root, close this and create a more focused issue about equality on arrays. If there are other relevant issues, please link them here and I will create a meta issue. |
TheSeamau5 commentedFeb 16, 2015
For some reason, the following code:
yields
False.You can convince yourself that the repeat function is using the same number.
This was found using the following elm-check property:
which yielded: