Bug(forge build
): ambiguity in source unit IDs with incremental builds affects source maps
#6067
Closed
2 tasks done
Labels
C-forge
Command: forge
Cmd-forge-build
Command: forge build
T-bug
Type: bug
T-to-investigate
Type: to investigate
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (490b588 2023-10-19T00:17:56.537546457Z)
What command(s) is the bug in?
forge build
Operating System
Linux
Describe the bug
I observed that source maps exhibit some ambiguity in relation to their source unit IDs during incremental builds. Specifically, upon building a project and adding a new contract within a new file, followed by another build, the new file incorrectly receives a source unit ID of
0
already utilized. Consequently, multiple source units now share an identical ID, creating confusion about which file certain source unit entries within the source maps correspond.Steps to Reproduce
Initialize a new contract file under
src/First.sol
with the ensuing content:Execute the command
forge build
.Subsequently, create an additional contract within
src/Second.sol
including the following:Run the command
forge build
once again.Proceed by examining the generated output artifacts, specifically
out/First.sol/First.json
andout/Second.sol/Second.json
, noting that the content is abbreviated for brevity. The contents are as follows:Current Behavior
The artifacts generated post-build, namely
First.json
andSecond.json
, both possess anid
attribute at the top level with a value of0
. Thisid
ostensibly represents the source unit ID. However, the source maps within each artifact refer to this identical ID, leading to an ambiguity as to the actual source unit to which the source maps are referring.Expected Behavior
Each unique source unit or file should be assigned a distinct source unit ID to prevent overlaps, thereby eliminating any ambiguity in the source maps. This clear distinction is vital for ensuring the source maps accurately reflect their corresponding source units, especially in incremental build environments.
The text was updated successfully, but these errors were encountered: