typescript/ast/scanner: scan() never advances past `#` not followed by an identifier start (7.1.0-beta)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 70/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- compilers
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🔎 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.
- Ngôn ngữ chính
- Go
- Star
- 112k
- Fork
- 16k
- Merge trung bình
- 3 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 145
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/TypeScript
-
API: `tsc.exe` opens a visible console window on Windows when the parent process has no consoleĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
microsoft/TypeScript#65083 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
TS7 LSP: documentHighlight returns nothing when the file path contains '@'Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/TypeScript#64758 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Language server (tsc --lsp) exits with code 1 after `shutdown` and `exit`Có thể đã có người làm @rajnish-verma-22172 đã nhận 11 ngày trước. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
microsoft/TypeScript#64742 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Class names `eval` and `arguments` are not reported as invalid strict mode bindingsCó thể đã có người làm @dmety đã nhận 24 ngày trước. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/TypeScript#64661 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Non-enum CLI options with multiple values separated by comma and space aren't whitespace trimmedCó thể đã có người làm @RyanCavanaugh đã nhận 25 ngày trước. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/TypeScript#64618 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/TypeScript
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 2 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
kagent-dev/kagent#3462 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
netrc credential source accepts a password with an embedded CR/LF that every other source rejectsĐang mởagent-butler-finding bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
jordansmall/spindrift#6268 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 7 ngày