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

Cannot read property 'ctor/height' of undefined #559

Closed
jinjor opened this Issue Apr 16, 2016 · 1 comment

Comments

Projects
None yet
1 participant
@jinjor
Contributor

jinjor commented Apr 16, 2016

This code causes an error: Cannot read property 'ctor' of undefined.

import Html exposing (..)

main =
  text buggy

-- Cannot read property 'ctor' of undefined
buggy : String
buggy =
  let
    list =
      List.map
        (\_ -> List.length list)
        [0]
  in
    ""

Lambda function is trying to use undefined value. I'm not sure if compiler can detect this error statically.

The same thing happens with Array.

import Html exposing (..)
import Array exposing (Array)

main =
  text buggy

-- Cannot read property 'height' of undefined
buggy : String
buggy =
  let
    array =
      Array.map
        (\_ -> Array.length array)
        (Array.fromList [0])
  in
    ""

Maybe you wonder why I was trying to access undefined value like this? In my case, the same name variable was predefined as an argument of the function. So I was not aware the new variable was sealing the other.

@jinjor

This comment has been minimized.

Show comment
Hide comment
@jinjor

jinjor Apr 16, 2016

Contributor

Oops, I found the same issue.

Contributor

jinjor commented Apr 16, 2016

Oops, I found the same issue.

@jinjor jinjor closed this Apr 16, 2016

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