ROFS. Recover an incomplete typedef as the new syntax.
With the `remove-old-function-syntax` feature enabled, a typedef without
`=` was always parsed as an old style typedef. An incomplete typedef got
a synthetic parameter list, which is old syntax that the feature
rejects, and errors for both the parameter list and the `;`, though
adding them doesn't fix the code:
typedef T
When a function followed, its name and parameters were taken as the
old style typedef, and reported as the old syntax:
typedef T
main() {}
Now, with the feature enabled:
- A typedef without `=` and without a parameter list after its name is
recovered as a new style typedef with a synthetic `=` and type.
- When the tokens after the type start another declaration, such as a
function, a getter, a setter, or a declaration keyword, the typedef
ends before them. The type is the name if it can be one, as `T` or
`T<U>`, otherwise it is the aliased type, and the name is missing.
- An incomplete typedef is one mistake, so it is reported once:
`missingTypedefParameters` at the name, or `missingIdentifier` when
the name is missing. The missing `;` is inserted without an error.
A typedef with a return type but no parameter list, as
`typedef int F;`, is still an old style typedef, because only it can
have the return type, but it also gets one error.
A complete old style typedef is still reported, and a library with an
earlier language version is parsed as before.
The partial code recovery tests of `typedef` before a function
declaration don't need `%before-language-feature` anymore. The
completion tests of doc comment references to a typedef used an
invalid typedef with a body, which is now parsed as a function, so
they use `;` instead. Completion at `n` in `typedef n` suggested types,
because `n` was the return type of an old style typedef; now it is the
name of the typedef, so there are no suggestions, as for other names
in declarations.
Bug: https://github.com/dart-lang/sdk/issues/65045
Change-Id: Id6b0e63ee984019ed8f627d63ffceecd5d03821a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/585180
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Dart is:
Approachable: Develop with a strongly typed programming language that is consistent, concise, and offers modern language features like null safety and patterns.
Portable: Compile to ARM, x64, or RISC-V machine code for mobile, desktop, and backend. Compile to JavaScript or WebAssembly for the web.
Productive: Make changes iteratively: use hot reload to see the result instantly in your running app. Diagnose app issues using DevTools.
Dart's flexible compiler technology lets you run Dart code in different ways, depending on your target platform and goals:
Dart Native: For programs targeting devices (mobile, desktop, server, and more), Dart Native includes both a Dart VM with JIT (just-in-time) compilation and an AOT (ahead-of-time) compiler for producing machine code.
Dart Web: For programs targeting the web, Dart Web includes both a development time compiler (dartdevc) and a production time compiler (dart2js).
Dart is free and open source.
See LICENSE and PATENT_GRANT.
Visit dart.dev to learn more about the language, tools, and to find codelabs.
Browse pub.dev for more packages and libraries contributed by the community and the Dart team.
Our API reference documentation is published at api.dart.dev, based on the stable release. (We also publish docs from our beta and dev channels, as well as from the primary development branch).
See the contribution guide for details.
If you want to build Dart yourself, here is a guide to getting the source, preparing your machine to build the SDK, and building.
There are more documents in our repo at docs.
Future plans for Dart are included in the combined Dart and Flutter roadmap on the Flutter wiki.