{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/23244","repository_url":"https://api.github.com/repos/dart-lang/sdk","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/23244/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/23244/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/23244/events","html_url":"https://github.com/dart-lang/sdk/issues/23244","id":84601279,"number":23244,"title":"Enums aren't canonicalized when sent over a port in a compound object","user":{"login":"peter-ahe-google","id":5689005,"avatar_url":"https://avatars.githubusercontent.com/u/5689005?v=3","gravatar_id":"","url":"https://api.github.com/users/peter-ahe-google","html_url":"https://github.com/peter-ahe-google","followers_url":"https://api.github.com/users/peter-ahe-google/followers","following_url":"https://api.github.com/users/peter-ahe-google/following{/other_user}","gists_url":"https://api.github.com/users/peter-ahe-google/gists{/gist_id}","starred_url":"https://api.github.com/users/peter-ahe-google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peter-ahe-google/subscriptions","organizations_url":"https://api.github.com/users/peter-ahe-google/orgs","repos_url":"https://api.github.com/users/peter-ahe-google/repos","events_url":"https://api.github.com/users/peter-ahe-google/events{/privacy}","received_events_url":"https://api.github.com/users/peter-ahe-google/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dart-lang/sdk/labels/area-dart2js","name":"area-dart2js","color":"c7def8"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/area-dartium","name":"area-dartium","color":"c7def8"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/C9","name":"C9","color":"ededed"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/Type:%20bug","name":"Type: bug","color":"ededed"}],"state":"open","locked":false,"assignee":{"login":"rakudrama","id":2108821,"avatar_url":"https://avatars.githubusercontent.com/u/2108821?v=3","gravatar_id":"","url":"https://api.github.com/users/rakudrama","html_url":"https://github.com/rakudrama","followers_url":"https://api.github.com/users/rakudrama/followers","following_url":"https://api.github.com/users/rakudrama/following{/other_user}","gists_url":"https://api.github.com/users/rakudrama/gists{/gist_id}","starred_url":"https://api.github.com/users/rakudrama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rakudrama/subscriptions","organizations_url":"https://api.github.com/users/rakudrama/orgs","repos_url":"https://api.github.com/users/rakudrama/repos","events_url":"https://api.github.com/users/rakudrama/events{/privacy}","received_events_url":"https://api.github.com/users/rakudrama/received_events","type":"User","site_admin":false},"assignees":[{"login":"rakudrama","id":2108821,"avatar_url":"https://avatars.githubusercontent.com/u/2108821?v=3","gravatar_id":"","url":"https://api.github.com/users/rakudrama","html_url":"https://github.com/rakudrama","followers_url":"https://api.github.com/users/rakudrama/followers","following_url":"https://api.github.com/users/rakudrama/following{/other_user}","gists_url":"https://api.github.com/users/rakudrama/gists{/gist_id}","starred_url":"https://api.github.com/users/rakudrama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rakudrama/subscriptions","organizations_url":"https://api.github.com/users/rakudrama/orgs","repos_url":"https://api.github.com/users/rakudrama/repos","events_url":"https://api.github.com/users/rakudrama/events{/privacy}","received_events_url":"https://api.github.com/users/rakudrama/received_events","type":"User","site_admin":false}],"milestone":null,"comments":20,"created_at":"2015-04-17T07:24:19Z","updated_at":"2016-08-01T15:01:15Z","closed_at":null,"body":"When sending an enum constant directly on a port, the enum constant is canonicalized correctly in the receiving isolate. However, if the enum constant is part of an object, for example, a list or a user-defined class, the enum object isn't canonicalized in the receiving isolate.\n\nimport 'dart:async';\nimport 'dart:isolate';\n\nenum Fisk {\n&nbsp;&nbsp;torsk,\n}\n\nisolate1(SendPort port) {\n&nbsp;&nbsp;port.send(Fisk.torsk);\n}\n\nisolate2(SendPort port) {\n&nbsp;&nbsp;port.send([Fisk.torsk]);\n}\n\nmain() async {\n&nbsp;&nbsp;var port = new ReceivePort();\n&nbsp;&nbsp;await Isolate.spawn(isolate1, port.sendPort);\n&nbsp;&nbsp;Completer completer = new Completer();\n&nbsp;&nbsp;port.listen((message) {\n&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;Received $message&quot;);\n&nbsp;&nbsp;&nbsp;&nbsp;port.close();\n&nbsp;&nbsp;&nbsp;&nbsp;expectTorsk(message);\n&nbsp;&nbsp;&nbsp;&nbsp;completer.complete();\n&nbsp;&nbsp;});\n&nbsp;&nbsp;await completer.future;\n&nbsp;&nbsp;port = new ReceivePort();\n&nbsp;&nbsp;await Isolate.spawn(isolate2, port.sendPort);\n&nbsp;&nbsp;port.listen((message) {\n&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;Received $message&quot;);\n&nbsp;&nbsp;&nbsp;&nbsp;port.close();\n&nbsp;&nbsp;&nbsp;&nbsp;expectTorsk(message[0]);\n&nbsp;&nbsp;});\n}\n\nexpectTorsk(Fisk fisk) {\n&nbsp;&nbsp;if (fisk != Fisk.torsk) {\n&nbsp;&nbsp;&nbsp;&nbsp;throw &quot;$fisk isn't a ${Fisk.torsk}&quot;;\n&nbsp;&nbsp;}\n}\n"},"comment":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/comments/236606789","html_url":"https://github.com/dart-lang/sdk/issues/23244#issuecomment-236606789","issue_url":"https://api.github.com/repos/dart-lang/sdk/issues/23244","id":236606789,"user":{"login":"lrhn","id":4865287,"avatar_url":"https://avatars.githubusercontent.com/u/4865287?v=3","gravatar_id":"","url":"https://api.github.com/users/lrhn","html_url":"https://github.com/lrhn","followers_url":"https://api.github.com/users/lrhn/followers","following_url":"https://api.github.com/users/lrhn/following{/other_user}","gists_url":"https://api.github.com/users/lrhn/gists{/gist_id}","starred_url":"https://api.github.com/users/lrhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrhn/subscriptions","organizations_url":"https://api.github.com/users/lrhn/orgs","repos_url":"https://api.github.com/users/lrhn/repos","events_url":"https://api.github.com/users/lrhn/events{/privacy}","received_events_url":"https://api.github.com/users/lrhn/received_events","type":"User","site_admin":false},"created_at":"2016-08-01T15:01:15Z","updated_at":"2016-08-01T15:01:15Z","body":"I agree that copying objects without calling a constructor is basically broken. There are already problems with hash-based collections (because cloned objects doesn't necessarily have the same hash code as the original) and with any object that has invariants or external state (e.g., using expandos).\r\n\r\nIt would be safer to restrict to only sending \"value objects\" (which we don't have, so some approximation). JSON-encodable data plus capabilities can be sent to any isolate, so this is only about which other values can be sent to `spawn`-created isolates. Restricting that to static functions and enums would probably handle most cases. You have to encode your object to List/Map/primitive data, but you also avoid accidentally sending a large chunk of data that your object is pointing to internally.\r\n\r\nOn the other hand, isolate communication is already hard enough, so do we want to make it harder?"}}
{"actor":{"display_login":"lrhn"}}