integrated-application-development / integrated-application-development/sonar-delphi

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

Open
#285 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
159
Forks
31
Avg merge
5d 4h
Merged PRs (30d)
4

Description

### 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](https://github.com/project-jedi/jcl/blob/1529c9693ae0e771910563054c7292aab6378870/jcl/source/common/JclStrings.pas#L5165), and I reduced it to the minimal reproducible example.

### Steps to reproduce

```delphi
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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.