From 415d4187efe611ddb53f91e7a078c34e56301040 Mon Sep 17 00:00:00 2001 From: grandizzy Date: Thu, 31 Jul 2025 13:19:18 +0300 Subject: [PATCH 1/2] fix(forge): consistent handling unresolved imports --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 447ec4e02f486..2977c6c9ca909 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4471,9 +4471,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f163b01cdad921f139776084391db2f1f5fb206ce2395f1847f0c1e992a89a4f" +checksum = "081e5cd31d7f94ca23a88ff9d2a414f0499d24374ab69bb6a50b2b1f4c955f01" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -4508,9 +4508,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2676d70082ed23680fe2d08c0b750d5f7f2438c6d946f1cb140a76c5e5e0392" +checksum = "dc590ec3766b4eae5733c2e3e40278164a166523c077171a892cfc8ae30a12e8" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -4518,9 +4518,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ada94dc5946334bb08df574855ba345ab03ba8c6f233560c72c8d61fa9db80" +checksum = "a46722aa9e5534f89ff53fa083eb626986b6b3dff351de4067dd46e0b02eee41" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -4541,9 +4541,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372052af72652e375a6e7eed22179bd8935114e25e1c5a8cca7f00e8f20bd94c" +checksum = "6b609d941469f5f9ceed30cf7e66352a5b646654351f591f54810845cdd7e9a5" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -4556,9 +4556,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf0962c46855979300f6526ed57f987ccf6a025c2b92ce574b281d9cb2ef666b" +checksum = "eaa0e5ea0fc2b656291bdc3e67f55789caa4b7297dda8a37563e57ab4f2ab9fd" dependencies = [ "alloy-primitives", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 95eedc203e0f2..da548723b4715 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -204,7 +204,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.20.0", default-features = false } -foundry-compilers = { version = "0.18.0", default-features = false } +foundry-compilers = { version = "0.18.1", default-features = false } foundry-fork-db = "0.16" solang-parser = { version = "=0.3.9", package = "foundry-solang-parser" } solar-ast = { version = "=0.1.5", default-features = false } From 9271526fecc31f2923e003cc231f839f7ee77364 Mon Sep 17 00:00:00 2001 From: grandizzy Date: Thu, 31 Jul 2025 13:40:40 +0300 Subject: [PATCH 2/2] Add test --- crates/forge/tests/cli/build.rs | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index c0dd0517551d8..76783ca7301c8 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -329,3 +329,46 @@ contract ValidContract {} cmd.args(["build"]).assert_success(); }); + +// +forgetest_init!(test_consistent_build_output, |prj, cmd| { + prj.add_source( + "AContract.sol", + r#" +import {B} from "/badpath/B.sol"; + +contract A is B {} + "#, + ) + .unwrap(); + + prj.add_source( + "CContract.sol", + r#" +import {B} from "badpath/B.sol"; + +contract C is B {} + "#, + ) + .unwrap(); + + cmd.args(["build", "src/AContract.sol"]).assert_failure().stdout_eq(str![[r#" +... +Unable to resolve imports: + "/badpath/B.sol" in "[..]" +with remappings: + forge-std/=[..] +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] + +"#]]); + cmd.forge_fuse().args(["build", "src/CContract.sol"]).assert_failure().stdout_eq(str![[r#" +Unable to resolve imports: + "badpath/B.sol" in "[..]" +with remappings: + forge-std/=[..] +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] + +"#]]); +});