[Bug]: Swift: a local with same name as a modifier (prefix, open, final...) used in a switch case body gives a syntax-parse error from tree-sitter-swift
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 65/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- developer-experience, tooling
Hướng nghiên cứu
Issue nêu extract.py, phần tham số hóa kiểm thử Swift và changelog. Đọc cách xử lý hiện có đối với các định danh được đặt tên theo modifier và chạy hai tệp kiểm thử Swift được nhắc đến trong issue. Công việc hoàn tất khi các biểu thức switch-case được bao phủ phân tích cú pháp thành công, sáu tên bổ sung được đưa vào và các kiểm thử đó đều đạt; các ngoại lệ được liệt kê vẫn giữ nguyên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Pre-flight checks
- I have checked the Troubleshooting section in the README
What happened?
Summary:
tree-sitter-swift 0.7.4 cannot parse a local value whose name is a Swift contextual modifier when it is used as return name <operator> or return name.member inside a switch case. The grammar reads the identifier as a declaration modifier waiting for a declaration, and the surrounding code collapses into ERROR nodes. Graphify warns about a syntax-parse error at line: X and extracts the file only partially.
Related but distinct: #3540 (another tree-sitter-swift parse failure, if let x = await ...).
The trigger is a modifier-named identifier at the start of an expression statement inside a case body, followed by an operator or member access.
Limits and unfixed exceptions (the fix doesn't cover these, so behavior is unchanged: partial extraction plus the warning):
- A function parameter named like a modifier. Renaming it would change the argument label and every call site.
- A closure parameter, as in
xs.map { prefix in ... }. - Tuple destructuring, as in
let (prefix, b) = t. - A file with any other syntax error, because the rewrite is accepted only if the whole file then parses cleanly.
- Names I haven't tested. The list is only what I verified.
Covered: if let prefix = x, and a type-scope property with the same name.
Code change: added six names that also fail to extract.py, the test parametrization, and the changelog: distributed, nonmutating, public, private, internal and fileprivate.
Validation: The Swift tests pass, 36 of 36 in the two files I re-ran after the change. I did not re-run the full suite because it had 8 failures before this change, and they also fail without this fix.
static, class and inout also error, but they are reserved keywords, so let class = 1 isn't valid Swift.
Steps to reproduce
Minimal repro
let prefix = "x"
switch kind {
case 0:
return prefix + "a" // error
| Case body | Result |
|---|---|
return prefix + "a" |
error |
return prefix.count > 0 ? "a" : "b" |
error |
return prefix |
ok |
print(prefix) |
ok |
let y = prefix |
ok |
x = prefix + "a" |
ok |
return "a" + prefix |
ok |
return pfx + "a" (local renamed) |
ok |
return prefix + "a" inside if k == 0 { ... } instead of a switch |
ok |
return prefix + "a" after the switch, outside any case |
ok |
Error output or graph output
codefile.swift had a syntax-parse error at line X, so its extraction may be partial (Y symbols found).
Graphify version
0.9.102
Operating System
macOS
Python Version
3.13
Installation Method
uv tool install (recommended)
Additional Environment Details
No response
Additional context
No response
- Ngôn ngữ chính
- Python
- Star
- 124k
- Fork
- 11.9k
- Merge trung bình
- 2 giờ 35 phút
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 Graphify-Labs/graphify
-
[Bug]: valid JSON with the wrong global-manifest shape bypasses recoveryCó thể đã có người làm @azizur100389 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Graphify-Labs/graphify#5020 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: malformed learning sidecar data can hide valid annotationsCó thể đã có người làm @azizur100389 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Graphify-Labs/graphify#5019 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: graphify update skips or partially rebuilds a missing graph when the manifest survivesCó thể đã có người làm @azizur100389 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Graphify-Labs/graphify#5016 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
extract --out <dir>: semantic cache never saved, docs missing from manifest (relative source_file resolved against --out)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Graphify-Labs/graphify#4831 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
hooks: last-resort `python3` probe launches the Microsoft Store redirector on Windows (visible console flash, exit 9009)Có thể đã có người làm @Deepjyoti-Sarmah đã nhận 17 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Graphify-Labs/graphify#4563 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Graphify-Labs/graphify
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
didi/helixharness#18 ·
-
[MOVIE]: Airport '77 (1977)Đang mởrequest-theme
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
LizardByte/ThemerrDB#9883 ·
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 75/100
NousResearch/hermes-agent#149885 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Set cache_ok = True on GUID TypeDecorator to enable SQLAlchemy query cachingCó thể đã có người làm @patelshivani2283-lab đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
fedora-infra/anitya#2157 ·
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 84/100
Project-MONAI/MONAI#9258 ·
Maintainer thường phản hồi trong vòng 3 ngày