Delphi parser loses every call inside a `for var x in …` loop
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/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
- tooling
Hướng nghiên cứu
Start by reproducing with the Loop.pas sample in the issue, running codegraph callees WithVar and codegraph callers DropIfEmpty. Then inspect the parse tree the Pascal grammar produces for for var lItem in AList do, which the issue shows as an ERROR node, and compare it with the working for lItem in AList do form. The grammar ships as tree-sitter-pascal.wasm, so the fix may belong upstream. Done when WithVar lists DropIfEmpty as a callee and DropIfEmpty has two callers.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
In a Delphi (Object Pascal) unit, a for … in loop that declares its variable inline (for var lItem in AList do, Delphi 10.3 and later) is an ERROR node for the parser: the loop and its body contribute nothing, so a call made in the body is missing from callees of the
routine and from callers of the callee. The same loop with the variable declared in a var section (for lItem in AList do) is indexed with its calls.
Versions
codegraph --version: 1.6.2 (Windows x64 bundle).- Windows 10 Pro 10.0.19045.
Minimal reproduction
Loop.pas:
unit Loop;
interface
type
TItem = class
public
function DropIfEmpty: Boolean;
end;
procedure WithVar(const AList: TArray<TItem>);
procedure WithDecl(const AList: TArray<TItem>);
implementation
function TItem.DropIfEmpty: Boolean;
begin
Result := True;
end;
procedure WithVar(const AList: TArray<TItem>);
begin
for var lItem in AList do
lItem.DropIfEmpty;
end;
procedure WithDecl(const AList: TArray<TItem>);
var
lItem: TItem;
begin
for lItem in AList do
lItem.DropIfEmpty;
end;
end.
Steps, in a directory holding only that file:
codegraph init -y .
codegraph callees WithVar
codegraph callees WithDecl
codegraph callers DropIfEmpty
Observed (1.6.2):
● 6 nodes, 6 edges
function WithVar (pascal) — Loop.pas:11
ℹ No callees found for "WithVar"
function WithDecl (pascal) — Loop.pas:12
method DropIfEmpty
Loop.pas:8
Callers of "DropIfEmpty" (1):
method TItem::DropIfEmpty (pascal) — Loop.pas:8
function WithDecl
Loop.pas:12
Expected: WithVar with the callee DropIfEmpty as well, and DropIfEmpty with two callers.
The grammar's tree for the body of WithVar (tree-sitter-pascal.wasm shipped in 1.6.2) — the whole loop is an ERROR, the body's lItem.DropIfEmpty never becomes a statement/exprDot:
block !
ERROR !
kFor
varAssignDef !
kVar "var"
ERROR ! lItem in AList do
ERROR ! lItem
identifier "DropIfEmpty"
The other inline-variable forms parse: var x := …; (varAssignDef), var y: T; (varDef) and for var i := 0 to … do (for with a varAssignDef); only for var x in … is missing.
Where it was found
A product of about 600 for var … in loops across its units: callers DropIfEmpty names five of the six routines that call it, and the one left out calls it from for var lItem in lEmpty do lItem.DropIfEmpty;. Fourteen of the loops type the variable (for var lHandle: THandle in lHandles do).
Note on the syntax
for var x in … is Delphi's inline variable declaration inside a for-in loop (documented under Inline Variable Declaration, Delphi 10.3 Rio and later); the variable may carry a type (for var x: T in …), generic types included.
- Ngôn ngữ chính
- C
- Star
- 73.2k
- Fork
- 4.7k
- Merge trung bình
- 2 giờ 16 phút
- Pull request đã merge (30 ngày)
- 423
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 colbymchenry/codegraph
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
colbymchenry/codegraph#2634 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows: bundled Node v24.16.0 can abort at exit (nodejs/node#56645); please bundle Node >= 24.20.0Có thể đã có người làm @Ancienttwo đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
colbymchenry/codegraph#2617 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Invalid regular expression: /\boperator++\s*(?:<[^<>()]*>)?\s*\(/: Nothing to repeat (v1.6.2)Đang mở
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 72/100
colbymchenry/codegraph#2482 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
codegraph ui - does not workĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
colbymchenry/codegraph#1900 · 2 bình luận · 5 reaction ·
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 72/100
colbymchenry/codegraph#1700 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của colbymchenry/codegraph
Issue tương tự
-
mewencode: base256[] and base128[] are indexed out of bounds by a non-ASCII octetCó thể đã có người làm @kazu-yamamoto đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
kazu-yamamoto/Mew#276 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
FujiNetWIFI/fujinet-firmware#2045 ·
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
Maintainer thường phản hồi trong vòng 1 ngày
-
[Performance]: Qwen-Image-2.1 CPU-only on i5-10500H (6C AVX2, 32 GB): 512x512 in 7.7 min at 8 stepsĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:gates area:gfx found-by:critic kind:gate-defect
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
InauguralSystems/EigenScript#1825 ·
Maintainer thường phản hồi trong vòng 1 ngày