Dart: support digit separators #14263
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "github/fork/srawlins/dart-digit-separators"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Dart is adding support for digit separators, the underscore, like
1_000_000or0x33_33_33. The Dart playground, DartPad, still runs on codemirror5, so this would be a welcome fix.That regexp seems to allow underscores anywhere, whereas the linked proposal only allows them between digits. I think this'll make
_tokenize as a number, which doesn't seem right.As I understand it, the
numberpattern is only checked when we seenumberStart, line 65 inclike.js. With manual testing, I see that_is styled as a "variable."As for other spots where
_is not allowed (e.g. in1_._0, neither underscore is allowed), I think it is fine to allow them for the purposes of in-progress typing, and error-recovery. For example, in the Dart parser, we parse1_._0as a number literal, and also report an error. This reduces errors-carried-forward. And for a trailing_like100_, it is fine to allow it for code-in-progress.If you think we should be more strict here and only parse error-free numbers as numbers, I can amend the PR.
Merged by: marijnh at 2024-09-05 14:45:25 UTC
Oh, indeed, there's a separate regexp for the start of the number. Then this is close enough, indeed.