Skip to content

Commit 2c90332

Browse files
authored
Some fields are optional during "stopAfter":"parsing" (#271)
Trivial patch. Reproduce: ```bash echo '{"language":"Solidity","sources":{"test.sol":{"content":"contract TT {\\n function main() public {}\\n}"}},"settings":{"stopAfter":"parsing","optimizer":{"enabled":false,"runs":200},"outputSelection":{"*":{"":["ast"],"*":[]}},"viaIR":true,"libraries":{}}}' | solc --standard-json ``` Since there is no semantics analysis when stopping after parsing, `scope` along with a few other fields are not available and this PR marks all `scope` to be optional.
1 parent 61ef8a3 commit 2c90332

File tree

1 file changed

+14
-6
lines changed
  • crates/artifacts/solc/src/ast

1 file changed

+14
-6
lines changed

crates/artifacts/solc/src/ast/mod.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,14 @@ ast_node!(
175175
#[serde(rename = "contractKind")]
176176
kind: ContractKind,
177177
documentation: Option<Documentation>,
178-
fully_implemented: bool,
178+
// Not available when "stopAfter": "parsing" is specified.
179+
fully_implemented: Option<bool>,
180+
// Not available when "stopAfter": "parsing" is specified.
181+
#[serde(default)]
179182
linearized_base_contracts: Vec<usize>,
180183
nodes: Vec<ContractDefinitionPart>,
181-
scope: usize,
184+
// Not available when "stopAfter": "parsing" is specified.
185+
scope: Option<usize>,
182186
#[serde(default, deserialize_with = "serde_helpers::default_for_null")]
183187
used_errors: Vec<usize>,
184188
#[serde(default, deserialize_with = "serde_helpers::default_for_null")]
@@ -536,7 +540,8 @@ ast_node!(
536540
#[serde(default)]
537541
mutability: Option<Mutability>,
538542
overrides: Option<OverrideSpecifier>,
539-
scope: usize,
543+
// Not available when "stopAfter": "parsing" is specified.
544+
scope: Option<usize>,
540545
storage_location: StorageLocation,
541546
type_descriptions: TypeDescriptions,
542547
type_name: Option<TypeName>,
@@ -713,7 +718,8 @@ ast_node!(
713718
overrides: Option<OverrideSpecifier>,
714719
parameters: ParameterList,
715720
return_parameters: ParameterList,
716-
scope: usize,
721+
// Not available when "stopAfter": "parsing" is specified.
722+
scope: Option<usize>,
717723
visibility: Visibility,
718724
/// The kind of function this node defines. Only valid for Solidity versions 0.5.x and
719725
/// above.
@@ -1028,7 +1034,8 @@ ast_node!(
10281034
name_location: Option<SourceLocation>,
10291035
canonical_name: String,
10301036
members: Vec<VariableDeclaration>,
1031-
scope: usize,
1037+
// Not available when "stopAfter": "parsing" is specified.
1038+
scope: Option<usize>,
10321039
visibility: Visibility,
10331040
}
10341041
);
@@ -1082,7 +1089,8 @@ ast_node!(
10821089
file: String,
10831090
#[serde(default, with = "serde_helpers::display_from_str_opt")]
10841091
name_location: Option<SourceLocation>,
1085-
scope: usize,
1092+
// Not available when "stopAfter": "parsing" is specified.
1093+
scope: Option<usize>,
10861094
source_unit: usize,
10871095
symbol_aliases: Vec<SymbolAlias>,
10881096
unit_alias: String,

0 commit comments

Comments
 (0)