Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

digit-separators flag no longer required unless for dart formatcommand #59815

Open
PiotrFLEURY opened this issue Dec 27, 2024 · 1 comment
Open
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. area-dart-cli Use area-dart-cli for issues related to the 'dart' command like tool. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@PiotrFLEURY
Copy link

Context

Digit separators are allowed since Dart 3.6 as mentioned in the official documentation here

This feature allow to write large number values like so

int calculate() {
  return 6_000 * 7;
}

Current behavior

The dart format command raise an error when the code contains underscores in number values

For example running command

dart format .

Will produce the output

Could not format because the source could not be parsed:

line 2, column 10 of lib/digit_separator_format.dart: This requires the 'digit-separators' language feature to be enabled.
  ╷
2 │   return 6_000 * 7;
  │          ^^^^^
  ╵
Formatted 2 files (0 changed) in 0.06 seconds.

Workaround

We need to add the --enable-experimental=digit-separators flag in order to format files

dart format --enable-experiment=digit-separators .

Output

Formatted 3 files (0 changed) in 0.05 seconds.
'digit-separators' is now enabled by default; this flag is no longer required.

Note: The --enable-experimental=digit-separators flag produce a message

'digit-separators' is now enabled by default; this flag is no longer required.

But not adding it produces a message asking for adding it. Does not sounds correct.

Expected behavior

--enable-experimental=digit-separators flag should not be required for dart format command starting on Dart 3.6

Current Dart version used

dart --version
Dart SDK version: 3.6.0 (stable) (Thu Dec 5 07:46:24 2024 -0800) on "macos_arm64"
@PiotrFLEURY PiotrFLEURY added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Dec 27, 2024
@FMorschel
Copy link
Contributor

When this is fixed, we should probably CP it too.
FYI @munificent

@keertip keertip added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) area-dart-cli Use area-dart-cli for issues related to the 'dart' command like tool. P2 A bug or feature request we're likely to work on labels Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. area-dart-cli Use area-dart-cli for issues related to the 'dart' command like tool. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants