[Bug-Candidate]: "Impossible to generate IR" when a `using for` library function is called on a mixed-width sum whose left operand is narrower
Author: vbarCreated Sep 24, 2026Updated Sep 24, 2026
Labelsbug-candidate
Describe the issue:
Slither fails to generate IR for a function that calls a using ... for uint256 library function on a parenthesized sum (a + b) where a is uint128 and b is uint256. Solidity widens the sum to uint256, so the call is valid and compiles.
Swapping the operands (b + a), casting explicitly (uint256(a) + b), or assigning the sum to a local variable first all avoid the error.
Code example to reproduce the issue:
pragma solidity ^0.8.0; import { SafeCastLib } from "./SafeCastLib.sol";
contract A { using SafeCastLib for uint256;
// ERROR: Impossible to generate IR
function leftNarrow(uint128 a, uint256 d) internal pure returns (uint128) {
return (a + d).safeCastTo128();
}
// OK
function rightNarrow(uint128 a, uint256 d) internal pure returns (uint128) {
return (d + a).safeCastTo128();
}
function run() external pure { leftNarrow(1, 2); rightNarrow(1, 2); }
}
Version:
slither 0.11.6
Relevant log output:
ERROR:ContractSolcParsing:Impossible to generate IR for A.leftNarrow (src/A.sol#5):
'NoneType' object has no attribute 'parameters'Source: crytic/slither