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

Aperta Adatta ai principianti
#5,583 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Janani-bn ci sta già lavorando.

Dal 19/11/2026.

  • #5584 di @Janani-bn — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, typescript
Ambito
frontend, tooling

Direzione di ricerca

Leggi src/languages/definitions/csharp/csharp.ts e confronta le regole numeriche per i valori letterali con e senza punto decimale. Riproduci il problema con gli esempi C# forniti o con chiamate a monaco.editor.tokenize, poi verifica che tutte le forme dell’esponente siano classificate come un unico token numerico, mentre gli esempi esistenti con il punto decimale continuino a essere tokenizzati correttamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
JavaScript
Stelle
47k
Fork
4.2k
Merge medio
3g 13h
PR unite (30g)
13

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/monaco-editor

Tutte le issue di microsoft/monaco-editor

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.