{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/27231","repository_url":"https://api.github.com/repos/dart-lang/sdk","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/27231/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/27231/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/27231/events","html_url":"https://github.com/dart-lang/sdk/issues/27231","id":174845103,"number":27231,"title":"Non-nullable type annotation syntax","user":{"login":"munificent","id":46275,"avatar_url":"https://avatars.githubusercontent.com/u/46275?v=3","gravatar_id":"","url":"https://api.github.com/users/munificent","html_url":"https://github.com/munificent","followers_url":"https://api.github.com/users/munificent/followers","following_url":"https://api.github.com/users/munificent/following{/other_user}","gists_url":"https://api.github.com/users/munificent/gists{/gist_id}","starred_url":"https://api.github.com/users/munificent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/munificent/subscriptions","organizations_url":"https://api.github.com/users/munificent/orgs","repos_url":"https://api.github.com/users/munificent/repos","events_url":"https://api.github.com/users/munificent/events{/privacy}","received_events_url":"https://api.github.com/users/munificent/received_events","type":"User","site_admin":false},"labels":[{"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/area-dart2js","name":"area-dart2js","color":"c7def8"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/area-dev-compiler","name":"area-dev-compiler","color":"c7def8"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/area-language","name":"area-language","color":"c7def8"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/area-vm","name":"area-vm","color":"c7def8"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/Type:%20enhancement","name":"Type: enhancement","color":"ededed"},{"url":"https://api.github.com/repos/dart-lang/sdk/labels/Type:%20meta","name":"Type: meta","color":"009800"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":72,"created_at":"2016-09-02T20:49:22Z","updated_at":"2016-09-24T15:48:58Z","closed_at":null,"body":"We on the language team would like to start experimenting with adding [non-nullable types][nnbd] to the type system. We are not yet 100% certain that they are going to work out, but we want to try an implementation and convert some libraries to see. To that end, we need some syntax.\r\n\r\n[nnbd]: https://github.com/dart-lang/dart_enhancement_proposals/issues/30\r\n\r\nThe VM, dart2js, and DDC can parse the syntax and ignore it. For analyzer, we'd like the new syntax stored in the AST so we can start hanging the type rules off it. dartfmt will, of course, need to format and preserve it.\r\n\r\n# Syntax\r\n\r\nWe are going to see if the feature is expressive enough with just one bit of syntax: a postfix `?` after a type annotation. The grammar changes are:\r\n\r\n```\r\ntype:\r\n  typeName typeArguments? ‘?’?\r\n  ;\r\n\r\nnormalFormalParameter:\r\n  functionSignature ‘?’? |\r\n  fieldFormalParameter |\r\n  simpleFormalParameter\r\n  ;\r\n```\r\n\r\nBecause of `is`, `?:`, and `.?`, it's a little tricky inserting this into the grammar. But, as far as I can tell so far, there's no real ambiguity. Some cases we've discussed:\r\n\r\n```dart\r\nString?.runtimeType\r\n```\r\n\r\nThis is a null-aware call on the String class. We are not extending class literals to support the nullable postfix `?`. You can't do just `MyClass?` as an expression.\r\n\r\n```dart\r\na is String?.runtimeType\r\n```\r\n\r\nThis is an error today and will be with the new syntax. A type test isn't a valid LHS for null-aware operator call or a regular method call. You would have to explicitly do `(a is String)?.runtimeType` or `(a is String?).runtimeType`.\r\n\r\n```dart\r\n\"str\" is String ? (some + arbitrarily + long + expression ...) : \"not string\";\r\n```\r\n\r\nThis may require arbitrary lookahead to disambiguate the `?` but speculatively assuming it is for `?:` will almost always be right since you can't call a boolean anyway.\r\n\r\nThat being said, we are in slightly dangerous waters here, which is why we'd like to start experimentally parsing the syntax to see if we run into real trouble. If we do, one simple option is to disallow `?` in the RHS of an `is` operator. But for, now we would like to try allowing it.\r\n\r\n# Semantics\r\n\r\nFor this phase, there are none. We will work directly with the strong mode folks when it comes to experimenting with the actual static checking after this is done and implementations won't barf on users who try the syntax.\r\n\r\n# Flag\r\n\r\nWhile this is being implemented, to ensure we don't expose users to inconsistency in our tools, it should be put behind a flag named `nnbd`.\r\n\r\n# Tracking issues\r\n\r\n- [x] Analyzer (#27232)\r\n- [ ] dart2js (#27232)\r\n- [ ] dev_compiler(#27234)\r\n- [ ] Formatter (https://github.com/dart-lang/dart_style/issues/536)\r\n- [ ] Specification (#27235)\r\n- [ ] VM (#27236)\r\n- [ ] IntelliJ-plugin (#27237)"},"comment":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/comments/249371591","html_url":"https://github.com/dart-lang/sdk/issues/27231#issuecomment-249371591","issue_url":"https://api.github.com/repos/dart-lang/sdk/issues/27231","id":249371591,"user":{"login":"tatumizer","id":778217,"avatar_url":"https://avatars.githubusercontent.com/u/778217?v=3","gravatar_id":"","url":"https://api.github.com/users/tatumizer","html_url":"https://github.com/tatumizer","followers_url":"https://api.github.com/users/tatumizer/followers","following_url":"https://api.github.com/users/tatumizer/following{/other_user}","gists_url":"https://api.github.com/users/tatumizer/gists{/gist_id}","starred_url":"https://api.github.com/users/tatumizer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tatumizer/subscriptions","organizations_url":"https://api.github.com/users/tatumizer/orgs","repos_url":"https://api.github.com/users/tatumizer/repos","events_url":"https://api.github.com/users/tatumizer/events{/privacy}","received_events_url":"https://api.github.com/users/tatumizer/received_events","type":"User","site_admin":false},"created_at":"2016-09-24T15:48:58Z","updated_at":"2016-09-24T15:48:58Z","body":"> It's still an error in checked mode because boolean conversion is defined to explicitly check for not being a bool.\r\n\r\nTypo: ... for not being a **null** (sorry for nitpicking)\r\n"}}
{"actor":{"display_login":"tatumizer"}}