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

Closed
PiotrFLEURY opened this issue Dec 27, 2024 · 2 comments
Closed
Assignees
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. dart-cli-format Issues related to the 'dart format' tool P2 A bug or feature request we're likely to work on triaged Issue has been triaged by sub team 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
@bkonyi bkonyi added dart-cli-format Issues related to the 'dart format' tool triaged Issue has been triaged by sub team labels Jan 6, 2025
copybara-service bot pushed a commit that referenced this issue Jan 28, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
The 2.3.7 version of dart_style that shipped in Dart SDK 3.6.0
incorrectly parses Dart code at language version 3.3 instead of 3.6.
That means it doesn't handle number literals with digit separators. In
other words, `dart format` fails on any code that contains digit
separators.

This bumps the DEP to 2.3.8, which is a single-commit patch version from
2.3.7 that fixes the parser language version number. There are no other
dart_style changes in 2.3.8.

Bug: #59815
Change-Id: If2546edcd11bd424019d76b87c7c08695add331a
Cherry-pick: dart-lang/dart_style#1636
Cherry-pick-request: #59998
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406204
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
@munificent
Copy link
Member

The cherrypick has landed so I'm going to close this. @PiotrFLEURY, thanks for the bug report!

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. dart-cli-format Issues related to the 'dart format' tool P2 A bug or feature request we're likely to work on triaged Issue has been triaged by sub team type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants