{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/28174","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/28174/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/28174/comments","events_url":"https://api.github.com/repos/golang/go/issues/28174/events","html_url":"https://github.com/golang/go/issues/28174","id":369502940,"node_id":"MDU6SXNzdWUzNjk1MDI5NDA=","number":28174,"title":"syscall/js: zero Value is interpreted as NaN instead of Undefined","user":{"login":"dennwc","id":676724,"node_id":"MDQ6VXNlcjY3NjcyNA==","avatar_url":"https://avatars3.githubusercontent.com/u/676724?v=4","gravatar_id":"","url":"https://api.github.com/users/dennwc","html_url":"https://github.com/dennwc","followers_url":"https://api.github.com/users/dennwc/followers","following_url":"https://api.github.com/users/dennwc/following{/other_user}","gists_url":"https://api.github.com/users/dennwc/gists{/gist_id}","starred_url":"https://api.github.com/users/dennwc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dennwc/subscriptions","organizations_url":"https://api.github.com/users/dennwc/orgs","repos_url":"https://api.github.com/users/dennwc/repos","events_url":"https://api.github.com/users/dennwc/events{/privacy}","received_events_url":"https://api.github.com/users/dennwc/received_events","type":"User","site_admin":false},"labels":[{"id":943041965,"node_id":"MDU6TGFiZWw5NDMwNDE5NjU=","url":"https://api.github.com/repos/golang/go/labels/Arch-Wasm","name":"Arch-Wasm","color":"5319e7","default":false},{"id":373402289,"node_id":"MDU6TGFiZWwzNzM0MDIyODk=","url":"https://api.github.com/repos/golang/go/labels/NeedsInvestigation","name":"NeedsInvestigation","color":"ededed","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/6","html_url":"https://github.com/golang/go/milestone/6","labels_url":"https://api.github.com/repos/golang/go/milestones/6/labels","id":1055141,"node_id":"MDk6TWlsZXN0b25lMTA1NTE0MQ==","number":6,"title":"Unplanned","description":"No plan to fix in any specific release.\r\n","creator":{"login":"rsc","id":104030,"node_id":"MDQ6VXNlcjEwNDAzMA==","avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"open_issues":1775,"closed_issues":1226,"state":"open","created_at":"2015-04-06T20:47:19Z","updated_at":"2018-10-12T18:51:16Z","due_on":"2099-12-31T08:00:00Z","closed_at":null},"comments":1,"created_at":"2018-10-12T10:59:41Z","updated_at":"2018-10-12T18:51:15Z","closed_at":"2018-10-12T18:51:15Z","author_association":"NONE","body":"### What version of Go are you using (`go version`)?\r\n```\r\ngo version go1.11.1 linux/amd64\r\n```\r\n\r\n### Does this issue reproduce with the latest release?\r\nYes (same on `tip`)\r\n\r\n### What operating system and processor architecture are you using (`go env`)?\r\n```\r\nGOOS=js\r\nGOARCH=wasm\r\n```\r\n\r\n### What did you do?\r\n```golang\r\nvar v js.Value\r\nfmt.Println(v == js.Undefined())\r\n```\r\n\r\n### What did you expect to see?\r\n```\r\ntrue\r\n```\r\n\r\n### What did you see instead?\r\n```\r\nfalse\r\n```\r\n\r\n### Description\r\n\r\nCurrently, `ref` type codes of JS values in `wasm` are arranged in a way that makes a zero value a `NaN` number instead of `undefined`.\r\n\r\nThis breaks established Go semantics where a zero pointer value of a type is assumed to have a `nil` value (JS default value is `undefined`).\r\n\r\nTo illustrate the difference, consider the case:\r\n```golang\r\nvar a *Obj // a == nil\r\n\r\nvar m map[string]*Obj\r\nb := m[\"non existent\"] // b == nil\r\n\r\na == b // true\r\n```\r\n\r\nHowever, this code does not work in the current implementation:\r\n\r\n```golang\r\nvar a js.Value // NaN !\r\n\r\nm := js.Global()\r\nb := m.Get(\"non existent\") // undefined\r\n\r\na == b // false !\r\n```\r\n\r\n### Proposed solution\r\n\r\nRemap JS value type enum to list `undefined` as a first type code (`= 0`) and move `NaN` to a different type code.\r\n\r\nCC @neelance "},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/429424492","html_url":"https://github.com/golang/go/issues/28174#issuecomment-429424492","issue_url":"https://api.github.com/repos/golang/go/issues/28174","id":429424492,"node_id":"MDEyOklzc3VlQ29tbWVudDQyOTQyNDQ5Mg==","user":{"login":"cherrymui","id":14119929,"node_id":"MDQ6VXNlcjE0MTE5OTI5","avatar_url":"https://avatars2.githubusercontent.com/u/14119929?v=4","gravatar_id":"","url":"https://api.github.com/users/cherrymui","html_url":"https://github.com/cherrymui","followers_url":"https://api.github.com/users/cherrymui/followers","following_url":"https://api.github.com/users/cherrymui/following{/other_user}","gists_url":"https://api.github.com/users/cherrymui/gists{/gist_id}","starred_url":"https://api.github.com/users/cherrymui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cherrymui/subscriptions","organizations_url":"https://api.github.com/users/cherrymui/orgs","repos_url":"https://api.github.com/users/cherrymui/repos","events_url":"https://api.github.com/users/cherrymui/events{/privacy}","received_events_url":"https://api.github.com/users/cherrymui/received_events","type":"User","site_admin":false},"created_at":"2018-10-12T18:51:15Z","updated_at":"2018-10-12T18:51:15Z","author_association":"CONTRIBUTOR","body":"See #27592. Closing this as a dup."}}
{"actor":{"display_login":"cherrymui"}}