sonar-delphi icon indicating copy to clipboard operation
sonar-delphi copied to clipboard

ERROR Error while analyzing ... missing FORWARD at 'var'

Open simonegirlanda opened this issue 1 year ago • 3 comments

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.

simonegirlanda avatar Dec 05 '24 17:12 simonegirlanda

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.

zaneduffield avatar Dec 05 '24 21:12 zaneduffield

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")

cirras avatar Dec 05 '24 22:12 cirras

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.

simonegirlanda avatar Dec 06 '24 08:12 simonegirlanda