You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IdentifierRedeclaration is reported for two import patterns that Solidity allows: importing the same declaration through two routes, and importing overloads of one name from different files.
Reproduction
A — the same free function reached by two import routes
z.sol reports Resolution(IdentifierRedeclaration) on f. The two targets have distinct signatures and should overload.
Both reproduce on main at 61d67fc, at LanguageVersion::LATEST / EvmTarget::LATEST.
Cause
conflicting_definition in crates/solidity-v2/outputs/cargo/semantic/src/passes/common/conflicts.rs is a pairwise comparison that delegates to Definition::overloads_with:
let existing = binder.find_definition_by_id(existing_id)?;if new_definition.overloads_with(existing){None}else{Some(existing_id)}
Both operands here are Definition::ImportedSymbol. The comparison never follows the alias to what was imported, so it can see neither that the two sides resolve to the same target (A) nor that they resolve to distinct overloadable signatures (B).
Notes for whoever picks this up
The fix belongs behind the alias: resolve each ImportedSymbol to its target set before comparing, then apply the existing overloads_with rule to the resolved definitions. Short-circuiting on "both sides are functions, therefore compatible" is not sufficient — it would also accept two imported functions with identical signatures, which is a real redeclaration.
No snapshot case currently covers either pattern. Both belong in crates/solidity-v2/testing/snapshots/diagnostics_output/resolution/identifier_redeclaration/. Adding them there also records solc's verdict alongside slang's, which is the cleanest way to confirm the expected behavior rather than relying on a reading of the spec.
IdentifierRedeclarationis reported for two import patterns that Solidity allows: importing the same declaration through two routes, and importing overloads of one name from different files.Reproduction
A — the same free function reached by two import routes
b.solreportsResolution(IdentifierRedeclaration)onf. Both names denote the same declaration, so there is nothing to disambiguate.B — overloads of one name imported from different files
z.solreportsResolution(IdentifierRedeclaration)onf. The two targets have distinct signatures and should overload.Both reproduce on
mainat 61d67fc, atLanguageVersion::LATEST/EvmTarget::LATEST.Cause
conflicting_definitionincrates/solidity-v2/outputs/cargo/semantic/src/passes/common/conflicts.rsis a pairwise comparison that delegates toDefinition::overloads_with:Both operands here are
Definition::ImportedSymbol. The comparison never follows the alias to what was imported, so it can see neither that the two sides resolve to the same target (A) nor that they resolve to distinct overloadable signatures (B).Notes for whoever picks this up
ImportedSymbolto its target set before comparing, then apply the existingoverloads_withrule to the resolved definitions. Short-circuiting on "both sides are functions, therefore compatible" is not sufficient — it would also accept two imported functions with identical signatures, which is a real redeclaration.default_import_closurefor identifier redefinition checking #1956 proposes re-usingdefault_import_closurefor identifier redefinition checking in this same area, and may be the natural implementation vehicle.crates/solidity-v2/testing/snapshots/diagnostics_output/resolution/identifier_redeclaration/. Adding them there also records solc's verdict alongside slang's, which is the cleanest way to confirm the expected behavior rather than relying on a reading of the spec.