{"action":"opened","issue":{"url":"https://api.github.com/repos/elm/compiler/issues/1714","repository_url":"https://api.github.com/repos/elm/compiler","labels_url":"https://api.github.com/repos/elm/compiler/issues/1714/labels{/name}","comments_url":"https://api.github.com/repos/elm/compiler/issues/1714/comments","events_url":"https://api.github.com/repos/elm/compiler/issues/1714/events","html_url":"https://github.com/elm/compiler/issues/1714","id":326565370,"number":1714,"title":"sending () through ports","user":{"login":"danmarcab","id":1517969,"avatar_url":"https://avatars2.githubusercontent.com/u/1517969?v=4","gravatar_id":"","url":"https://api.github.com/users/danmarcab","html_url":"https://github.com/danmarcab","followers_url":"https://api.github.com/users/danmarcab/followers","following_url":"https://api.github.com/users/danmarcab/following{/other_user}","gists_url":"https://api.github.com/users/danmarcab/gists{/gist_id}","starred_url":"https://api.github.com/users/danmarcab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danmarcab/subscriptions","organizations_url":"https://api.github.com/users/danmarcab/orgs","repos_url":"https://api.github.com/users/danmarcab/repos","events_url":"https://api.github.com/users/danmarcab/events{/privacy}","received_events_url":"https://api.github.com/users/danmarcab/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-25T15:17:32Z","updated_at":"2018-05-25T15:17:32Z","closed_at":null,"author_association":"NONE","body":"If a port is defined as `() -> Cmd msg`, you get a runtime error when calling the port. It works fine if the port is defined as `{} -> Cmd msg`.\r\n\r\n### SSCCE\r\n\r\n#### Main.elm\r\n\r\n```elm\r\nport module Main exposing (main)\r\n\r\nimport Browser\r\nimport Html exposing (Html, button, div, text)\r\nimport Html.Events exposing (onClick)\r\n\r\n\r\nport log : () -> Cmd msg\r\n\r\n\r\ntype alias Model = ()\r\n\r\ntype Msg\r\n    = Log\r\n\r\n\r\nupdate : Msg -> Model -> (Model, Cmd msg)\r\nupdate msg () =\r\n    case msg of\r\n        Log ->\r\n            ((), log ())\r\n\r\n\r\nview : Model -> Html Msg\r\nview model =\r\n    button [ onClick Log ] [ text \"Port with ()\" ] \r\n\r\n\r\nmain : Program () Model Msg\r\nmain =\r\n    Browser.embed\r\n        { init = \\_ -> ((), Cmd.none)\r\n        , view = view\r\n        , update = update\r\n        , subscriptions = \\_ -> Sub.none\r\n        }\r\n\r\n```\r\n\r\n#### index.html\r\n```html\r\n<html>\r\n  <head></head>\r\n  <body>\r\n    <main></main>\r\n    <script src=\"/elm.js\"></script>\r\n    <script>\r\n      var app = Elm.Main.embed(document.querySelector('main'));\r\n      app.ports.log.subscribe(function() { console.log(\"Port with () called\"); });\r\n    </script>\r\n  </body>\r\n</html>\r\n```\r\n\r\nSSCCE In [ellie](https://19.ellie-app.com/k2wcC27Xnxa1)\r\n "}}
{"actor":{"display_login":"danmarcab"}}