Skip to content

Diagnose duplicate overrides#1789

Open
akiramenai wants to merge 1 commit into
mainfrom
dborisenkov/override
Open

Diagnose duplicate overrides#1789
akiramenai wants to merge 1 commit into
mainfrom
dborisenkov/override

Conversation

@akiramenai

Copy link
Copy Markdown

This patch introduces a generic extractor for override attributes and applies it to methods, state variables, fallback, receive, and modifiers, ensuring duplicate override checks are performed consistently across all these constructs.

@akiramenai akiramenai requested a review from OmarTawfik May 20, 2026 12:26
@akiramenai akiramenai requested review from a team as code owners May 20, 2026 12:26
@changeset-bot

changeset-bot Bot commented May 20, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2632fb9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@akiramenai akiramenai force-pushed the dborisenkov/override branch from 4f9dca2 to da57a1e Compare May 20, 2026 13:20
This patch introduces a generic extractor for override attributes and applies it to methods, state variables, fallback, receive, and modifiers, ensuring duplicate override checks are performed consistently across all these constructs.
@akiramenai akiramenai force-pushed the dborisenkov/override branch from da57a1e to 2632fb9 Compare May 20, 2026 13:42
fn extract_override_specifier<'a, Input>(
&mut self,
attributes: impl IntoIterator<Item = &'a Input>,
override_specifier_of: impl Fn(&'a Input) -> Option<&'a input::OverrideSpecifier>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IIUC, this override_specifier_of acts as a filter for incoming types, which needs the same callsite to repeat the same logic to use it (passing a callback, then if/else to wrap an Option<>).

WDYT of adding extensions under crates/solidity-v2/outputs/cargo/ir/src/ir/node_extensions/override_paths.rs, with impl TryFrom<> for OverridePaths for the 5 types here?

This would remove all the helpers from here, and allow you to use .try_into() here, similar to extract_mutability_specifier.

@@ -0,0 +1,25 @@
pragma solidity ^0.8.0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I suggest splitting these into 5 separate tests, to make it easier to diagnose/triage failures.

  • crates/solidity-v2/testing/snapshots/diagnostics_output/syntax/multiple_override_specifiers/fallback_function/input.sol
  • crates/solidity-v2/testing/snapshots/diagnostics_output/syntax/multiple_override_specifiers/receive_function/input.sol
  • etc....

uint public override x;
modifier onlyOwner() override {}
}
// (removed duplicate B and C)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Q: what is the "duplicate B and C" here? lingering comment?

@OmarTawfik OmarTawfik self-assigned this Jun 3, 2026
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.

2 participants