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 upGot Bibli.elm:1970 Uncaught TypeError: Cannot read property 'ctor' of undefined OR 'Internal Structure' #727
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
process-bot
Sep 23, 2016
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
Sep 23, 2016
|
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. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
savardd
Sep 23, 2016
import Html exposing (div, button, text)
import Html.App exposing (beginnerProgram)
import Html.Events exposing (onClick)
main =
beginnerProgram
{ model = getInit
, view = view
, update = update
}
type alias Book =
{ title: String
, isbn: String
, date: String
}
type alias Model =
{ books: List Book
, test: String
}
getBooks: Model -> String -> List Book
getBooks model html =
[ Book "" "" "" ]
getInit =
{ books = []
, test = ""
}
viewBook book =
div [] []
viewBooks model =
div []
(
List.map viewBook model.books
)
view model =
div []
[ div [] [ text (toString model) ]
, button [ onClick (FetchSuccess "") ] [ text "fetch" ]
--, viewBooks model -- COMMENT THIS LINE TO SEE 'Internal Structure'
]
type Msg = FetchSuccess String
update: Msg -> Model -> Model
update msg model =
case msg of
FetchSuccess a ->
let
isbns = []
books = getBooks model a
model = {model|test=toString isbns -- If model renamed 'amodel' all works ok
,books=books
}
in
model -- If model renamed 'amodel' all works ok
savardd
commented
Sep 23, 2016
import Html exposing (div, button, text)
import Html.App exposing (beginnerProgram)
import Html.Events exposing (onClick)
main =
beginnerProgram
{ model = getInit
, view = view
, update = update
}
type alias Book =
{ title: String
, isbn: String
, date: String
}
type alias Model =
{ books: List Book
, test: String
}
getBooks: Model -> String -> List Book
getBooks model html =
[ Book "" "" "" ]
getInit =
{ books = []
, test = ""
}
viewBook book =
div [] []
viewBooks model =
div []
(
List.map viewBook model.books
)
view model =
div []
[ div [] [ text (toString model) ]
, button [ onClick (FetchSuccess "") ] [ text "fetch" ]
--, viewBooks model -- COMMENT THIS LINE TO SEE 'Internal Structure'
]
type Msg = FetchSuccess String
update: Msg -> Model -> Model
update msg model =
case msg of
FetchSuccess a ->
let
isbns = []
books = getBooks model a
model = {model|test=toString isbns -- If model renamed 'amodel' all works ok
,books=books
}
in
model -- If model renamed 'amodel' all works ok |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
|
You have run into this: elm/compiler#873. |
jvoigtlaender
closed this
Sep 23, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
savardd commentedSep 23, 2016
•
edited
Edited 1 time
-
savardd
edited Sep 23, 2016 (most recent)
In elm 0.17.1
In the sample code uploaded there is two errors that we can see.
With the code as is, if we click on 'fetch', there will be an error on the javascript console:
--> Bibli.elm:1970 Uncaught TypeError: Cannot read property 'ctor' of undefined
If we comment the line number 47 : ", viewBooks model" in the function view model,
the model will show as "{ books = "", test = "[]" }" once we click on fetch.
And if we rename the 'model' variable on the FetchSuccess to another name (amodel) for exemple, all the code works.