Skip to content

Commit

Permalink
[BUG] AST [IF statement] single-statement conditional fix (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x19 authored Apr 20, 2024
1 parent 4108c77 commit 7e25c86
Show file tree
Hide file tree
Showing 118 changed files with 191,723 additions and 162,302 deletions.
3 changes: 3 additions & 0 deletions ast/if.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ func (i *IfStatement) Parse(
break
}

// There can be shorthand...
body.parseStatements(unit, contractNode, fnNode, statementCtx.GetChild(0))

i.Body = body
}

Expand Down
19 changes: 19 additions & 0 deletions ast/sources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ func getSourceTestCases(t *testing.T) []struct {
unresolvedReferences: 0,
disabled: false,
},
{
name: "Shorthand IF Test",
outputPath: "ast/",
sources: &solgo.Sources{
SourceUnits: []*solgo.SourceUnit{
{
Name: "SimpleAuction",
Path: tests.ReadContractFileForTest(t, "ast/SimpleAuction").Path,
Content: tests.ReadContractFileForTest(t, "ast/SimpleAuction").Content,
},
},
EntrySourceUnitName: "SimpleAuction",
LocalSourcesPath: buildFullPath("../sources/"),
},
expectedAst: tests.ReadJsonBytesForTest(t, "ast/SimpleAuction.solgo.ast").Content,
expectedProto: tests.ReadJsonBytesForTest(t, "ast/SimpleAuction.solgo.ast.proto").Content,
unresolvedReferences: 0,
disabled: false,
},
{
name: "L1Vault - 0x3b07A1A5de80f9b22DE0EC6C44C6E59DDc1C5f41",
outputPath: "contracts/10x3b07A1A5de80f9b22DE0EC6C44C6E59DDc1C5f41/",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"address": "0x4c8cfcac5e459d1e0c4054f58edaded8bd4066a1",
"type": "keystore",
"private_key": "",
"public_key": "",
"account": {
"address": "0x4c8cfcac5e459d1e0c4054f58edaded8bd4066a1",
"url": "keystore:///home/nevio/dev/unpack/solgo-orig/data/faucets/ethereum/UTC--2024-04-20T10-21-55.627092327Z--4c8cfcac5e459d1e0c4054f58edaded8bd4066a1"
},
"password": "c2ltdWxhdG9y",
"network": "ethereum",
"tags": [
"test"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"address": "0xe1f7abbc3eede26b88fe43a69f4162f1a535258e",
"type": "keystore",
"private_key": "",
"public_key": "",
"account": {
"address": "0xe1f7abbc3eede26b88fe43a69f4162f1a535258e",
"url": "keystore:///home/nevio/dev/unpack/solgo-orig/data/faucets/ethereum/UTC--2024-04-20T10-22-33.839396022Z--e1f7abbc3eede26b88fe43a69f4162f1a535258e"
},
"password": "c2ltdWxhdG9y",
"network": "ethereum",
"tags": [
"test"
]
}
2 changes: 1 addition & 1 deletion data/solc/releases/releases.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/tests/abi/ERC20.abi.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"entry_contract_id": 512,
"entry_contract_id": 536,
"entry_contract_name": "ERC20",
"contracts_count": 5,
"contracts": {
Expand Down
2 changes: 1 addition & 1 deletion data/tests/abi/ERC20.abi.proto.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"entryContractId": 512,
"entryContractId": 536,
"entryContractName": "ERC20",
"contractsCount": 5,
"contracts": {
Expand Down
2 changes: 1 addition & 1 deletion data/tests/abi/TokenSale.abi.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"entry_contract_id": 413,
"entry_contract_id": 437,
"entry_contract_name": "TokenSale",
"contracts_count": 3,
"contracts": {
Expand Down
2 changes: 1 addition & 1 deletion data/tests/abi/TokenSale.abi.proto.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"entryContractId": 413,
"entryContractId": 437,
"entryContractName": "TokenSale",
"contractsCount": 3,
"contracts": {
Expand Down
Loading

0 comments on commit 7e25c86

Please sign in to comment.