Skip to content

Commit 0ac1878

Browse files
authored
chore(lint): correctly show solar errors (#11713)
1 parent 4163af0 commit 0ac1878

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

crates/forge/src/cmd/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{install, watch::WatchArgs};
22
use clap::Parser;
3-
use eyre::{Result, eyre};
3+
use eyre::{Context, Result};
44
use forge_lint::{linter::Linter, sol::SolidityLinter};
55
use foundry_cli::{
66
opts::BuildOpts,
@@ -115,7 +115,7 @@ impl BuildArgs {
115115
// Only run the `SolidityLinter` if lint on build and no compilation errors.
116116
if config.lint.lint_on_build && !output.output().errors.iter().any(|e| e.is_error()) {
117117
self.lint(&project, &config, self.paths.as_deref(), &mut output)
118-
.map_err(|err| eyre!("Lint failed: {err}"))?;
118+
.wrap_err("Lint failed")?;
119119
}
120120

121121
Ok(output)

crates/lint/src/sol/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ impl<'a> Linter for SolidityLinter<'a> {
223223
type Lint = SolLint;
224224

225225
fn lint(&self, input: &[PathBuf], compiler: &mut Compiler) -> eyre::Result<()> {
226+
convert_solar_errors(compiler.dcx())?;
227+
226228
let ui_testing = std::env::var_os("FOUNDRY_LINT_UI_TESTING").is_some();
227229

228230
let sm = compiler.sess().clone_source_map();
@@ -241,9 +243,8 @@ impl<'a> Linter for SolidityLinter<'a> {
241243
}
242244

243245
compiler.enter_mut(|compiler| -> eyre::Result<()> {
244-
if compiler.gcx().stage() == Some(solar::config::CompilerStage::Parsing) {
246+
if compiler.gcx().stage() < Some(solar::config::CompilerStage::Lowering) {
245247
let _ = compiler.lower_asts();
246-
convert_solar_errors(compiler.dcx())?;
247248
}
248249

249250
let gcx = compiler.gcx();
@@ -272,7 +273,7 @@ impl<'a> Linter for SolidityLinter<'a> {
272273
let _ = self.process_source_hir(gcx, hir_source_id, path, &inline_config);
273274
});
274275

275-
Ok(())
276+
convert_solar_errors(compiler.dcx())
276277
})?;
277278

278279
let sess = compiler.sess_mut();
@@ -282,7 +283,7 @@ impl<'a> Linter for SolidityLinter<'a> {
282283
sess.reconfigure();
283284
}
284285

285-
convert_solar_errors(compiler.dcx())
286+
Ok(())
286287
}
287288
}
288289

0 commit comments

Comments
 (0)