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

Ambiguous declarations erroneously found for `string` and `array of Char` parameter types

Open zaneduffield opened this issue 6 months 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.6.0

SonarQube version

No response

Issue description

sonar-delphi fails to resolve the correct overload when a single-character string is passed to a function with overloads for both string and array of Char as the relevant parameter.

I noticed this because a warning is logged when scanning JclStrings, and I reduced it to the minimal reproducible example.

Steps to reproduce

procedure Foo(Value: array of Char); overload; begin end;
procedure Foo(Value: string); overload; begin end;

begin
  Foo('a');  // [WARN] Ambiguous declarations could not be resolved
  Foo('aa'); // no warning logged
end.

Minimal Delphi code exhibiting the issue

No response

zaneduffield avatar Aug 14 '24 07:08 zaneduffield