diff --git a/src/artifacts/ast/mod.rs b/src/artifacts/ast/mod.rs index d54a2e28..0e60444a 100644 --- a/src/artifacts/ast/mod.rs +++ b/src/artifacts/ast/mod.rs @@ -810,7 +810,7 @@ stmt_node!( stmt_node!( /// A do while statement. struct DoWhileStatement { - block: Block, + body: Block, condition: Expression, } ); diff --git a/src/artifacts/ast/visitor.rs b/src/artifacts/ast/visitor.rs index 336f74f3..b1168493 100644 --- a/src/artifacts/ast/visitor.rs +++ b/src/artifacts/ast/visitor.rs @@ -411,7 +411,7 @@ impl_walk!(ForStatement, visit_for_statement, |for_statement, visitor| { }); impl_walk!(DoWhileStatement, visit_do_while_statement, |do_while_statement, visitor| { - do_while_statement.block.walk(visitor); + do_while_statement.body.walk(visitor); do_while_statement.condition.walk(visitor); }); diff --git a/test-data/ast/do_while.json b/test-data/ast/do_while.json new file mode 100644 index 00000000..5f8bda05 --- /dev/null +++ b/test-data/ast/do_while.json @@ -0,0 +1 @@ +{"absolutePath":"script/SomeScript.sol","id":39709,"exportedSymbols":{"Script":[113],"ScriptBase":[74],"SomeScript":[39708],"StdChains":[877],"StdCheatsSafe":[2937],"StdStorage":[4496],"StdStyle":[7346],"StdUtils":[8073],"VmSafe":[9693],"console":[18328],"console2":[26453],"safeconsole":[39691],"stdJson":[4322],"stdMath":[4464],"stdStorageSafe":[5544]},"nodeType":"SourceUnit","src":"0:188:14","nodes":[{"id":39693,"nodeType":"PragmaDirective","src":"0:23:14","nodes":[],"literals":["solidity","0.8",".23"]},{"id":39694,"nodeType":"ImportDirective","src":"25:30:14","nodes":[],"absolutePath":"lib/forge-std/src/Script.sol","file":"forge-std/Script.sol","nameLocation":"-1:-1:-1","scope":39709,"sourceUnit":114,"symbolAliases":[],"unitAlias":""},{"id":39708,"nodeType":"ContractDefinition","src":"57:131:14","nodes":[{"id":39707,"nodeType":"FunctionDefinition","src":"93:93:14","nodes":[],"body":{"id":39706,"nodeType":"Block","src":"115:71:14","nodes":[],"statements":[{"body":{"id":39703,"nodeType":"Block","src":"128:38:14","statements":[{"assignments":[39700],"declarations":[{"constant":false,"id":39700,"mutability":"mutable","name":"a","nameLocation":"150:1:14","nodeType":"VariableDeclaration","scope":39703,"src":"142:9:14","stateVariable":false,"storageLocation":"default","typeDescriptions":{"typeIdentifier":"t_uint256","typeString":"uint256"},"typeName":{"id":39699,"name":"uint256","nodeType":"ElementaryTypeName","src":"142:7:14","typeDescriptions":{"typeIdentifier":"t_uint256","typeString":"uint256"}},"visibility":"internal"}],"id":39702,"initialValue":{"hexValue":"31","id":39701,"isConstant":false,"isLValue":false,"isPure":true,"kind":"number","lValueRequested":false,"nodeType":"Literal","src":"154:1:14","typeDescriptions":{"typeIdentifier":"t_rational_1_by_1","typeString":"int_const 1"},"value":"1"},"nodeType":"VariableDeclarationStatement","src":"142:13:14"}]},"condition":{"hexValue":"66616c7365","id":39704,"isConstant":false,"isLValue":false,"isPure":true,"kind":"bool","lValueRequested":false,"nodeType":"Literal","src":"173:5:14","typeDescriptions":{"typeIdentifier":"t_bool","typeString":"bool"},"value":"false"},"id":39705,"nodeType":"DoWhileStatement","src":"125:55:14"}]},"functionSelector":"c0406226","implemented":true,"kind":"function","modifiers":[],"name":"run","nameLocation":"102:3:14","parameters":{"id":39697,"nodeType":"ParameterList","parameters":[],"src":"105:2:14"},"returnParameters":{"id":39698,"nodeType":"ParameterList","parameters":[],"src":"115:0:14"},"scope":39708,"stateMutability":"nonpayable","virtual":false,"visibility":"public"}],"abstract":false,"baseContracts":[{"baseName":{"id":39695,"name":"Script","nameLocations":["80:6:14"],"nodeType":"IdentifierPath","referencedDeclaration":113,"src":"80:6:14"},"id":39696,"nodeType":"InheritanceSpecifier","src":"80:6:14"}],"canonicalName":"SomeScript","contractDependencies":[],"contractKind":"contract","fullyImplemented":true,"linearizedBaseContracts":[39708,113,8073,2937,877,74,62],"name":"SomeScript","nameLocation":"66:10:14","scope":39709,"usedErrors":[],"usedEvents":[]}]} \ No newline at end of file