Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve incompatible solidity versions error formatting #43

Open
mattsse opened this issue Jan 12, 2024 · 2 comments
Open

Improve incompatible solidity versions error formatting #43

mattsse opened this issue Jan 12, 2024 · 2 comments
Assignees

Comments

@mattsse
Copy link
Member

mattsse commented Jan 12, 2024

ref foundry-rs/foundry#6722

this should improve error formatting and ideally highlight the conflicting versions

let mut msg = String::new();
self.format_imports_list(idx, &mut msg).unwrap();
errors.push(format!("Found incompatible Solidity versions:\n{msg}"));

@AbhinavMir
Copy link

AbhinavMir commented Feb 10, 2024

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

@AbhinavMir
Copy link

AbhinavMir commented Feb 15, 2024

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    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants