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
@DaniPopes any idea if this is related to #6522? I'm pretty sure it's been broken for longer, but something about looking up sourcemaps from inherited contracts is broken at some point. Trying my best to figure out if that's loading the sources when building the debugger or when looking up the pc in the map.
ContractSources is a mapping of name -> id -> (source code, bytecode)
In src_map, the source for the contract is looked up by name. Since this may return multiple contracts with the same name, the entries are iterated over and the SourceElement's index is compared to the file_id of the current contract source. If they match, the source code is returned.
The problem is that this will never return source code for inherited contracts, because it is only loading source code for (contracts with the same name as) the contract being invoked; if the SourceElement points to a different index (aka file_id), it will never match any of the contract sources loaded from ContractSources.
ContractSources should maintain an index both of name -> id -> (source, bytecode)andid -> (source, bytecode) for looking up cross-source sourcemaps.
@emo-eth I having this same issue where the contract source is not loaded. I am reading your comments here but it doesn't mention anything about how to resolve it. Can you share how to get the contract to be loaded on the debug panel?
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (2cf84d9 2024-02-07T00:15:49.638525000Z)
What command(s) is the bug in?
forge test --debug
Operating System
None
Describe the bug
Sourcemaps for inherited contracts are not found/shown by the Forge test debugger.
In this case, the call to the inheriting contract is displayed correctly with sourcemap:
But once the function is dispatched to the inherited contract (
JUMPI
->JUMPDEST
), the debugger reports no sourcemap:Code for minimal repro; run with
forge clean; forge test --debug test_Increment.
Tested with solc0.8.13
and0.8.23
.Counter.sol
AltCounter.sol (inheriting contract)
Counter.t.sol
The text was updated successfully, but these errors were encountered: