typescript/ast/scanner: scan() never advances past `#` not followed by an identifier start (7.1.0-beta)
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 70/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- typescript
- Domínio
- compilers
Direção de pesquisa
Start with the createScanner entry point in typescript/ast/scanner and run the provided reproduction on the three inputs. Trace the # scanning behavior when no identifier start follows, then check existing scanner tests for where to add regression coverage. Done means each scan advances or returns EndOfFile, and the inputs produce tokens that do not repeat at the same position.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
🔎 Search Terms
createScanner, scan, PrivateIdentifier, #, infinite loop, scanner does not advance, typescript/ast/scanner
🕗 Version & Regression Information
- Reproduces in
[email protected](typescript/ast/scanner). The JS scanner is used through the new API entry points. - Does not reproduce in
[email protected](ts.createScanner). - Node 22.22.3, Linux x64.
⏯ Playground Link
No response
💻 Code
// node repro.mjs
import { createScanner } from "typescript/ast/scanner";
import { SyntaxKind } from "typescript/ast";
for (const text of ["a # b", "# ", "#1"]) {
const scanner = createScanner(/*skipTrivia*/ true, /*languageVariant*/ undefined, text);
const tokens = [];
for (let i = 0; i < 6; i++) {
const kind = scanner.scan();
tokens.push(`${SyntaxKind[kind]}@${scanner.getTokenStart()}-${scanner.getTokenEnd()}`);
if (kind === SyntaxKind.EndOfFile) break;
}
console.log(JSON.stringify(text), tokens.join(", "));
}
🙁 Actual behavior
When # is not followed by an identifier start, scan() returns PrivateIdentifier with an empty range and never advances, so it never reaches EndOfFile:
"a # b" Identifier@0-1, PrivateIdentifier@2-2, PrivateIdentifier@2-2, PrivateIdentifier@2-2, PrivateIdentifier@2-2, PrivateIdentifier@2-2
"# " PrivateIdentifier@0-0, PrivateIdentifier@0-0, ...
"#1" PrivateIdentifier@0-0, PrivateIdentifier@0-0, ...
Any loop of the form while (scanner.scan() !== SyntaxKind.EndOfFile) hangs on such input.
🙂 Expected behavior
The scanner consumes the # and moves on, as [email protected] does:
"a # b" Identifier@0, PrivateIdentifier@2, Identifier@4, EndOfFileToken@5
"# " PrivateIdentifier@0, EndOfFileToken@2
"#1" PrivateIdentifier@0, NumericLiteral@1, EndOfFileToken@2
(5.9 also reports an "Invalid character" error for the lone #.) At minimum, every scan() call should advance the position or return EndOfFile.
Additional information about the issue
Input like this is common in tooling that scans arbitrary text, such as comments, markdown-ish strings, and partial edits.
- Linguagem predominante
- Go
- Estrelas
- 112k
- Forks
- 16k
- Merge médio
- 3d 4h
- PRs com merge (30d)
- 145
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de microsoft/TypeScript
-
API: `tsc.exe` opens a visible console window on Windows when the parent process has no consoleAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
microsoft/TypeScript#65083 ·
Mantenedores costumam responder em até 1 dia
-
TS7 LSP: documentHighlight returns nothing when the file path contains '@'Talvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. AbertaBug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
microsoft/TypeScript#64758 ·
Mantenedores costumam responder em até 1 dia
-
Language server (tsc --lsp) exits with code 1 after `shutdown` and `exit`Talvez já em andamento @rajnish-verma-22172 assumiu há 11 dias. AbertaBug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
microsoft/TypeScript#64742 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Class names `eval` and `arguments` are not reported as invalid strict mode bindingsTalvez já em andamento @dmety assumiu há 24 dias. AbertaBug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
microsoft/TypeScript#64661 ·
Mantenedores costumam responder em até 1 dia
-
Non-enum CLI options with multiple values separated by comma and space aren't whitespace trimmedTalvez já em andamento @RyanCavanaugh assumiu há 25 dias. AbertaBug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
microsoft/TypeScript#64618 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de microsoft/TypeScript
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 2 dias
-
needs-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
cli/cli#14895 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
kagent-dev/kagent#3462 ·
Mantenedores costumam responder em até 1 dia
-
netrc credential source accepts a password with an embedded CR/LF that every other source rejectsAbertaagent-butler-finding bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
jordansmall/spindrift#6268 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 7 dias