Delphi parser loses every call inside a `for var x in …` loop
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- tooling
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C
- Estrellas
- 73.2k
- Forks
- 4.7k
- Merge medio
- 2 h 16 min
- PR fusionados (30 d)
- 423
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de colbymchenry/codegraph
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
colbymchenry/codegraph#2634 ·
Los mantenedores suelen responder en 1 día
-
Windows: bundled Node v24.16.0 can abort at exit (nodejs/node#56645); please bundle Node >= 24.20.0Posiblemente ocupada @Ancienttwo la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
colbymchenry/codegraph#2617 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Invalid regular expression: /\boperator++\s*(?:<[^<>()]*>)?\s*\(/: Nothing to repeat (v1.6.2)Abierto
Dificultad 2/5 Menos de una hora Aptitud para principiantes 72/100
colbymchenry/codegraph#2482 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
codegraph ui - does not workAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
colbymchenry/codegraph#1900 · 2 comentarios · 5 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
colbymchenry/codegraph#1700 ·
Los mantenedores suelen responder en 1 día
Todos los issues de colbymchenry/codegraph
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
FujiNetWIFI/fujinet-lib#204 ·
Los mantenedores suelen responder en 1 día
-
os:linux
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
mpv-player/mpv#18649 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
facebookincubator/muse-gadget-sdk#249 ·
Los mantenedores suelen responder en 1 día
-
docs: nng_dial / nng_dialer_start can return NNG_ECONNSHUT and NNG_ECRYPTO, which are not documentedAbierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 89/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
micropython/micropython#19786 ·
Los mantenedores suelen responder en 1 día