Forráskód Böngészése

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

mattias 2 éve
szülő
commit
e4356a0d38

+ 3 - 0
packages/fcl-passrc/src/pasresolver.pp

@@ -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);
 

+ 10 - 0
packages/fcl-passrc/tests/tcresolver.pas

@@ -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);