unpackdev / solgo

Solidity parser in Go, designed to transform Solidity code into a structured format for enhanced analysis, particularly beneficial for developers using Go to analyze Solidity smart contracts.
https://unpack.dev
Apache License 2.0
1 stars 0 forks source link

[Bug] Parsing does not handle single statement `if` Statements #202

Closed xianlinc closed 4 months ago

xianlinc commented 5 months ago

Problem

Parsing of ast tree does not handle the case where the statementContext.Block() != nil and statementContext.Empty() == false. This happens when we have a single statement if statement such as if (block.timestamp <= time) revert TooLate(time);.

Suggestion

Add a line to handle that case in ast/if.go: https://github.com/unpackdev/solgo/blob/87b65765ed0f5a26b0b1904c65a1bc2c9b69cd67/ast/if.go#L191

0x19 commented 5 months ago

@xianlinc do you have contract or address that I can use do build tests on?

xianlinc commented 5 months ago

yep! This contract from the solidity docs has one https://docs.soliditylang.org/en/latest/solidity-by-example.html#simple-open-auction