fcl-passrc: fixed stackoverflow on const a=a, #39258

This commit is contained in:
mattias 2023-07-12 10:58:06 +02:00
parent 440af0f81f
commit e4356a0d38
2 changed files with 13 additions and 0 deletions

View File

@ -10325,6 +10325,9 @@ begin
FindData.Found:=DeclEl;
end;
if (DeclEl is TPasVariable) and El.HasParent(DeclEl) then
RaiseIdentifierNotFound(20230712105546,aName,El);
Ref:=CreateReference(DeclEl,El,Access,@FindData);
CheckFoundElement(FindData,Ref);

View File

@ -205,6 +205,7 @@ type
Procedure TestVarInitConst;
Procedure TestVarOfVarFail;
Procedure TestConstOfVarFail;
Procedure TestConstSelfFail;
Procedure TestTypedConstWrongExprFail;
Procedure TestVarWrongExprFail;
Procedure TestArgWrongExprFail;
@ -2928,6 +2929,15 @@ begin
CheckParserException('Expected type, but got variable',PParser.nParserExpectedTypeButGot);
end;
procedure TTestResolver.TestConstSelfFail;
begin
StartProgram(false);
Add('const');
Add(' a = a;');
Add('begin');
CheckResolverException('identifier not found "a"',nIdentifierNotFound);
end;
procedure TTestResolver.TestTypedConstWrongExprFail;
begin
StartProgram(false);