compilers icon indicating copy to clipboard operation
compilers copied to clipboard

Improve incompatible solidity versions error formatting

Open mattsse opened this issue 1 year ago • 2 comments

ref https://github.com/foundry-rs/foundry/issues/6722

this should improve error formatting and ideally highlight the conflicting versions

https://github.com/foundry-rs/compilers/blob/314c9171c3c09a90dd528c4884bc1b3da569308b/src/resolver/mod.rs#L607-L609

mattsse avatar Jan 12 '24 13:01 mattsse

would love to take this on sometime this week. :)

AbhinavMir avatar Feb 10 '24 05:02 AbhinavMir

Hi @mattsse ! How do I get foundry_compilers to throw errors when compiling faulty code? I wrote a Solidity code with syntax errors, and expect it to fail, but foundry_compilers compiles it.

use foundry_compilers::{Project, ProjectPathsConfig};

fn main() {
    let project = Project::builder()
        .paths(ProjectPathsConfig::hardhat("/home/august/bad_code_solidity_hardhat").unwrap())
        .build()
        .unwrap();

    if let Err(e) = project.compile() {
        // The compilation failed, `e` contains the error.
        eprintln!("Compilation failed with error: {:?}", e);
    }

    project.rerun_if_sources_changed();
}

When I do cargo run I get the following output

   Compiling compiler-test v0.1.0 (..../compiler-test)
    Finished dev [unoptimized + debuginfo] target(s) in 2.16s
     Running `target/debug/compiler-test`
cargo:rerun-if-changed=/home/august/bad_code_solidity_hardhat
Time taken: 2 seconds    

AbhinavMir avatar Feb 15 '24 05:02 AbhinavMir