Skip to content

Commit b45fb08

Browse files
committed
fix parse delphi 2005 for loop
1 parent 41d8181 commit b45fb08

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Parse/BuildParseTree.pas

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,6 +2293,16 @@ function TBuildParseTree.RecogniseVarDecl(const inlineVar: boolean): boolean;
22932293
end
22942294
else
22952295
RecogniseIdentList(False);
2296+
2297+
// check if we are inside a for loop header
2298+
lc := fcTokenList.FirstSolidToken;
2299+
if lc.TokenType = ttIn then
2300+
begin
2301+
// Delphi 2005 syntax
2302+
PopNode;
2303+
Exit;
2304+
end;
2305+
22962306
Recognise(ttColon);
22972307
RecogniseType;
22982308

test.pas

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ function myFunction(aParam: string
3636
var inline_var_decl2_string, inline_var_decl3_string: string := 'this is a string';
3737

3838
const inline_const := 999;
39+
40+
for var currentField in fieldList do
41+
begin
42+
var inline_var_decl4: string = 'a string';
43+
end;
3944

4045
for i := 1 to 10 do
4146
if i < 10 then write(i, ',')

0 commit comments

Comments
 (0)