[Bug] C# scientific-notation literals without a decimal point are split into identifiers
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, typescript
Research direction
Read src/languages/definitions/csharp/csharp.ts and compare the numeric rules for literals with and without a decimal point. Reproduce the issue with the supplied C# examples or monaco.editor.tokenize calls, then check that all exponent forms are classified as one numeric token while the existing decimal-point examples still tokenize correctly.
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 code below in vscode.dev with C# language mode. Its TextMate grammar recognizes the exponent marker and digits as numeric scopes. In Monaco, the exponent marker instead becomes an identifier when the literal has no decimal point. This report is about token classification, not requiring identical theme colors between the editors.
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Reproduced in Monaco 0.57.0 and 0.58.0-dev-20261111 in the official playground. Also checked the real Monarch tokenizer using the C# definition currently on main.
Monaco Editor Playground Link
Monaco Editor Playground Code
const value = `double a = 1e3;
double b = 1.0e3;
double c = 1E+3;
double d = 1.0E+3;
double e = 1e-3;
double f = 1.0e-3;`;
monaco.editor.create(document.getElementById('container'), {
value, language: 'csharp', theme: 'vs-dark', fontSize: 20,
minimap: { enabled: false }, automaticLayout: true
});
Reproduction Steps
- Open the playground link and click Load/Run to run the example.
- Compare
1e3with1.0e3,1E+3with1.0E+3, and1e-3with1.0e-3. - For token-level confirmation after loading C#, compare
monaco.editor.tokenize('1e3', 'csharp')withmonaco.editor.tokenize('1.0e3', 'csharp').
Actual (Problematic) Behavior
The exponent is not recognized as part of the numeric literal unless a decimal point is present:
| Input | Tokens (offset: type) |
|---|---|
1e3 |
0: number.cs, 1: identifier.cs |
1E+3 |
0: number.cs, 1: identifier.cs, 2: delimiter.cs, 3: number.cs |
1e-3 |
0: number.cs, 1: identifier.cs, 2: delimiter.cs, 3: number.cs |
The controls 1.0e3, 1.0E+3, and 1.0e-3 are each a single number.float.cs token.
Expected Behavior
Recognize the exponent as part of these valid C# real literals, with or without a decimal point. The C# specification explicitly allows a decimal-digit sequence followed by an exponent, without requiring a fractional part:
Additional Context
The numeric rules in src/languages/definitions/csharp/csharp.ts recognize an optional exponent only in the rule that requires a decimal point. An integer-part-plus-exponent form falls through to the integer and identifier rules.
This is separate from the Rust exponent-sign issue #5582. The C# problem occurs with unsigned, explicitly positive and negative exponents, and depends on whether a decimal point is present.
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] Rust scientific-notation literals without an exponent sign are split into identifiersPossibly taken @Janani-bn claimed this 14 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microsoft/monaco-editor#5582 ·
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