{"action":"created","issue":{"url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/1063","labels_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/1063/labels{/name}","comments_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/1063/comments","events_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/1063/events","html_url":"https://github.com/elm-lang/elm-compiler/issues/1063","id":107294562,"number":1063,"title":"Undefined variable being passed to a function does not raise compiler error","user":{"login":"fiatjaf","id":1653275,"avatar_url":"https://avatars.githubusercontent.com/u/1653275?v=3","gravatar_id":"","url":"https://api.github.com/users/fiatjaf","html_url":"https://github.com/fiatjaf","followers_url":"https://api.github.com/users/fiatjaf/followers","following_url":"https://api.github.com/users/fiatjaf/following{/other_user}","gists_url":"https://api.github.com/users/fiatjaf/gists{/gist_id}","starred_url":"https://api.github.com/users/fiatjaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fiatjaf/subscriptions","organizations_url":"https://api.github.com/users/fiatjaf/orgs","repos_url":"https://api.github.com/users/fiatjaf/repos","events_url":"https://api.github.com/users/fiatjaf/events{/privacy}","received_events_url":"https://api.github.com/users/fiatjaf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-18T23:26:32Z","updated_at":"2015-09-19T00:53:00Z","closed_at":null,"body":"Deep down in the \"cases\" of my `update` function, there is this:\r\n\r\n```elm\r\nupdate : Action -> Model -> (Model, Effects Action)\r\nupdate action model =\r\n  case action of\r\n    (other cases)\r\n    BoardAction boardAction ->\r\n      let\r\n        (board, effects) = Board.update boardAction board\r\n      in\r\n        (\r\n          { model |\r\n            board <- board\r\n          }\r\n        , Effects.map (BoardAction) effects\r\n        )\r\n```\r\n\r\nWhere I passed that last `board` argument I should have passed `model.board`, but I made this mistake, and the compiler did not complain. Now I tried replacing `board` for other arbitrary names, but then the compiler noted the mistake and compilation failed.\r\n\r\nThen I tried the following:\r\n\r\n```elm\r\n    BoardAction boardAction ->\r\n      let\r\n        (hahaha, effects) = Board.update boardAction hahaha\r\n      in\r\n        (\r\n          { model |\r\n            board <- hahaha\r\n          }\r\n        , Effects.map (BoardAction) effects\r\n        )\r\n```\r\n\r\nand the compiler allowed.\r\n\r\nRunning the program compiled this way I get a runtime error somewhere where I needed a property of `model.board`:\r\n\r\n```\r\nUncaught TypeError: Cannot read property 'columns' of undefined\r\n```\r\n`'columns'` is a property of `model.board`, but here's where I think the problem could be better inspected, in the generated code for `BoardAction`:\r\n\r\n```javascript\r\n   var update = F2(function (action,\r\n   model) {\r\n      return function () {\r\n         switch (action.ctor)\r\n         {case \"BoardAction\":\r\n            return function () {\r\n                 var $ = A2($Board.update,\r\n                 action._0,\r\n                 hahaha),\r\n                 hahaha = $._0,\r\n                 effects = $._1;\r\n                 return {ctor: \"_Tuple2\"\r\n                        ,_0: _U.replace([[\"board\"\r\n                                         ,hahaha]],\r\n                        model)\r\n                        ,_1: A2($Effects.map,\r\n                        BoardAction,\r\n                        effects)};\r\n              }();\r\n```\r\n\r\nor, in the printscreen version with all the important values:\r\n\r\n![](http://i.imgur.com/DjSB0sC.png)"},"comment":{"url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/comments/141604963","html_url":"https://github.com/elm-lang/elm-compiler/issues/1063#issuecomment-141604963","issue_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/1063","id":141604963,"user":{"login":"fiatjaf","id":1653275,"avatar_url":"https://avatars.githubusercontent.com/u/1653275?v=3","gravatar_id":"","url":"https://api.github.com/users/fiatjaf","html_url":"https://github.com/fiatjaf","followers_url":"https://api.github.com/users/fiatjaf/followers","following_url":"https://api.github.com/users/fiatjaf/following{/other_user}","gists_url":"https://api.github.com/users/fiatjaf/gists{/gist_id}","starred_url":"https://api.github.com/users/fiatjaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fiatjaf/subscriptions","organizations_url":"https://api.github.com/users/fiatjaf/orgs","repos_url":"https://api.github.com/users/fiatjaf/repos","events_url":"https://api.github.com/users/fiatjaf/events{/privacy}","received_events_url":"https://api.github.com/users/fiatjaf/received_events","type":"User","site_admin":false},"created_at":"2015-09-19T00:53:00Z","updated_at":"2015-09-19T00:53:00Z","body":"It looks the same."}}