{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/25096","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/25096/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/25096/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/25096/events","html_url":"https://github.com/dart-lang/sdk/issues/25096","id":120059838,"number":25096,"title":"Really confusing parser and analyzer output when you do \"Map<X, Y>{...}\"","user":{"login":"Hixie","id":551196,"avatar_url":"https://avatars.githubusercontent.com/u/551196?v=3","gravatar_id":"","url":"https://api.github.com/users/Hixie","html_url":"https://github.com/Hixie","followers_url":"https://api.github.com/users/Hixie/followers","following_url":"https://api.github.com/users/Hixie/following{/other_user}","gists_url":"https://api.github.com/users/Hixie/gists{/gist_id}","starred_url":"https://api.github.com/users/Hixie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hixie/subscriptions","organizations_url":"https://api.github.com/users/Hixie/orgs","repos_url":"https://api.github.com/users/Hixie/repos","events_url":"https://api.github.com/users/Hixie/events{/privacy}","received_events_url":"https://api.github.com/users/Hixie/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dart-lang/sdk/labels/analyzer-recovery","name":"analyzer-recovery","color":"d4c5f9"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/area-analyzer","name":"area-analyzer","color":"c7def8"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/Priority-Medium","name":"Priority-Medium","color":"fbca04"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/type-enhancement","name":"type-enhancement","color":"ededed"}],"state":"open","locked":false,"assignee":{"login":"bwilkerson","id":5840555,"avatar_url":"https://avatars.githubusercontent.com/u/5840555?v=3","gravatar_id":"","url":"https://api.github.com/users/bwilkerson","html_url":"https://github.com/bwilkerson","followers_url":"https://api.github.com/users/bwilkerson/followers","following_url":"https://api.github.com/users/bwilkerson/following{/other_user}","gists_url":"https://api.github.com/users/bwilkerson/gists{/gist_id}","starred_url":"https://api.github.com/users/bwilkerson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwilkerson/subscriptions","organizations_url":"https://api.github.com/users/bwilkerson/orgs","repos_url":"https://api.github.com/users/bwilkerson/repos","events_url":"https://api.github.com/users/bwilkerson/events{/privacy}","received_events_url":"https://api.github.com/users/bwilkerson/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-12-02T23:31:04Z","updated_at":"2015-12-03T17:22:25Z","closed_at":null,"body":"The following code, at first glance, doesn't seem wrong. Of course, it is, because Map literals are of the form `<...>{}`, not `Map<...>{}`. But, imagine being in the mindset where you think the code is right.\r\n\r\n```dart\r\nvoid test(Map map) { }\r\n\r\nvoid main() {\r\n  test(Map<String, String>{ '': '' });\r\n}\r\n```\r\n\r\nIn that mindset, the analyzer's output here is extremely confusing:\r\n\r\n```\r\nAnalyzing [test.dart]...\r\n[warning] 1 positional arguments expected, but 2 found (test.dart, line 5, col 7)\r\n[warning] The operator '<' is not defined for the class 'Type' (test.dart, line 5, col 11)\r\n[warning] The operator '>' is not defined for the class 'Type' (test.dart, line 5, col 26)\r\n3 errors found.\r\n```\r\n\r\nThe runtime output is not much better:\r\n```\r\nUnhandled exception:\r\nClass '_Type' has no instance method '<'.\r\n\r\nNoSuchMethodError: method not found: '<'\r\nReceiver: Type: class 'Map'\r\nArguments: [Type: class 'String']\r\n#0      Object._noSuchMethod (dart:core-patch/object_patch.dart:42)\r\n#1      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)\r\n#2      main (test.dart:5:11)\r\n#3      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)\r\n#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:150)\r\n```\r\n\r\nThe analyzer and the compiler both for some reason think the `<` is an operator, rather than being either the delimiter for the type parameter of the `Map` type, or the delimiter for the type parameter of the map literal.\r\n\r\nI would have expected an analyzer warning along the lines of \"Unexpected `{` after type `Map<String, String>`\". (Maybe, for bonus points, followed by \"If you meant to start a Map literal, do not include the word `Map` before the type parameters\".) "},"comment":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/comments/161722062","html_url":"https://github.com/dart-lang/sdk/issues/25096#issuecomment-161722062","issue_url":"https://api.github.com/repos/dart-lang/sdk/issues/25096","id":161722062,"user":{"login":"Hixie","id":551196,"avatar_url":"https://avatars.githubusercontent.com/u/551196?v=3","gravatar_id":"","url":"https://api.github.com/users/Hixie","html_url":"https://github.com/Hixie","followers_url":"https://api.github.com/users/Hixie/followers","following_url":"https://api.github.com/users/Hixie/following{/other_user}","gists_url":"https://api.github.com/users/Hixie/gists{/gist_id}","starred_url":"https://api.github.com/users/Hixie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hixie/subscriptions","organizations_url":"https://api.github.com/users/Hixie/orgs","repos_url":"https://api.github.com/users/Hixie/repos","events_url":"https://api.github.com/users/Hixie/events{/privacy}","received_events_url":"https://api.github.com/users/Hixie/received_events","type":"User","site_admin":false},"created_at":"2015-12-03T17:22:25Z","updated_at":"2015-12-03T17:22:25Z","body":"Oh, interesting, I hadn't noticed it could be parsed that way. Good point.\r\n\r\n```dart\r\nvoid test(Map map) { }\r\n\r\nvoid main() {\r\n  test(\r\n    Map < String,\r\n    String > { '': '' }\r\n  );\r\n}\r\n```\r\n\r\nI guess the analyzer could detect this, but yeah, if it's valid code, the compiler probably couldn't..."}}