Closed Scharrels closed 1 month ago
Hi @Scharrels, thanks for reporting this issue.
I was able to reproduce it after setting sonar.delphi.toolchain
to DCC64
.
I reduced the problem to this minimal example
procedure Foo;
{$if False}
asm
{$else}
begin
var x := @Foo;
{$endif}
end;
What's happening here is the lexer is switching into ASM mode before the conditional directive processor has eliminated the asm
branch, and the ASM label token generated make no sense to the grammar. It's an issue related to #261.
As @zaneduffield noted, this would be fixed with #261.
However, I think it's a bad enough problem to warrant a medium-term hack.
It might be as simple as popping the asm
mode in the parser when we encounter a begin
token.
Prerequisites
SonarDelphi version
1.7.0
SonarQube version
10.5.1
Issue description
The following error occurs on multiple files in our project. Luckily, one of the files is FastMM5, making it possible to report this bug without sharing our own code. The following file causes the error:
https://github.com/pleriche/FastMM5/blob/version_505/FastMM5.pas
This causes the sonar-delphi to crash with the following stacktrace:
Steps to reproduce
The easiest way to reproduce this is to do a DelphiLint analysis on the following file:
https://github.com/pleriche/FastMM5/blob/version_505/FastMM5.pas
This shows the same error as sonar-delphi.
Minimal Delphi code exhibiting the issue
https://github.com/pleriche/FastMM5/blob/version_505/FastMM5.pas