Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bare inherited fails to resolve parent message handler with different signature #271

Open
2 tasks done
Cirras opened this issue Jul 19, 2024 · 1 comment
Open
2 tasks done
Labels
bug Something isn't working

Comments

@Cirras
Copy link
Collaborator

Cirras commented Jul 19, 2024

Prerequisites

  • This bug is in SonarDelphi, not SonarQube or my Delphi code.
  • This bug has not already been reported.

SonarDelphi version

1.7.0

SonarQube version

No response

Issue description

SonarDelphi does not currently implement the following behavior around message handlers.

When inherited has no identifier after it, it refers to the inherited method with the same name as the enclosing method or, if the enclosing method is a message handler, to the inherited message handler for the same message. In this case, inherited takes no explicit parameters, but passes to the inherited method the same parameters with which the enclosing method was called.

See https://docwiki.embarcadero.com/RADStudio/Athens/en/Methods_(Delphi)#Inherited

Steps to reproduce

In the below code example, the inherited in TBar.Bar should resolve to TFoo.Foo.

Minimal Delphi code exhibiting the issue

unit Example;

interface

type
  TFoo = class(TObject)
    procedure Foo(var Msg: TWMSize); message WM_SIZE;
  end;

  TBar = class(TFoo)
    procedure Bar(var Msg: TMessage); message WM_SIZE;
  end;

implementation

procedure TFoo.Foo(var Msg: TWMSize);
begin
  // ...
end;

procedure TBar.Bar(var Msg: TMessage);
begin
  inherited; // This should call TFoo.Foo
  // ...
end;

end.
@Cirras Cirras added the bug Something isn't working label Jul 19, 2024
@Cirras
Copy link
Collaborator Author

Cirras commented Aug 7, 2024

Blocked by #116 - we'd need the evaluated message expression to be persisted in the symbol table for name resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant