Skip to content

Commit 7e25c86

Browse files
authored
[BUG] AST [IF statement] single-statement conditional fix (#206)
1 parent 4108c77 commit 7e25c86

File tree

118 files changed

+191723
-162302
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+191723
-162302
lines changed

ast/if.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ func (i *IfStatement) Parse(
187187
break
188188
}
189189

190+
// There can be shorthand...
191+
body.parseStatements(unit, contractNode, fnNode, statementCtx.GetChild(0))
192+
190193
i.Body = body
191194
}
192195

ast/sources_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ func getSourceTestCases(t *testing.T) []struct {
4747
unresolvedReferences: 0,
4848
disabled: false,
4949
},
50+
{
51+
name: "Shorthand IF Test",
52+
outputPath: "ast/",
53+
sources: &solgo.Sources{
54+
SourceUnits: []*solgo.SourceUnit{
55+
{
56+
Name: "SimpleAuction",
57+
Path: tests.ReadContractFileForTest(t, "ast/SimpleAuction").Path,
58+
Content: tests.ReadContractFileForTest(t, "ast/SimpleAuction").Content,
59+
},
60+
},
61+
EntrySourceUnitName: "SimpleAuction",
62+
LocalSourcesPath: buildFullPath("../sources/"),
63+
},
64+
expectedAst: tests.ReadJsonBytesForTest(t, "ast/SimpleAuction.solgo.ast").Content,
65+
expectedProto: tests.ReadJsonBytesForTest(t, "ast/SimpleAuction.solgo.ast.proto").Content,
66+
unresolvedReferences: 0,
67+
disabled: false,
68+
},
5069
{
5170
name: "L1Vault - 0x3b07A1A5de80f9b22DE0EC6C44C6E59DDc1C5f41",
5271
outputPath: "contracts/10x3b07A1A5de80f9b22DE0EC6C44C6E59DDc1C5f41/",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"address": "0x4c8cfcac5e459d1e0c4054f58edaded8bd4066a1",
3+
"type": "keystore",
4+
"private_key": "",
5+
"public_key": "",
6+
"account": {
7+
"address": "0x4c8cfcac5e459d1e0c4054f58edaded8bd4066a1",
8+
"url": "keystore:///home/nevio/dev/unpack/solgo-orig/data/faucets/ethereum/UTC--2024-04-20T10-21-55.627092327Z--4c8cfcac5e459d1e0c4054f58edaded8bd4066a1"
9+
},
10+
"password": "c2ltdWxhdG9y",
11+
"network": "ethereum",
12+
"tags": [
13+
"test"
14+
]
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"address": "0xe1f7abbc3eede26b88fe43a69f4162f1a535258e",
3+
"type": "keystore",
4+
"private_key": "",
5+
"public_key": "",
6+
"account": {
7+
"address": "0xe1f7abbc3eede26b88fe43a69f4162f1a535258e",
8+
"url": "keystore:///home/nevio/dev/unpack/solgo-orig/data/faucets/ethereum/UTC--2024-04-20T10-22-33.839396022Z--e1f7abbc3eede26b88fe43a69f4162f1a535258e"
9+
},
10+
"password": "c2ltdWxhdG9y",
11+
"network": "ethereum",
12+
"tags": [
13+
"test"
14+
]
15+
}

data/solc/releases/releases.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

data/tests/abi/ERC20.abi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"entry_contract_id": 512,
2+
"entry_contract_id": 536,
33
"entry_contract_name": "ERC20",
44
"contracts_count": 5,
55
"contracts": {

data/tests/abi/ERC20.abi.proto.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"entryContractId": 512,
2+
"entryContractId": 536,
33
"entryContractName": "ERC20",
44
"contractsCount": 5,
55
"contracts": {

data/tests/abi/TokenSale.abi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"entry_contract_id": 413,
2+
"entry_contract_id": 437,
33
"entry_contract_name": "TokenSale",
44
"contracts_count": 3,
55
"contracts": {

data/tests/abi/TokenSale.abi.proto.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"entryContractId": 413,
2+
"entryContractId": 437,
33
"entryContractName": "TokenSale",
44
"contractsCount": 3,
55
"contracts": {

0 commit comments

Comments
 (0)