Skip to content

Commit 458b2fa

Browse files
fix: sanitize settings.optimizer.details.inliner (#216)
Ref foundry-rs/foundry#9322 (comment) argotorg/solidity#15576 (comment) Set inliner to None since it is properly supported from 0.8.5 version( see `Standard JSON: Properly allow the inliner setting under settings.optimizer.details` https://soliditylang.org/blog/2021/06/10/solidity-0.8.5-release-announcement/) --------- Co-authored-by: DaniPopes <[email protected]>
1 parent 3b82e5b commit 458b2fa

File tree

1 file changed

+24
-0
lines changed
  • crates/artifacts/solc/src

1 file changed

+24
-0
lines changed

crates/artifacts/solc/src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,14 @@ impl Settings {
314314
self.via_ir = None;
315315
}
316316

317+
const V0_8_5: Version = Version::new(0, 8, 5);
318+
if *version < V0_8_5 {
319+
// introduced in 0.8.5 <https://github.com/ethereum/solidity/releases/tag/v0.8.5>
320+
if let Some(optimizer_details) = &mut self.optimizer.details {
321+
optimizer_details.inliner = None;
322+
}
323+
}
324+
317325
const V0_8_7: Version = Version::new(0, 8, 7);
318326
if *version < V0_8_7 {
319327
// lower the disable version from 0.8.10 to 0.8.7, due to `divModNoSlacks`,
@@ -2221,4 +2229,20 @@ mod tests {
22212229
let content = fs::read_to_string(path).unwrap();
22222230
let _output: CompilerOutput = serde_json::from_str(&content).unwrap();
22232231
}
2232+
2233+
// <https://github.com/foundry-rs/foundry/issues/9322>
2234+
#[test]
2235+
fn can_sanitize_optimizer_inliner() {
2236+
let version: Version = "0.8.4".parse().unwrap();
2237+
let settings = Settings::default().with_via_ir_minimum_optimization();
2238+
2239+
let input =
2240+
SolcInput { language: SolcLanguage::Solidity, sources: Default::default(), settings };
2241+
2242+
let i = input.clone().sanitized(&version);
2243+
assert!(i.settings.optimizer.details.unwrap().inliner.is_none());
2244+
2245+
let i = input.sanitized(&Version::new(0, 8, 5));
2246+
assert_eq!(i.settings.optimizer.details.unwrap().inliner, Some(false));
2247+
}
22242248
}

0 commit comments

Comments
 (0)