Skip to content

Commit a1da952

Browse files
authored
chore(lint): re-use project output (#11563)
* chore(lint): re-use project output * patch * upd * fix: lower * update, bless, fix tests to compile with solc * pragma * blessings * j1 * bump * bless * bless * hide
1 parent d6e6f86 commit a1da952

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3102
-2850
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ _
1818
.vite
1919
.wrangler
2020
build
21-
*.zip
21+
*.zip

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,7 @@ foundry-block-explorers = { version = "0.22.0", default-features = false }
210210
foundry-compilers = { version = "0.19.1", default-features = false }
211211
foundry-fork-db = "0.18"
212212
solang-parser = { version = "=0.3.9", package = "foundry-solang-parser" }
213-
solar = { package = "solar-compiler", version = "=0.1.6", default-features = false }
214-
# TODO: remove in next solar release: https://github.com/paradigmxyz/solar/pull/444
215-
solar-interface = { version = "=0.1.6", default-features = false }
213+
solar = { package = "solar-compiler", version = "=0.1.7", default-features = false }
216214

217215
## alloy
218216
alloy-consensus = { version = "1.0.23", default-features = false }
@@ -415,7 +413,7 @@ rexpect = { git = "https://github.com/rust-cli/rexpect", rev = "2ed0b1898d7edaf6
415413

416414
## foundry
417415
# foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers.git", rev = "f5b46b2" }
418-
# foundry-compilers = { git = "https://github.com/foundry-rs/compilers.git", rev = "e4a9b04" }
416+
# foundry-compilers = { git = "https://github.com/foundry-rs/compilers.git", branch = "dani/bump-solar" }
419417
# foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "eee6563" }
420418

421419
## solar

crates/chisel/src/solidity_helper.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,19 @@ impl SolidityHelper {
152152
let mut stack = vec![];
153153
for token in Cursor::new(input) {
154154
match token.kind {
155-
OpenParen | OpenBrace | OpenBracket => stack.push(token.kind),
156-
CloseParen | CloseBrace | CloseBracket => match (stack.pop(), token.kind) {
157-
(Some(OpenParen), CloseParen)
158-
| (Some(OpenBrace), CloseBrace)
159-
| (Some(OpenBracket), CloseBracket) => {}
155+
OpenDelim(delim) => stack.push(delim),
156+
CloseDelim(delim) => match (stack.pop(), delim) {
157+
(Some(open), close) if open == close => {}
160158
(Some(wanted), _) => {
159+
let wanted = wanted.to_open_str();
161160
return ValidationResult::Invalid(Some(format!(
162-
"Mismatched brackets: {wanted:?} is not properly closed"
161+
"Mismatched brackets: `{wanted}` is not properly closed"
163162
)));
164163
}
165164
(None, c) => {
165+
let c = c.to_close_str();
166166
return ValidationResult::Invalid(Some(format!(
167-
"Mismatched brackets: {c:?} is unpaired"
167+
"Mismatched brackets: `{c}` is unpaired"
168168
)));
169169
}
170170
},

crates/common/src/errors/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ fn all_sources<E: private::ErrorChain + ?Sized>(err: &E) -> Vec<String> {
4444
err.chain().map(|cause| cause.to_string().trim().to_string()).collect()
4545
}
4646

47+
/// Converts solar errors to an eyre error.
48+
pub fn convert_solar_errors(dcx: &solar::interface::diagnostics::DiagCtxt) -> eyre::Result<()> {
49+
match dcx.emitted_errors() {
50+
Some(Ok(())) => Ok(()),
51+
Some(Err(e)) if !e.is_empty() => eyre::bail!("solar run failed:\n\n{e}"),
52+
_ if dcx.has_errors().is_err() => eyre::bail!("solar run failed"),
53+
_ => Ok(()),
54+
}
55+
}
56+
4757
#[cfg(test)]
4858
mod tests {
4959
use super::*;

crates/common/src/preprocessor/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::errors::convert_solar_errors;
12
use foundry_compilers::{
23
Compiler, ProjectPathsConfig, SourceParser, apply_updates,
34
artifacts::SolcLanguage,
@@ -22,7 +23,7 @@ use deps::{PreprocessorDependencies, remove_bytecode_dependencies};
2223
/// Returns the range of the given span in the source map.
2324
#[track_caller]
2425
fn span_to_range(source_map: &SourceMap, span: Span) -> Range<usize> {
25-
source_map.span_to_source(span).unwrap().1
26+
source_map.span_to_range(span).unwrap()
2627
}
2728

2829
/// Preprocessor that replaces static bytecode linking in tests and scripts (`new Contract`) with
@@ -97,8 +98,8 @@ impl Preprocessor<SolcCompiler> for DynamicTestLinkingPreprocessor {
9798
});
9899

99100
// Warn if any diagnostics emitted during content parsing.
100-
if let Err(err) = compiler.sess().emitted_errors().unwrap() {
101-
warn!("failed preprocessing:\n{err}");
101+
if let Err(err) = convert_solar_errors(compiler.dcx()) {
102+
warn!(%err, "failed preprocessing");
102103
}
103104

104105
Ok(())

0 commit comments

Comments
 (0)