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.length producing this error: TypeError: Cannot read property 'height' of undefined #549
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Apr 5, 2016
Contributor
Probably the same as https://github.com/elm-lang/core/issues/349 and/or https://github.com/elm-lang/core/issues/474?
|
Probably the same as https://github.com/elm-lang/core/issues/349 and/or https://github.com/elm-lang/core/issues/474? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rebelwarrior
Apr 5, 2016
Contributor
Definitely not #349.
If I hard code indexEnd to 32 33 or even 133 I get no error.
It's not the slice alone it's the array + length that's producing the error.
Sent from my mobile.
On Apr 5, 2016, at 1:20 AM, Janis Voigtländer notifications@github.com wrote:
Probably the same as #349 and/or #474?
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
|
Definitely not #349. Sent from my mobile.
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Apr 5, 2016
Contributor
If I hard code indexEnd to 32 33 or even 133 I get no error.
Doesn't mean https://github.com/elm-lang/core/pull/399 won't fix this.
Doesn't mean https://github.com/elm-lang/core/pull/399 won't fix this. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rebelwarrior
Apr 5, 2016
Contributor
Here is another weird thing I tried it on try elm and reproduced the error with this code. So it seems to be an intermittent issue with very large Arrays. Note that changing the end number of the first array up or down one digit makes the error go away and so does making it larger say by adding a zero.
module Sublist (..) where
import Array
import Graphics.Element exposing (..)
import Debug exposing (..)
sublist : List comparable -> List comparable -> String
sublist list1 list2 =
let
size1 = List.length list1
size2 = List.length list2
in
if list1 == list2 then
"Equal"
else if List.isEmpty list1 && not (List.isEmpty list2) then
"Sublist"
else if List.isEmpty list2 && not (List.isEmpty list1) then
"Superlist"
else if size1 <= size2 && isSublistOf list1 list2 then
"Sublist"
else if size2 <= size1 && isSublistOf list2 list1 then
"Superlist"
else
"Unequal"
isSublistOf list1 list2 =
let
array1 = Array.fromList list1
array2 = Array.fromList list2
in
-- check recursively if array2 indexes match first element of array1
-- if so check if it fits
checkArrayEl_r array1 array2 0
checkArrayEl_r : Array.Array a -> Array.Array a -> Int -> Bool
checkArrayEl_r array1 array2 indexOf2 =
case (Array.get indexOf2 array2) of
Nothing -> False
Just el2 ->
case (Array.get 0 array1) of
Nothing -> False
Just el1 ->
if el1 /= el2 then
checkArrayEl_r array1 array2 (indexOf2 + 1)
else
ifArrayFits array1 array2 indexOf2
ifArrayFits : Array.Array a -> Array.Array a -> Int -> Bool
ifArrayFits array1 array2 indexOf2 =
-- Code below is producing an error and it should not...
-- TypeError: Cannot read property 'height' of undefined
let
indexEnd = (Array.length array1)
x = log ((toString indexOf2) ++ "---------**------")
-- indexEnd = 133
in
(array1 == (Array.slice indexOf2 (indexEnd + indexOf2) array2))
main : Element
main =
show (sublist [10..100001] [1..100000])|
Here is another weird thing I tried it on try elm and reproduced the error with this code. So it seems to be an intermittent issue with very large Arrays. Note that changing the end number of the first array up or down one digit makes the error go away and so does making it larger say by adding a zero. module Sublist (..) where
import Array
import Graphics.Element exposing (..)
import Debug exposing (..)
sublist : List comparable -> List comparable -> String
sublist list1 list2 =
let
size1 = List.length list1
size2 = List.length list2
in
if list1 == list2 then
"Equal"
else if List.isEmpty list1 && not (List.isEmpty list2) then
"Sublist"
else if List.isEmpty list2 && not (List.isEmpty list1) then
"Superlist"
else if size1 <= size2 && isSublistOf list1 list2 then
"Sublist"
else if size2 <= size1 && isSublistOf list2 list1 then
"Superlist"
else
"Unequal"
isSublistOf list1 list2 =
let
array1 = Array.fromList list1
array2 = Array.fromList list2
in
-- check recursively if array2 indexes match first element of array1
-- if so check if it fits
checkArrayEl_r array1 array2 0
checkArrayEl_r : Array.Array a -> Array.Array a -> Int -> Bool
checkArrayEl_r array1 array2 indexOf2 =
case (Array.get indexOf2 array2) of
Nothing -> False
Just el2 ->
case (Array.get 0 array1) of
Nothing -> False
Just el1 ->
if el1 /= el2 then
checkArrayEl_r array1 array2 (indexOf2 + 1)
else
ifArrayFits array1 array2 indexOf2
ifArrayFits : Array.Array a -> Array.Array a -> Int -> Bool
ifArrayFits array1 array2 indexOf2 =
-- Code below is producing an error and it should not...
-- TypeError: Cannot read property 'height' of undefined
let
indexEnd = (Array.length array1)
x = log ((toString indexOf2) ++ "---------**------")
-- indexEnd = 133
in
(array1 == (Array.slice indexOf2 (indexEnd + indexOf2) array2))
main : Element
main =
show (sublist [10..100001] [1..100000]) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rebelwarrior
Apr 5, 2016
Contributor
That's true @jvoigtlaender it maybe the solution to one may fix the other. Slice is definitely funky for Arrays.
|
That's true @jvoigtlaender it maybe the solution to one may fix the other. Slice is definitely funky for Arrays. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Jun 25, 2016
Member
Closing in favor of #649 which will track all array issues and progress on a new implementation.
|
Closing in favor of #649 which will track all array issues and progress on a new implementation. |
rebelwarrior commentedApr 4, 2016
Hi, I got an unusual error after compilation:
This is the offending code:
This is from exercism.io here is the link:
exercism.io/rebelwarrior/elm/sublist
Version 0.16 of Elm.
It could be related to the way it is tested. I tried all the commands in this function in the repl and all worked fine. However, if I simply returned
TrueorFalsefrom the function and commented out the code the error disappeared.