[Bug] Go numeric literals with underscore separators are split into identifiers
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 83/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, typescript
- Domain
- tooling
Research direction
Read src/languages/definitions/go/go.ts and inspect the numeric token patterns for decimal, hexadecimal, octal, and binary literals. Compare how those patterns handle apostrophes with the Go specification's underscore rules. Done means underscore separated literals, including underscores after a base prefix, remain highlighted as numeric tokens while the existing controls continue to work.
Written by the indexing model from the issue text.
Description
Reproducible in vscode.dev or VS Code Desktop?
- Not reproducible in VS Code Desktop
The same sample is highlighted correctly in VS Code Desktop 1.112.0 with its built-in Go grammar.
Monaco Editor Playground Link
Monaco Editor Playground Code
JavaScript:
monaco.editor.create(document.getElementById("container"), {
value: [
"package main",
"",
"var decimal = 1_000",
"var hex = 0xCA_FE",
"var binary = 0b1010_0110",
"",
"var control = 1000",
"var hexControl = 0xCAFE"
].join("\n"),
language: "go",
theme: "vs-dark",
fontSize: 20
});
HTML:
<div id="container" style="height:100vh"></div>
CSS:
html, body { margin: 0; height: 100%; }
Reproduction Steps
- Open the playground link and click Load if prompted.
- Compare the three literals containing underscores with the controls without underscores.
Actual Behavior
The numeric token ends before the first underscore:
1_000:1isnumber.go;_000isidentifier.go.0xCA_FE:0xCAisnumber.hex.go;_FEisidentifier.go.0b1010_0110:0b1010isnumber.binary.go;_0110isidentifier.go.
The suffix consequently uses identifier highlighting instead of number highlighting. Reproduced in playground 0.55.1 and with the Go grammar from current main at 5359a3330383137dfdf8897ba1d93d943fec4027.
Expected Behavior
The underscore and following digits should remain part of the numeric literal. These are valid Go literals: the Go specification permits underscores between digits or after a base prefix.
Additional Context
The numeric rules in src/languages/definitions/go/go.ts accept apostrophes in the hexadecimal, octal, binary and decimal patterns, but do not handle Go's underscore separators.
Go specification: https://go.dev/ref/spec
Grammar source: https://github.com/microsoft/monaco-editor/blob/main/src/languages/definitions/go/go.ts
- Dominant language
- JavaScript
- Stars
- 46.9k
- Forks
- 4.2k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 28
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
-
[Bug] JavaScript/TypeScript tokenizer: regex literals with `/` inside `[...]` or with the `v` flag are not recognizedPossibly taken @Janani-bn claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
microsoft/monaco-editor#5575 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
microsoft/monaco-editor#5563 ·
Maintainers usually reply within 1 day
-
[Bug] Why versions of marked and dompurify are fixed?May be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
microsoft/monaco-editor#5314 · 2 comments · 4 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
microsoft/monaco-editor#5193 ·
Maintainers usually reply within 1 day
-
[Bug] colorizeElement method doesn't color the whole text if domNode has more than one #text childOpen
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
microsoft/monaco-editor#4571 ·
Maintainers usually reply within 1 day
All issues in microsoft/monaco-editor
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ImranR98/apps.obtainium.imranr.dev#2000 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
obsidianmd/obsidian-help#1169 ·
Maintainers usually reply within 2 days
-
[docs] RELEASE.md: wrong branch name, no check that the prepare PR merged with the right subject, manual publish stepPossibly taken @albertteoh claimed this today. Opendocumentation
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
jaegertracing/jaeger-ui#4739 ·
Maintainers usually reply within 1 day
-
添加报告文档问题的模板Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
maboloshi/github-chinese#823 ·
Maintainers usually reply within 1 day