Inheritance Order
Detects incorrect C3 linearization order in multiple inheritance that can cause unexpected function resolution and storage layout issues.
Inheritance Order
Overview
The inheritance order detector identifies contracts with multiple inheritance where the linearization order may cause unexpected behavior. Solidity uses C3 linearization to resolve which parent’s function is called when multiple parents define the same function. Incorrect ordering can cause storage layout shifts and unexpected function dispatch.
Detection Methodology
Analyzes the inheritance graph for: ambiguous function resolution, storage layout conflicts between parent contracts, and diamond inheritance patterns where the most-derived override is not the expected one.
Examples
Sample Sigvex Output
{
"detector_id": "inheritance-order",
"severity": "low",
"confidence": 0.70,
"description": "Contract inherits from ParentA and ParentB, both defining withdraw(). The C3 linearization resolves to ParentB.withdraw(), which may not be the intended behavior.",
"location": { "function": "contract-level", "offset": 0 }
}
Related Detectors
- Shadowing — variable shadowing
- Storage Collision — storage layout issues