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
Have you ensured that all of these are up to date?
Foundry
Foundryup
What version of Foundry are you on?
forge --version
What command(s) is the bug in?
forge test --debug
Operating System
macOS (Apple Silicon)
Describe the bug
Sourcemaps in the Forge debugger have been flaky for a while now; see #5435 for an example.
I've finally come across a minimal reproduction – with the caveat that the error displayed in this reproduction is different from the one I'm used to seeing. The error displayed by this reproduction is No PC-IC maps for contract <contract>; I am used to seeingNo source map for contract <contract>.
Currently, source maps break for any contract/library that contains any invocations of an external library method (of any nested depth). The source maps for the library itself are unaffected (as long as that library does not invoke any external library methods).
Since I never normally use external library methods, this is definitely not the issue I usually run into.
(As a side note, I know coverage for libraries also has many issues; I can't help but wonder if this is related. See #2567 for discussion and other relevant linked issues).
Note that internal library function invocations do not seem to break sourcemaps, at least in this reproduction.
Reproduce with the following contracts by running forge test --debug test_Increment
Counter.sol
// SPDX-License-Identifier: MITpragma solidity^0.8.13;
/** * Sourcemaps for this ContractDefinition work because it does not invoke any * library functions. */libraryCountable {
function increment(uint256number) publicpurereturns (uint256) {
return++number;
}
function setNumber(uint256, uint256newNumber) publicpurereturns (uint256) {
return newNumber;
}
}
/** * Sourcemaps for this ContractDefinition *do not work* because it invokes * the above library functions. */libraryNestedCountable {
using Countableforuint256;
function increment(uint256number) publicpurereturns (uint256) {
return number.increment();
}
function setNumber(uint256number, uint256newNumber) publicpurereturns (uint256) {
return number.setNumber(newNumber);
}
}
/** * Sourcemaps for this ContractDefinition do not work because it invokes * the NestedCountable library's functions */contractCounter {
uint256public number;
function setNumber(uint256newNumber) public {
number = NestedCountable.setNumber(number, newNumber);
}
function increment() public {
number = NestedCountable.increment(number);
}
}
Counter.t.sol
// SPDX-License-Identifier: MITpragma solidity^0.8.13;
import {Test, console} from"forge-std/Test.sol";
import {Counter} from"src/Counter.sol";
/** * Sourcemaps for this test ContractDefinition do not work because it contains * a reference to Counter, which invokes library functions. */contractCounterTestisTest {
Counter public counter;
function setUp() public {
counter =newCounter();
counter.setNumber(0);
}
function test_Increment() public {
counter.increment();
assertEq(counter.number(), 1);
}
function testFuzz_SetNumber(uint256x) public {
counter.setNumber(x);
assertEq(counter.number(), x);
}
}
The text was updated successfully, but these errors were encountered:
emo-eth
changed the title
Forge test debugger is unable to load sourcemaps for any ContractDefinition that invokes library functions
Forge test debugger is unable to load sourcemaps for any ContractDefinition that contains references invoking library functions
Feb 7, 2024
emo-eth
changed the title
Forge test debugger is unable to load sourcemaps for any ContractDefinition that contains references invoking library functions
Forge test debugger is unable to load sourcemaps for any ContractDefinition that contains references invoking external library functions
Feb 7, 2024
Currently, source maps break for any contract/library that contains any invocations of an internal library method (of any nested depth – note that I did not try external methods).
The example only contains public/external functions in the library, is this intentional?
Currently, source maps break for any contract/library that contains any invocations of an internal library method (of any nested depth – note that I did not try external methods).
The example only contains public/external functions in the library, is this intentional?
Sorry, edited a few times – current edit I think should be accurate:
External function invocations break sourcemaps – internal function invocations are fine.
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge --version
What command(s) is the bug in?
forge test --debug
Operating System
macOS (Apple Silicon)
Describe the bug
Sourcemaps in the Forge debugger have been flaky for a while now; see #5435 for an example.
I've finally come across a minimal reproduction – with the caveat that the error displayed in this reproduction is different from the one I'm used to seeing. The error displayed by this reproduction is
No PC-IC maps for contract <contract>
; I am used to seeingNo source map for contract <contract>
.Currently, source maps break for any contract/library that contains any invocations of an external
library
method (of any nested depth). The source maps for the library itself are unaffected (as long as that library does not invoke any external library methods).Since I never normally use external library methods, this is definitely not the issue I usually run into.
(As a side note, I know coverage for libraries also has many issues; I can't help but wonder if this is related. See #2567 for discussion and other relevant linked issues).
Note that internal library function invocations do not seem to break sourcemaps, at least in this reproduction.
Reproduce with the following contracts by running
forge test --debug test_Increment
Counter.sol
Counter.t.sol
The text was updated successfully, but these errors were encountered: