{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/angular/issues/1494","repository_url":"https://api.github.com/repos/dart-lang/angular","labels_url":"https://api.github.com/repos/dart-lang/angular/issues/1494/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/angular/issues/1494/comments","events_url":"https://api.github.com/repos/dart-lang/angular/issues/1494/events","html_url":"https://github.com/dart-lang/angular/issues/1494","id":341681706,"node_id":"MDU6SXNzdWUzNDE2ODE3MDY=","number":1494,"title":"Improve and facilitate error reporting for annotations","user":{"login":"leonsenft","id":1916163,"node_id":"MDQ6VXNlcjE5MTYxNjM=","avatar_url":"https://avatars0.githubusercontent.com/u/1916163?v=4","gravatar_id":"","url":"https://api.github.com/users/leonsenft","html_url":"https://github.com/leonsenft","followers_url":"https://api.github.com/users/leonsenft/followers","following_url":"https://api.github.com/users/leonsenft/following{/other_user}","gists_url":"https://api.github.com/users/leonsenft/gists{/gist_id}","starred_url":"https://api.github.com/users/leonsenft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonsenft/subscriptions","organizations_url":"https://api.github.com/users/leonsenft/orgs","repos_url":"https://api.github.com/users/leonsenft/repos","events_url":"https://api.github.com/users/leonsenft/events{/privacy}","received_events_url":"https://api.github.com/users/leonsenft/received_events","type":"User","site_admin":false},"labels":[{"id":623415559,"node_id":"MDU6TGFiZWw2MjM0MTU1NTk=","url":"https://api.github.com/repos/dart-lang/angular/labels/%E2%9B%B9%20feedback:%20discussion","name":"⛹ feedback: discussion","color":"cc317c","default":false},{"id":833520139,"node_id":"MDU6TGFiZWw4MzM1MjAxMzk=","url":"https://api.github.com/repos/dart-lang/angular/labels/%E2%9C%89%20dependency:%20analyzer","name":"✉ dependency: analyzer","color":"fcbfdc","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-07-16T21:14:58Z","updated_at":"2018-08-09T22:09:06Z","closed_at":"2018-08-09T22:09:06Z","author_association":"CONTRIBUTOR","body":"When validating constant values obtained from analysis of annotations, it's difficult to provide any relevant context in our warning and error messages.\r\n\r\nFor example, today if you have an invalid template, you'll get a messages like the following:\r\n\r\n```\r\nline 1, column 6 of AppComponent: ParseErrorLevel.FATAL: Can't bind to 'foo'\r\nsince it isn't a known native property or known directive. Please fix typo or\r\nadd to directives list.\r\n\r\n<div [foo]=\"bar\"></div>\r\n     ^^^^^^^^^^^\r\n```\r\n\r\nWe even have source information from the analyzer for *some* Dart source:\r\n\r\n```\r\nline 9, column 15 of package:.../app_component.dart: @HostListener\r\nmust be on a non-static member\r\n  static void foo(int yes) {}\r\n              ^^^\r\n```\r\n\r\nWhere we don't have access to such source information is when dealing with constant values obtained from annotations.\r\n\r\nFor example, the following use of `Typed` is invalid.\r\n\r\n```dart\r\n@Component(\r\n  ...\r\n  directiveTypes: [\r\n    Typed<List>.of([12]),\r\n  ],\r\n)\r\nclass AppComponent {}\r\n```\r\n\r\nThis currently produces the following error, sans context.\r\n\r\n```\r\nExpected a type argument of \"Typed\" to be of one of the following\r\ntypes:\r\n  * \"Symbol\"\r\n  * \"Type\"\r\n  * \"Typed\"\r\nGo an expression of the type \"int\".\r\n```\r\n\r\nIdeally we could augment this message with the following contextual source information.\r\n\r\n```\r\nline X, column Y of package:Z: Expected a type argument... (continued)\r\n    Typed<List>.of([12]),\r\n                    ^^\r\n```\r\n\r\nUnfortunately, the finest granularity of source information we get from Dart analyzer APIs is the annotation AST itself.\r\n\r\nWe could retain a reference to the source annotation, walk its AST as we compute the constant value, and use offsets to compute source information, but this solution is highly error prone.\r\n\r\nIdeally the analyzer APIs themselves could offer better support for this task, and if not, perhaps such functionality could be encapsulated in a standalone package or incorporated into source_gen."},"comment":{"url":"https://api.github.com/repos/dart-lang/angular/issues/comments/411913913","html_url":"https://github.com/dart-lang/angular/issues/1494#issuecomment-411913913","issue_url":"https://api.github.com/repos/dart-lang/angular/issues/1494","id":411913913,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMTkxMzkxMw==","user":{"login":"leonsenft","id":1916163,"node_id":"MDQ6VXNlcjE5MTYxNjM=","avatar_url":"https://avatars0.githubusercontent.com/u/1916163?v=4","gravatar_id":"","url":"https://api.github.com/users/leonsenft","html_url":"https://github.com/leonsenft","followers_url":"https://api.github.com/users/leonsenft/followers","following_url":"https://api.github.com/users/leonsenft/following{/other_user}","gists_url":"https://api.github.com/users/leonsenft/gists{/gist_id}","starred_url":"https://api.github.com/users/leonsenft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonsenft/subscriptions","organizations_url":"https://api.github.com/users/leonsenft/orgs","repos_url":"https://api.github.com/users/leonsenft/repos","events_url":"https://api.github.com/users/leonsenft/events{/privacy}","received_events_url":"https://api.github.com/users/leonsenft/received_events","type":"User","site_admin":false},"created_at":"2018-08-09T22:09:06Z","updated_at":"2018-08-09T22:09:06Z","author_association":"CONTRIBUTOR","body":"We discussed offline and concluded this solution can't be well generalized, nor will a analyzer-driven solution be available anytime in the near future.\r\n\r\nWe'll revisit this discussion in the future if significant analyzer or framework changes can be made (in a future major release) to accommodate or eliminate this issue."}}
{"actor":{"display_login":"leonsenft"}}