Skip to content

Conversation

@fourls
Copy link
Collaborator

@fourls fourls commented Nov 1, 2024

This PR fixes an issue with the new MissingRaise rule that would cause it to raise false positives on constructor calls on Self, when Self is an exception type. For example:

type
  EMyError = class(Exception)
  public
    constructor Create(S: string);
    constructor Create(A: Integer; B: Integer);
  end;

constructor EMyError.Create(A: Integer; B: Integer);
begin
  // ...
  Create('Default message'); // <- Raises a false positive issue
  // ...
end;

@fourls fourls requested a review from zaneduffield November 1, 2024 06:31
Copy link
Collaborator

@zaneduffield zaneduffield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

It's annoying that Delphi lets you call a constructor method to re-initialise an existing object, but it's not so bad when you realise that all new-object constructor calls are qualified.

@zaneduffield
Copy link
Collaborator

It's also worth noting that this doesn't need a changelog entry because the bug was never released.

@fourls fourls merged commit 4345241 into master Nov 3, 2024
2 checks passed
@fourls fourls deleted the fix-missing-raise branch November 3, 2024 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants