Skip to content

Commit cf2e4fb

Browse files
committed
chore(forge): filter out old solidity versions
1 parent 0597b0e commit cf2e4fb

File tree

4 files changed

+29
-30
lines changed

4 files changed

+29
-30
lines changed

Cargo.lock

Lines changed: 11 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ rexpect = { git = "https://github.com/rust-cli/rexpect", rev = "2ed0b1898d7edaf6
444444
# foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "eee6563" }
445445

446446
# solar
447-
# solar = { package = "solar-compiler", git = "https://github.com/paradigmxyz/solar.git", branch = "main" }
448-
# solar-interface = { package = "solar-interface", git = "https://github.com/paradigmxyz/solar.git", branch = "main" }
449-
# solar-ast = { package = "solar-ast", git = "https://github.com/paradigmxyz/solar.git", branch = "main" }
450-
# solar-sema = { package = "solar-sema", git = "https://github.com/paradigmxyz/solar.git", branch = "main" }
447+
solar = { package = "solar-compiler", git = "https://github.com/paradigmxyz/solar.git", branch = "main" }
448+
solar-interface = { package = "solar-interface", git = "https://github.com/paradigmxyz/solar.git", branch = "main" }
449+
solar-ast = { package = "solar-ast", git = "https://github.com/paradigmxyz/solar.git", branch = "main" }
450+
solar-sema = { package = "solar-sema", git = "https://github.com/paradigmxyz/solar.git", branch = "main" }

crates/cli/src/opts/build/utils.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ use foundry_compilers::{
77
};
88
use foundry_config::{Config, semver::Version};
99
use rayon::prelude::*;
10-
use solar::sema::ParsingContext;
10+
use solar::{interface::MIN_SOLIDITY_VERSION as MSV, sema::ParsingContext};
1111
use std::{
1212
collections::{HashSet, VecDeque},
1313
path::{Path, PathBuf},
1414
};
1515

16+
const MIN_SUPPORTED_VERSION: Version = Version::new(MSV.0, MSV.1, MSV.2);
17+
1618
/// Configures a [`ParsingContext`] from [`Config`].
1719
///
1820
/// - Configures include paths, remappings
@@ -59,10 +61,16 @@ pub fn configure_pcx(
5961
.ok_or_else(|| eyre::eyre!("no Solidity sources"))?
6062
.1
6163
.into_iter()
64+
// Filter unsupported versions
65+
.filter(|(v, _, _)| v >= &MIN_SUPPORTED_VERSION)
6266
// Always pick the latest version
6367
.max_by(|(v1, _, _), (v2, _, _)| v1.cmp(v2))
6468
.unwrap();
6569

70+
if sources.is_empty() {
71+
sh_warn!("no files found. Solar doesn't support Solidity versions prior to 0.8.0")?;
72+
}
73+
6674
let solc = SolcVersionedInput::build(
6775
sources,
6876
config.solc_settings()?,
@@ -125,12 +133,14 @@ pub fn configure_pcx_from_compile_output(
125133

126134
// Read all sources and find the latest version.
127135
let (version, sources) = {
128-
let (mut max_version, mut sources) = (Version::new(0, 0, 0), Sources::new());
136+
let (mut max_version, mut sources) = (MIN_SUPPORTED_VERSION, Sources::new());
129137
for (id, _) in output.artifact_ids() {
130138
if let Ok(path) = dunce::canonicalize(&id.source)
131139
&& source_paths.remove(&path)
132140
{
133-
if id.version > max_version {
141+
if id.version < MIN_SUPPORTED_VERSION {
142+
continue;
143+
} else if max_version < id.version {
134144
max_version = id.version;
135145
};
136146

crates/forge/src/multi_runner.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,7 @@ impl MultiContractRunnerBuilder {
572572
if files.is_empty() { None } else { Some(&files) },
573573
)?;
574574
pcx.parse();
575-
// Check if any sources exist, to avoid logging `error: no files found`
576-
if !compiler.sess().source_map().is_empty() {
577-
let _ = compiler.lower_asts();
578-
}
575+
let _ = compiler.lower_asts();
579576
Ok(())
580577
})?;
581578

0 commit comments

Comments
 (0)