[Bug] C# scientific-notation literals without a decimal point are split into identifiers

Open Beginner friendly
#5,583 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Janani-bn is already working on this.

Since Nov 19, 2026.

  • #5584 by @Janani-bn — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Domain
frontend, tooling

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

https://microsoft.github.io/monaco-editor/playground.html?source=v0.57.0#XQAAAAJrAQAAAAAAAABBqIlHNxBQc6srq8tVgmqdRUkJtSH_-OAlCR2mwvU7wVHWa3_D95EjkKUGhqNilkFJgIpjv_TQqMmdYTHX_P5CBp3_uY6OuUwLx6BwLn-o-R5HxlqzZG2tfkZyJLRtbVAsuExVOJAPuI_GQZh-8r680URxOyDQZKnybDHpQm962y33ldBo4c_nJiT5wNGZd8_bBln22dcc7X8R6P4zC53N3Tb8px8dbIvuYa6nXcCumm_j3IxA3e-wKLlXJJB6-0JayfpgO92ZMWMrQkjF2F77IliPir8tH_pAjtKA_y7prquWNExhDIDO1uapOykrV8QQIViRNgm1NWvzFWxPwhhzyMgtksFHBP-5t1GA

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
  1. Open the playground link and click Load/Run to run the example.
  2. Compare 1e3 with 1.0e3, 1E+3 with 1.0E+3, and 1e-3 with 1.0e-3.
  3. For token-level confirmation after loading C#, compare monaco.editor.tokenize('1e3', 'csharp') with monaco.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:

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure

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

Monaco playground stable and nightly comparison

vscode.dev C sharp comparison

Dominant language
JavaScript
Stars
47k
Forks
4.2k
Avg merge
3d 13h
Merged PRs (30d)
13

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/monaco-editor

All issues in microsoft/monaco-editor

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.