ERROR Error while analyzing ... missing FORWARD at 'var'
Prerequisites
- [X] This bug is in SonarDelphi, not SonarQube or my Delphi code.
- [X] This bug has not already been reported.
SonarDelphi version
1.11.0
SonarQube version
10.7
Issue description
ERROR Error while analyzing ... missing FORWARD at 'var'
we get this error inside implementation of methods, with different conditions (some of them are to be discovered yet)
We have solved by changing syntax of written code.
Steps to reproduce
use test code in description
Minimal Delphi code exhibiting the issue
Case 1
Two contiguous IF without begin/end block and an instructions contained in parenthesis... (ok, this is very strange)
unit testassignment;
interface
type
myclass = Class(Tobject)
Public
Procedure myMethod;
End;
Implementation
Procedure myClass.myMethod;
Var
B : Boolean;
Begin
if B then
B := B;
if B then
(B := B);
end;
end.
Case 2
tArray
Moved in #318, it give "missing FORWARD at 'var'" error message, but it is related to that issue.
Hi @simonegirlanda, what version of Delphi are you using?
I ask because in Delphi 11, your first example yields the compiler error
E2029 ')' expected but ':=' found ...
As far as I'm aware, it's not valid Delphi.
As mentioned, case 2 is a duplicate of #318. Same problem, so no need to address it here. Feel free to add that case to the #318 description though.
P.S. try to keep to one bug/problem per GitHub issue (case 1 and 2 have no relation besides "they both cause parsing errors")
Hi @simonegirlanda, what version of Delphi are you using?
I ask because in Delphi 11, your first example yields the compiler error
E2029 ')' expected but ':=' found ...
As far as I'm aware, it's not valid Delphi.
we are using Delphi 10.1, but we will upgrade to latest version in next weeks.
We have solved both these cases by changing code syntax, I've created this issue supposing that could help your precious work. I'll move case 2 in #318.
We have planned to study how to implement new rules, to give our contribution too.