{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/32847","repository_url":"https://api.github.com/repos/dart-lang/sdk","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/32847/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/32847/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/32847/events","html_url":"https://github.com/dart-lang/sdk/issues/32847","id":313441148,"number":32847,"title":"frontend type inference emits \"UnknownType\" instead of DynamicType","user":{"login":"sigmundch","id":2049220,"avatar_url":"https://avatars3.githubusercontent.com/u/2049220?v=4","gravatar_id":"","url":"https://api.github.com/users/sigmundch","html_url":"https://github.com/sigmundch","followers_url":"https://api.github.com/users/sigmundch/followers","following_url":"https://api.github.com/users/sigmundch/following{/other_user}","gists_url":"https://api.github.com/users/sigmundch/gists{/gist_id}","starred_url":"https://api.github.com/users/sigmundch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sigmundch/subscriptions","organizations_url":"https://api.github.com/users/sigmundch/orgs","repos_url":"https://api.github.com/users/sigmundch/repos","events_url":"https://api.github.com/users/sigmundch/events{/privacy}","received_events_url":"https://api.github.com/users/sigmundch/received_events","type":"User","site_admin":false},"labels":[{"id":746988267,"url":"https://api.github.com/repos/dart-lang/sdk/labels/Customer-dart2js","name":"Customer-dart2js","color":"006b75","default":false},{"id":219928158,"url":"https://api.github.com/repos/dart-lang/sdk/labels/P1%20high","name":"P1 high","color":"eb6420","default":false},{"id":524536392,"url":"https://api.github.com/repos/dart-lang/sdk/labels/area-front-end","name":"area-front-end","color":"c5def5","default":false}],"state":"open","locked":false,"assignee":{"login":"kmillikin","id":1971137,"avatar_url":"https://avatars0.githubusercontent.com/u/1971137?v=4","gravatar_id":"","url":"https://api.github.com/users/kmillikin","html_url":"https://github.com/kmillikin","followers_url":"https://api.github.com/users/kmillikin/followers","following_url":"https://api.github.com/users/kmillikin/following{/other_user}","gists_url":"https://api.github.com/users/kmillikin/gists{/gist_id}","starred_url":"https://api.github.com/users/kmillikin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmillikin/subscriptions","organizations_url":"https://api.github.com/users/kmillikin/orgs","repos_url":"https://api.github.com/users/kmillikin/repos","events_url":"https://api.github.com/users/kmillikin/events{/privacy}","received_events_url":"https://api.github.com/users/kmillikin/received_events","type":"User","site_admin":false},"assignees":[{"login":"kmillikin","id":1971137,"avatar_url":"https://avatars0.githubusercontent.com/u/1971137?v=4","gravatar_id":"","url":"https://api.github.com/users/kmillikin","html_url":"https://github.com/kmillikin","followers_url":"https://api.github.com/users/kmillikin/followers","following_url":"https://api.github.com/users/kmillikin/following{/other_user}","gists_url":"https://api.github.com/users/kmillikin/gists{/gist_id}","starred_url":"https://api.github.com/users/kmillikin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmillikin/subscriptions","organizations_url":"https://api.github.com/users/kmillikin/orgs","repos_url":"https://api.github.com/users/kmillikin/repos","events_url":"https://api.github.com/users/kmillikin/events{/privacy}","received_events_url":"https://api.github.com/users/kmillikin/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/dart-lang/sdk/milestones/54","html_url":"https://github.com/dart-lang/sdk/milestone/54","labels_url":"https://api.github.com/repos/dart-lang/sdk/milestones/54/labels","id":3190923,"number":54,"title":"Dart2Beta4","description":"","creator":{"login":"JekCharlsonYu","id":35309828,"avatar_url":"https://avatars3.githubusercontent.com/u/35309828?v=4","gravatar_id":"","url":"https://api.github.com/users/JekCharlsonYu","html_url":"https://github.com/JekCharlsonYu","followers_url":"https://api.github.com/users/JekCharlsonYu/followers","following_url":"https://api.github.com/users/JekCharlsonYu/following{/other_user}","gists_url":"https://api.github.com/users/JekCharlsonYu/gists{/gist_id}","starred_url":"https://api.github.com/users/JekCharlsonYu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JekCharlsonYu/subscriptions","organizations_url":"https://api.github.com/users/JekCharlsonYu/orgs","repos_url":"https://api.github.com/users/JekCharlsonYu/repos","events_url":"https://api.github.com/users/JekCharlsonYu/events{/privacy}","received_events_url":"https://api.github.com/users/JekCharlsonYu/received_events","type":"User","site_admin":false},"open_issues":59,"closed_issues":14,"state":"open","created_at":"2018-03-15T15:50:07Z","updated_at":"2018-04-17T12:24:47Z","due_on":"2018-05-15T07:00:00Z","closed_at":null},"comments":0,"created_at":"2018-04-11T18:39:21Z","updated_at":"2018-04-17T15:55:01Z","closed_at":null,"author_association":"MEMBER","body":"Consider this example:\r\n\r\n```dart\r\nfoo<T>(Iterable<T> Function(int) f) {}\r\n\r\nmain() {\r\n  foo((int x) => (x > 1) ? [] : [1, 2].map((e) => 1));\r\n\r\n  foo((int x) {\r\n    if (x > 1) {\r\n      return [];\r\n    } else {\r\n      return [1, 2].map((e) => e);\r\n    }\r\n  });\r\n}\r\n```\r\n\r\nIt appears that type inference correctly infers that the first closure return an `Iterable<dynamic>`, but it doesn't infer the same thing for the second closure. Instead it generates `Iterable<UnknownType>`. This causes failures down the line (we noticed the failure also as a crash in the dart2js backend).\r\n\r\nHere is the output from dumping the IR with fasta-compile:\r\n\r\n```\r\n> pkg/front_end/tool/fasta compile --strong --dump-ir m.dart                                                                                          \r\nstatic method foo<T extends core::Object>((core::int) → core::Iterable<self::foo::T> f) → dynamic {}\r\nstatic method main() → dynamic {                                                     \r\n  self::foo<dynamic>((core::int x) → core::Iterable<dynamic> => (x.{core::num::>}(1) ?{core::Object} <dynamic>[] : <core::int>[1, 2].{core::Iterable::map}<c\r\nore::int>((core::int e) → core::int => 1)) as{TypeError} core::Iterable<dynamic>);\r\n  self::foo<dynamic>((core::int x) → core::Iterable<<UnknownType>> {                \r\n    if(x.{core::num::>}(1)) {                                                      \r\n      return <dynamic>[];                              \r\n    }                                                                            \r\n    else {                                                              \r\n      return <core::int>[1, 2].{core::Iterable::map}<core::int>((core::int e) → core::int => e);\r\n    }                                                                                    \r\n  });                                                                             \r\n}                        \r\n                                                                                                                                       \r\nUnhandled exception:     \r\nUnsupported operation: serialization of generic DartTypes                                                                                      \r\n#0      BinaryPrinter.defaultDartType (package:kernel/binary/ast_to_binary.dart:1745:5)\r\n#1      UnknownType.accept (package:front_end/src/fasta/type_inference/type_schema.dart:72:16)                                                           \r\n#2      BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229:10)                                  \r\n#3      BinaryPrinter.writeNodeList (package:kernel/binary/ast_to_binary.dart:221:7)\r\n#4      BinaryPrinter.visitInterfaceType (package:kernel/binary/ast_to_binary.dart:1644:7)\r\n#5      InterfaceType.accept (package:kernel/ast.dart:4883:34)\r\n#6      BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229:10)              \r\n#7      BinaryPrinter.visitFunctionNode (package:kernel/binary/ast_to_binary.dart:949:5)         \r\n#8      FunctionNode.accept (package:kernel/ast.dart:1991:30)                                                                        \r\n#9      BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229:10)                                          \r\n#10     BinaryPrinter.visitFunctionExpression (package:kernel/binary/ast_to_binary.dart:1308:5)\r\n#11     FunctionExpression.accept (package:kernel/ast.dart:3510:36)                                                                 \r\n#12     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229:10)\r\n#13     BinaryPrinter.writeNodeList (package:kernel/binary/ast_to_binary.dart:221:7)                             \r\n#14     BinaryPrinter.visitArguments (package:kernel/binary/ast_to_binary.dart:1125:5)            \r\n#15     Arguments.accept (package:kernel/ast.dart:2686:30)                                         \r\n#16     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229:10)                        \r\n#17     BinaryPrinter.visitStaticInvocation (package:kernel/binary/ast_to_binary.dart:1108:5\r\n...\r\n```\r\n\r\n@kmillikin - can someone on the FE side take a look?"},"comment":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/comments/382045255","html_url":"https://github.com/dart-lang/sdk/issues/32847#issuecomment-382045255","issue_url":"https://api.github.com/repos/dart-lang/sdk/issues/32847","id":382045255,"user":{"login":"kmillikin","id":1971137,"avatar_url":"https://avatars0.githubusercontent.com/u/1971137?v=4","gravatar_id":"","url":"https://api.github.com/users/kmillikin","html_url":"https://github.com/kmillikin","followers_url":"https://api.github.com/users/kmillikin/followers","following_url":"https://api.github.com/users/kmillikin/following{/other_user}","gists_url":"https://api.github.com/users/kmillikin/gists{/gist_id}","starred_url":"https://api.github.com/users/kmillikin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmillikin/subscriptions","organizations_url":"https://api.github.com/users/kmillikin/orgs","repos_url":"https://api.github.com/users/kmillikin/repos","events_url":"https://api.github.com/users/kmillikin/events{/privacy}","received_events_url":"https://api.github.com/users/kmillikin/received_events","type":"User","site_admin":false},"created_at":"2018-04-17T15:55:01Z","updated_at":"2018-04-17T15:55:01Z","author_association":"MEMBER","body":"Yes, I'll take a look.  `UnknownType` should not survive type inference."}}
{"actor":{"display_login":"kmillikin"}}