diff --git a/src/artifacts/ast/lowfidelity.rs b/src/artifacts/ast/lowfidelity.rs index 738f4301..64076580 100644 --- a/src/artifacts/ast/lowfidelity.rs +++ b/src/artifacts/ast/lowfidelity.rs @@ -62,7 +62,7 @@ impl Node { /// Represents the source location of a node: `::`. /// /// The `length` and `index` can be -1 which is represented as `None` -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)] pub struct SourceLocation { pub start: usize, pub length: Option, diff --git a/src/artifacts/ast/misc.rs b/src/artifacts/ast/misc.rs index ced7f7a2..67b45231 100644 --- a/src/artifacts/ast/misc.rs +++ b/src/artifacts/ast/misc.rs @@ -4,7 +4,7 @@ use std::{fmt, fmt::Write, str::FromStr}; /// Represents the source location of a node: `::`. /// /// The `start`, `length` and `index` can be -1 which is represented as `None` -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)] pub struct SourceLocation { pub start: Option, pub length: Option, diff --git a/src/artifacts/ast/mod.rs b/src/artifacts/ast/mod.rs index b8ad39e2..c3fc731b 100644 --- a/src/artifacts/ast/mod.rs +++ b/src/artifacts/ast/mod.rs @@ -944,8 +944,7 @@ ast_node!( struct TryCatchClause { block: Block, error_name: String, - #[serde(default, deserialize_with = "serde_helpers::default_for_null")] - parameters: Vec, + parameters: Option, } ); diff --git a/test-data/ast/try_catch.json b/test-data/ast/try_catch.json new file mode 100644 index 00000000..a95e2e19 --- /dev/null +++ b/test-data/ast/try_catch.json @@ -0,0 +1 @@ +{"absolutePath":"src/X.sol","id":40896,"exportedSymbols":{"SomeContract":[40895]},"nodeType":"SourceUnit","src":"0:243:17","nodes":[{"id":40895,"nodeType":"ContractDefinition","src":"0:243:17","nodes":[{"id":40894,"nodeType":"FunctionDefinition","src":"28:213:17","nodes":[],"body":{"id":40893,"nodeType":"Block","src":"50:191:17","nodes":[],"statements":[{"clauses":[{"block":{"id":40880,"nodeType":"Block","src":"75:30:17","statements":[]},"errorName":"","id":40881,"nodeType":"TryCatchClause","src":"75:30:17"},{"block":{"id":40885,"nodeType":"Block","src":"140:30:17","statements":[]},"errorName":"Error","id":40886,"nodeType":"TryCatchClause","parameters":{"id":40884,"nodeType":"ParameterList","parameters":[{"constant":false,"id":40883,"mutability":"mutable","name":"reason","nameLocation":"132:6:17","nodeType":"VariableDeclaration","scope":40886,"src":"118:20:17","stateVariable":false,"storageLocation":"memory","typeDescriptions":{"typeIdentifier":"t_string_memory_ptr","typeString":"string"},"typeName":{"id":40882,"name":"string","nodeType":"ElementaryTypeName","src":"118:6:17","typeDescriptions":{"typeIdentifier":"t_string_storage_ptr","typeString":"string"}},"visibility":"internal"}],"src":"117:22:17"},"src":"106:64:17"},{"block":{"id":40890,"nodeType":"Block","src":"205:30:17","statements":[]},"errorName":"","id":40891,"nodeType":"TryCatchClause","parameters":{"id":40889,"nodeType":"ParameterList","parameters":[{"constant":false,"id":40888,"mutability":"mutable","name":"lowLevelData","nameLocation":"191:12:17","nodeType":"VariableDeclaration","scope":40891,"src":"178:25:17","stateVariable":false,"storageLocation":"memory","typeDescriptions":{"typeIdentifier":"t_bytes_memory_ptr","typeString":"bytes"},"typeName":{"id":40887,"name":"bytes","nodeType":"ElementaryTypeName","src":"178:5:17","typeDescriptions":{"typeIdentifier":"t_bytes_storage_ptr","typeString":"bytes"}},"visibility":"internal"}],"src":"177:27:17"},"src":"171:64:17"}],"externalCall":{"arguments":[],"expression":{"argumentTypes":[],"expression":{"id":40877,"name":"this","nodeType":"Identifier","overloadedDeclarations":[],"referencedDeclaration":-28,"src":"64:4:17","typeDescriptions":{"typeIdentifier":"t_contract$_SomeContract_$40895","typeString":"contract SomeContract"}},"id":40878,"isConstant":false,"isLValue":false,"isPure":false,"lValueRequested":false,"memberLocation":"69:3:17","memberName":"foo","nodeType":"MemberAccess","referencedDeclaration":40894,"src":"64:8:17","typeDescriptions":{"typeIdentifier":"t_function_external_nonpayable$__$returns$__$","typeString":"function () external"}},"id":40879,"isConstant":false,"isLValue":false,"isPure":false,"kind":"functionCall","lValueRequested":false,"nameLocations":[],"names":[],"nodeType":"FunctionCall","src":"64:10:17","tryCall":true,"typeDescriptions":{"typeIdentifier":"t_tuple$__$","typeString":"tuple()"}},"id":40892,"nodeType":"TryStatement","src":"60:175:17"}]},"functionSelector":"c2985578","implemented":true,"kind":"function","modifiers":[],"name":"foo","nameLocation":"37:3:17","parameters":{"id":40875,"nodeType":"ParameterList","parameters":[],"src":"40:2:17"},"returnParameters":{"id":40876,"nodeType":"ParameterList","parameters":[],"src":"50:0:17"},"scope":40895,"stateMutability":"nonpayable","virtual":false,"visibility":"public"}],"abstract":false,"baseContracts":[],"canonicalName":"SomeContract","contractDependencies":[],"contractKind":"contract","fullyImplemented":true,"linearizedBaseContracts":[40895],"name":"SomeContract","nameLocation":"9:12:17","scope":40896,"usedErrors":[],"usedEvents":[]}]} \ No newline at end of file