dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.23k stars 1.57k forks source link

[analyzer] Misleading message for dart language version when it has quotes #47197

Open asashour opened 3 years ago

asashour commented 3 years ago

When there are quotes around the version in dart language version comment, e.g.

// @dart="2.7"
// @dart='2.7'

There is a message

The Dart language version override comment must be specified with an '=' character
Specify a Dart language version override with a comment like '// @dart = 2.0'.

However, the message should be something else, since the issue not regarding a missing = character.

The issue no longer exists if there is a space after =, e.g.

// @dart= "2.7"
// @dart= '2.7'

however it is not considered as a language version comment (which is ok), but a Hint would also be better in this case.

We should either have another HintCode, or at least get INVALID_LANGUAGE_VERSION_OVERRIDE_NUMBER

https://github.com/dart-lang/sdk/blob/dea3861e5f956a589ea117e8e4a7f2e56b173af8/pkg/analyzer/lib/src/dart/error/hint_codes.dart#L1063-L1066

Appreciate deciding what should be done, I could try to implement.

jensjoha commented 3 years ago

This is an analyzer message. It doesn't conform to the specified dart-version handling, so the scanner sees it as just any other comment. The analyzer tries to me helpful --- I'll reassign.

bwilkerson commented 3 years ago

@srawlins