Skip to content

Conversation

@ep0chzer0
Copy link

Summary

Fixes #664

The call-graph printer was using just function.name for node IDs and labels, causing overloaded functions (same name, different signatures) to appear as the same node. This made it look like functions were calling themselves when they were actually calling an overloaded variant.

Problem

For the SafeMath library example in the issue:

function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    return sub(a, b, "SafeMath: subtraction overflow");
}

function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
    require(b <= a, errorMessage);
    return a - b;
}

The graph showed subsub, making it look like a self-call.

Solution

  • Use function.full_name (includes parameter types) for node IDs to ensure each overloaded function gets a unique node
  • Use function.full_name for labels so users can distinguish between overloaded functions in the graph
  • Use function.solidity_signature for Variables (public state variables) to maintain consistency

Before/After

Before:

"SafeMath.sub" -> "SafeMath.sub"

After:

"SafeMath.sub(uint256,uint256)" -> "SafeMath.sub(uint256,uint256,string)"

Test Plan

  • Verify overloaded functions get unique node IDs
  • Verify labels show full signatures
  • Run black formatter

🤖 Generated with Claude Code

@ep0chzer0 ep0chzer0 requested a review from smonicas as a code owner January 16, 2026 11:50
@ep0chzer0
Copy link
Author

Hello maintainers! This fixes the long-standing issue where overloaded functions appeared as self-calls in the call graph. The fix uses full_name instead of just name for node IDs and labels. Could you please approve the CI workflows to run? Thank you!

@ep0chzer0 ep0chzer0 force-pushed the fix/callgraph-overloaded-functions branch 2 times, most recently from bf8ef4b to 8f87a1f Compare January 16, 2026 13:35
The call-graph printer was using just `function.name` for node IDs
and labels, causing overloaded functions (same name, different
signatures) to appear as the same node. For example, `sub(uint256,uint256)`
and `sub(uint256,uint256,string)` would both appear as "sub" and look
like the function was calling itself.

Changes:
- Use `function.full_name` (includes parameter types) for node IDs
  to ensure each overloaded function gets a unique node
- Use `function.full_name` for labels so users can distinguish
  between overloaded functions in the graph
- Use `function.solidity_signature` for Variables to maintain
  consistency with the signature-based approach

Before:
```
"SafeMath.sub" -> "SafeMath.sub"  (looks like self-call)
```

After:
```
"SafeMath.sub(uint256,uint256)" -> "SafeMath.sub(uint256,uint256,string)"
```

Fixes crytic#664
@ep0chzer0 ep0chzer0 force-pushed the fix/callgraph-overloaded-functions branch from 8f87a1f to c000d8f Compare January 16, 2026 23:28
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.

[BUG] The feature (print call-graph) of Slither cannot correctly distinguish functions with the same name (i.e., overload) in a contract .

1 participant