fix(solc): can parse secondary source locations (#849)

This commit is contained in:
Matthias Seitz 2022-01-31 22:54:49 +01:00 committed by GitHub
parent 2b178e9cf7
commit 5fefb2b721
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View File

@ -1733,7 +1733,7 @@ pub struct Error {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub source_location: Option<SourceLocation>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub secondary_source_locations: Vec<SourceLocation>,
pub secondary_source_locations: Vec<SecondarySourceLocation>,
pub r#type: String,
pub component: String,
pub severity: Severity,
@ -1845,6 +1845,13 @@ pub struct SourceLocation {
pub file: String,
pub start: i32,
pub end: i32,
}
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct SecondarySourceLocation {
pub file: Option<String>,
pub start: Option<i32>,
pub end: Option<i32>,
pub message: Option<String>,
}

View File

@ -378,3 +378,26 @@ fn can_flatten_file_with_duplicates() {
assert_eq!(result.matches("contract FooBar {").count(), 1);
assert_eq!(result.matches(";").count(), 1);
}
#[test]
fn can_detect_type_error() {
let project = TempProject::<MinimalCombinedArtifacts>::dapptools().unwrap();
project
.add_source(
"Contract",
r#"
pragma solidity ^0.8.10;
contract Contract {
function xyz() public {
require(address(0), "Error");
}
}
"#,
)
.unwrap();
let compiled = project.compile().unwrap();
assert!(compiled.has_compiler_errors());
}