{"id":20303952,"url":"https://github.com/billstclair/elm-default-in-port-record","last_synced_at":"2026-05-13T02:13:24.601Z","repository":{"id":43613224,"uuid":"71519172","full_name":"billstclair/elm-default-in-port-record","owner":"billstclair","description":"Reproduce an Elm compiler bug","archived":false,"fork":false,"pushed_at":"2016-10-21T01:45:59.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-20T10:52:53.412Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/billstclair.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-21T01:40:43.000Z","updated_at":"2016-10-21T01:41:16.000Z","dependencies_parsed_at":"2022-09-13T11:21:37.999Z","dependency_job_id":null,"html_url":"https://github.com/billstclair/elm-default-in-port-record","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/billstclair/elm-default-in-port-record","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billstclair%2Felm-default-in-port-record","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billstclair%2Felm-default-in-port-record/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billstclair%2Felm-default-in-port-record/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billstclair%2Felm-default-in-port-record/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/billstclair","download_url":"https://codeload.github.com/billstclair/elm-default-in-port-record/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billstclair%2Felm-default-in-port-record/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32964486,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T23:30:32.555Z","status":"online","status_checked_at":"2026-05-13T02:00:07.132Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T16:41:52.862Z","updated_at":"2026-05-13T02:13:24.585Z","avatar_url":"https://github.com/billstclair.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"Elm version 0.17.1\u003cbr/\u003e\nmacOS Sierra version 10.12\u003cbr/\u003e\nOpera 40.0.2308.81\n\n\nThis project is for elucidation of an Elm compiler bug. I reported it in the elm-compiler project as [issue #1510](https://github.com/elm-lang/elm-compiler/issues/1510).\n\nBuild index.js with:\n\n```\nelm make default-in-port-record.elm --output index.js\n```\n\nThen open ```index.html``` in your browser.\n\nCick the \"Click Me\" button once. Note that the \"default\" value increments.\n\nRefresh your browser. You'll get a JavaScript runtime error in the function ```initWithFlags``` in index.js.\n\nThe problem is that \"default\" is a reserved word in JavaScript. The compiler correctly escapes it by prepending a \"$\" in most of the code, e.g. here's the compiler output for the ```update``` function:\n\n```\nvar _user$project$Main$update = F2(\n\tfunction (msg, model) {\n\t\tvar _p0 = msg;\n\t\treturn {\n\t\t\tctor: '_Tuple2',\n\t\t\t_0: _elm_lang$core$Native_Utils.update(\n\t\t\t\tmodel,\n\t\t\t\t{$default: model.$default + 1}),\n\t\t\t_1: _elm_lang$core$Platform_Cmd$none\n\t\t};\n\t});\n```\n\nThe compiler does _not_ properly escape it, however in the code the converts it from Elm to JavaScript for saving (when you click the \"Click Me\" button and ```updateWithStorage``` invokes the ```setStorage``` port):\n\n```\nvar _user$project$Main$setStorage = _elm_lang$core$Native_Platform.outgoingPort(\n\t'setStorage',\n\tfunction (v) {\n\t\treturn {default: v.default};\n\t});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbillstclair%2Felm-default-in-port-record","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbillstclair%2Felm-default-in-port-record","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbillstclair%2Felm-default-in-port-record/lists"}