Diagnose duplicate overrides#1789
Conversation
|
4f9dca2 to
da57a1e
Compare
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.
da57a1e to
2632fb9
Compare
| 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>, |
There was a problem hiding this comment.
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; | |||
There was a problem hiding this comment.
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.solcrates/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) |
There was a problem hiding this comment.
Q: what is the "duplicate B and C" here? lingering comment?
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.