[Bug] Rust scientific-notation literals without an exponent sign are split into identifiers
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust, typescript
- Domain
- tooling
Research direction
Read src/languages/definitions/rust/rust.ts, where the issue identifies the exponent rule, and compare its pattern with the signed and unsigned examples in the report. Check the Rust tokenizer on those examples; done means valid decimal scientific notation is one number token whether the exponent sign is present or absent.
Written by the indexing model from the issue text.
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Checked the examples below in vscode.dev using Rust language mode. Its TextMate grammar keeps the exponent digits inside a numeric scope, rather than classifying the entire exponent tail as an identifier. The exponent marker can have a different color, so the report is about the token classification, not requiring identical colors across the two editors.
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Reproduced in the public playground with Monaco 0.57.0 and 0.58.0-dev-20261111. Also reproduced using the tokenizer from current main at commit 85549d055d7a548764ccba1a4cc3753810ef9166.
Monaco Editor Playground Link
Monaco Editor Playground Code
const value = `fn main() {
let a = 1e3;
let b = 1e+3;
let c = 1.5e3;
let d = 1.5e+3;
let e = 2E10f64;
let f = 2E+10f64;
}`;
monaco.editor.create(document.getElementById('container'), {
value, language: 'rust', theme: 'vs-dark', fontSize: 20,
minimap: { enabled: false }, automaticLayout: true
});
Reproduction Steps
- Open the linked playground, then click Run/Reload to run the example.
- Compare the Rust literals on alternating lines:
1e3vs1e+3,1.5e3vs1.5e+3, and2E10f64vs2E+10f64. - For token-level confirmation after loading the Rust language, inspect
monaco.editor.tokenize('1e3', 'rust')and compare it withmonaco.editor.tokenize('1e+3', 'rust').
Actual (Problematic) Behavior
An exponent without an explicit sign ends the number early. The rest becomes an identifier:
| Input | Tokens (offset: type) |
|---|---|
1e3 |
0: number.rust, 1: identifier.rust |
1.5e3 |
0: number.rust, 3: identifier.rust |
2E10f64 |
0: number.rust, 1: identifier.rust |
The signed controls 1e+3, 1e-3, 1.5e+3, and 2E+10f64 are each a single number.rust token. This makes adding an otherwise optional + change highlighting.
Expected Behavior
Recognize these valid Rust floating-point literals as numbers whether or not the exponent has an explicit sign. The Rust Reference makes the + or - in a floating-point exponent optional:
https://doc.rust-lang.org/reference/tokens.html
Additional Context
The exponent rule in src/languages/definitions/rust/rust.ts currently requires [+-], unlike the optional exponent sign in Rust's syntax. This appears to explain the difference between the signed and unsigned examples.
This report concerns decimal scientific notation, not hexadecimal separators or raw strings.
AI assistance was used to investigate and prepare this report. The token output and playground behavior were checked directly.
Screenshots
- Dominant language
- JavaScript
- Stars
- 47k
- Forks
- 4.2k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 13
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/monaco-editor
-
Difficulty 1/5 1-3 hours Newbie friendliness 65/100
microsoft/monaco-editor#5626 ·
Maintainers usually reply within 1 day
-
[Bug] package.json `"typings"` points to a file which does not exist in the npm packagePossibly taken @whoalin1 claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/monaco-editor#5615 ·
Maintainers usually reply within 1 day
-
[Bug] C# scientific-notation literals without a decimal point are split into identifiersPossibly taken @Janani-bn claimed this 15 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
microsoft/monaco-editor#5583 ·
Maintainers usually reply within 1 day
-
[Bug] Go numeric literals with underscore separators are split into identifiersMay be free again @aaronanish-t claimed this 25 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
microsoft/monaco-editor#5577 · 1 comment ·
Maintainers usually reply within 1 day
-
[Bug] JavaScript/TypeScript tokenizer: regex literals with `/` inside `[...]` or with the `v` flag are not recognizedPossibly taken @Janani-bn claimed this 26 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
microsoft/monaco-editor#5575 ·
Maintainers usually reply within 1 day
All issues in microsoft/monaco-editor
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
quasarframework/quasar#18614 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug/1-unconfirmed kind/bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
521xueweihan/HelloGitHub#4714 ·
-
01 type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day