Parsing import allows "as" before "if" #56641
Labels
area-fe-analyzer-shared
Assigned by engineers; when triaging, prefer either area-front-end or area-analyzer.
cfe-parser
Parser issues in the CFE
fe-analyzer-shared-parser
Issues with the shared parser's handling of correct code
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
I don't get any errors in:
This runs if I run it with
dart temp.dart
and analyzes without error usingdart analyze
. The grammar for imports is:That means that the
as
clause, if present, must be after anyif
configurations.I ran into this issue because
dart format
will always output theas
clause after theif
configurations, which then trips up its sanity check because it made a non-whitespace change by reordering those clauses.I did find at least two libraries in the wild (dotlottie_loader-0.0.4/lib/src/loaders/network_loader.dart and sentry-8.3.0/lib/src/environment/environment_variables.dart) that has the clauses in the wrong order, so fixing this is both nominally and actually a breaking change (though likely a very minor one given the rarity of conditional imports).
The text was updated successfully, but these errors were encountered: