diff --git a/test/libsolidity/ASTJSON/address_payable.json b/test/libsolidity/ASTJSON/address_payable.json index 22090ee290f4..9aec1e510cfa 100644 --- a/test/libsolidity/ASTJSON/address_payable.json +++ b/test/libsolidity/ASTJSON/address_payable.json @@ -423,18 +423,19 @@ "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", - "src": "239:7:1", + "src": "239:8:1", "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" + "typeIdentifier": "t_type$_t_address_payable_$", + "typeString": "type(address payable)" }, "typeName": { "id": 31, "name": "address", "nodeType": "ElementaryTypeName", - "src": "239:7:1", + "src": "239:8:1", + "stateMutability": "payable", "typeDescriptions": {} } }, @@ -450,8 +451,8 @@ "tryCall": false, "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" + "typeIdentifier": "t_address_payable", + "typeString": "address payable" } }, "src": "232:17:1", diff --git a/test/libsolidity/ASTJSON/address_payable.sol b/test/libsolidity/ASTJSON/address_payable.sol index f7cc66cb568e..28c9c8a20da4 100644 --- a/test/libsolidity/ASTJSON/address_payable.sol +++ b/test/libsolidity/ASTJSON/address_payable.sol @@ -4,7 +4,7 @@ contract C { address payable a = m[arg]; r = arg; address c = address(this); - m[c] = address(0); + m[c] = payable(0); } } diff --git a/test/libsolidity/ASTJSON/address_payable_parseOnly.json b/test/libsolidity/ASTJSON/address_payable_parseOnly.json index 85e06e90cdfe..39e91de1cc10 100644 --- a/test/libsolidity/ASTJSON/address_payable_parseOnly.json +++ b/test/libsolidity/ASTJSON/address_payable_parseOnly.json @@ -268,14 +268,15 @@ { "id": 32, "nodeType": "ElementaryTypeNameExpression", - "src": "239:7:1", + "src": "239:8:1", "typeDescriptions": {}, "typeName": { "id": 31, "name": "address", "nodeType": "ElementaryTypeName", - "src": "239:7:1", + "src": "239:8:1", + "stateMutability": "payable", "typeDescriptions": {} } }, diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions.json b/test/libsolidity/ASTJSON/assembly/nested_functions.json index aea5e54d0951..41a18a1d0ebb 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions.json @@ -17,6 +17,7 @@ "canonicalName": "C", "contractDependencies": [], "contractKind": "contract", + "fullyImplemented": true, "id": 8, "linearizedBaseContracts": [ @@ -32,21 +33,21 @@ { "id": 6, "nodeType": "Block", - "src": "57:97:1", + "src": "57:95:1", "statements": [ { "AST": { "nodeType": "YulBlock", - "src": "72:78:1", + "src": "72:76:1", "statements": [ { "body": { "nodeType": "YulBlock", - "src": "94:50:1", + "src": "94:35:1", "statements": [ { @@ -59,43 +60,53 @@ "name": "f2", "nodeType": "YulFunctionDefinition", "src": "104:17:1" - }, - { - "nodeType": "YulAssignment", - "src": "130:6:1", - "value": - { - "kind": "number", - "nodeType": "YulLiteral", - "src": "135:1:1", - "type": "", - "value": "2" - }, - "variableNames": - [ - { - "name": "x", - "nodeType": "YulIdentifier", - "src": "130:1:1" - } - ] } ] }, "name": "f1", "nodeType": "YulFunctionDefinition", - "src": "80:64:1" + "src": "80:49:1" + }, + { + "nodeType": "YulAssignment", + "src": "136:6:1", + "value": + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "141:1:1", + "type": "", + "value": "2" + }, + "variableNames": + [ + { + "name": "x", + "nodeType": "YulIdentifier", + "src": "136:1:1" + } + ] } ] }, "evmVersion": %EVMVERSION%, - "externalReferences": [], + "externalReferences": + [ + { + "declaration": 3, + "isOffset": false, + "isSlot": false, + "src": "136:1:1", + "valueSize": 1 + } + ], "id": 5, "nodeType": "InlineAssembly", - "src": "63:87:1" + "src": "63:85:1" } ] }, + "functionSelector": "26121ff0", "id": 7, "implemented": true, "kind": "function", @@ -127,14 +138,22 @@ "src": "49:6:1", "stateVariable": false, "storageLocation": "default", - "typeDescriptions": {}, + "typeDescriptions": + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, "typeName": { "id": 2, "name": "uint", "nodeType": "ElementaryTypeName", "src": "49:4:1", - "typeDescriptions": {} + "typeDescriptions": + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } }, "visibility": "internal" } @@ -142,16 +161,16 @@ "src": "48:8:1" }, "scope": 8, - "src": "15:139:1", + "src": "15:137:1", "stateMutability": "pure", "virtual": false, "visibility": "public" } ], "scope": 9, - "src": "0:156:1", + "src": "0:154:1", "usedErrors": [] } ], - "src": "0:157:1" + "src": "0:155:1" } diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions.sol b/test/libsolidity/ASTJSON/assembly/nested_functions.sol index 412dd05a4863..396efa0bf8a2 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions.sol +++ b/test/libsolidity/ASTJSON/assembly/nested_functions.sol @@ -3,8 +3,8 @@ contract C { assembly { function f1() { function f2() { } - x := 2 } + x := 2 } } } diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions_parseOnly.json b/test/libsolidity/ASTJSON/assembly/nested_functions_parseOnly.json index af50716650e0..f5f554608006 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions_parseOnly.json @@ -20,21 +20,21 @@ { "id": 6, "nodeType": "Block", - "src": "57:97:1", + "src": "57:95:1", "statements": [ { "AST": { "nodeType": "YulBlock", - "src": "72:78:1", + "src": "72:76:1", "statements": [ { "body": { "nodeType": "YulBlock", - "src": "94:50:1", + "src": "94:35:1", "statements": [ { @@ -47,32 +47,32 @@ "name": "f2", "nodeType": "YulFunctionDefinition", "src": "104:17:1" - }, - { - "nodeType": "YulAssignment", - "src": "130:6:1", - "value": - { - "kind": "number", - "nodeType": "YulLiteral", - "src": "135:1:1", - "type": "", - "value": "2" - }, - "variableNames": - [ - { - "name": "x", - "nodeType": "YulIdentifier", - "src": "130:1:1" - } - ] } ] }, "name": "f1", "nodeType": "YulFunctionDefinition", - "src": "80:64:1" + "src": "80:49:1" + }, + { + "nodeType": "YulAssignment", + "src": "136:6:1", + "value": + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "141:1:1", + "type": "", + "value": "2" + }, + "variableNames": + [ + { + "name": "x", + "nodeType": "YulIdentifier", + "src": "136:1:1" + } + ] } ] }, @@ -80,7 +80,7 @@ "externalReferences": [], "id": 5, "nodeType": "InlineAssembly", - "src": "63:87:1" + "src": "63:85:1" } ] }, @@ -128,15 +128,15 @@ ], "src": "48:8:1" }, - "src": "15:139:1", + "src": "15:137:1", "stateMutability": "pure", "virtual": false, "visibility": "public" } ], - "src": "0:156:1", + "src": "0:154:1", "usedErrors": [] } ], - "src": "0:157:1" + "src": "0:155:1" } diff --git a/test/libsolidity/ASTJSON/assembly/switch.json b/test/libsolidity/ASTJSON/assembly/switch.json index 85dcb313f25a..f78699ef647d 100644 --- a/test/libsolidity/ASTJSON/assembly/switch.json +++ b/test/libsolidity/ASTJSON/assembly/switch.json @@ -17,6 +17,7 @@ "canonicalName": "C", "contractDependencies": [], "contractKind": "contract", + "fullyImplemented": true, "id": 6, "linearizedBaseContracts": [ @@ -56,7 +57,7 @@ "variables": [ { - "name": "f", + "name": "v", "nodeType": "YulTypedName", "src": "79:1:1", "type": "" @@ -87,7 +88,7 @@ "variableNames": [ { - "name": "f", + "name": "v", "nodeType": "YulIdentifier", "src": "141:1:1" } @@ -127,7 +128,7 @@ "variableNames": [ { - "name": "f", + "name": "v", "nodeType": "YulIdentifier", "src": "172:1:1" } @@ -158,29 +159,14 @@ ] }, "evmVersion": %EVMVERSION%, - "externalReferences": - [ - { - "declaration": 5, - "isOffset": false, - "isSlot": false, - "src": "141:1:1", - "valueSize": 18446744073709551615 - }, - { - "declaration": 5, - "isOffset": false, - "isSlot": false, - "src": "172:1:1", - "valueSize": 18446744073709551615 - } - ], + "externalReferences": [], "id": 3, "nodeType": "InlineAssembly", "src": "52:138:1" } ] }, + "functionSelector": "26121ff0", "id": 5, "implemented": true, "kind": "function", diff --git a/test/libsolidity/ASTJSON/assembly/switch.sol b/test/libsolidity/ASTJSON/assembly/switch.sol index 640c5b51c7eb..c04d311b09e4 100644 --- a/test/libsolidity/ASTJSON/assembly/switch.sol +++ b/test/libsolidity/ASTJSON/assembly/switch.sol @@ -1,10 +1,10 @@ contract C { function f() pure public { assembly { - let f := 0 + let v := 0 switch calldatasize() - case 0 { f := 1 } - default { f := 2 } + case 0 { v := 1 } + default { v := 2 } } } } diff --git a/test/libsolidity/ASTJSON/assembly/switch_parseOnly.json b/test/libsolidity/ASTJSON/assembly/switch_parseOnly.json index 93e671c10035..54d38b6383e1 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/switch_parseOnly.json @@ -44,7 +44,7 @@ "variables": [ { - "name": "f", + "name": "v", "nodeType": "YulTypedName", "src": "79:1:1", "type": "" @@ -75,7 +75,7 @@ "variableNames": [ { - "name": "f", + "name": "v", "nodeType": "YulIdentifier", "src": "141:1:1" } @@ -115,7 +115,7 @@ "variableNames": [ { - "name": "f", + "name": "v", "nodeType": "YulIdentifier", "src": "172:1:1" } diff --git a/test/libsolidity/ASTJSON/event_with_variables_of_internal_types.json b/test/libsolidity/ASTJSON/event_with_variables_of_internal_types.json deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/test/libsolidity/ASTJSON/fail_after_parsing.sol b/test/libsolidity/ASTJSON/fail_after_parsing.sol new file mode 100644 index 000000000000..b3b53a7c1611 --- /dev/null +++ b/test/libsolidity/ASTJSON/fail_after_parsing.sol @@ -0,0 +1,16 @@ +function g() public; + +interface I { + struct S { S s; } + + function f(E storage e) { + error E; + emit E(); + + ++c; + uint calldata c = 123.4; + } +} + +// ---- +// failAfter: Parsed diff --git a/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json b/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json new file mode 100644 index 000000000000..a5c7669ef51a --- /dev/null +++ b/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json @@ -0,0 +1,283 @@ +{ + "absolutePath": "a", + "id": 30, + "nodeType": "SourceUnit", + "nodes": + [ + { + "id": 3, + "implemented": false, + "kind": "freeFunction", + "modifiers": [], + "name": "g", + "nameLocation": "9:1:1", + "nodeType": "FunctionDefinition", + "parameters": + { + "id": 1, + "nodeType": "ParameterList", + "parameters": [], + "src": "10:2:1" + }, + "returnParameters": + { + "id": 2, + "nodeType": "ParameterList", + "parameters": [], + "src": "19:0:1" + }, + "src": "0:20:1", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "public" + }, + { + "abstract": false, + "baseContracts": [], + "contractDependencies": [], + "contractKind": "interface", + "id": 29, + "name": "I", + "nameLocation": "31:1:1", + "nodeType": "ContractDefinition", + "nodes": + [ + { + "id": 7, + "members": + [ + { + "constant": false, + "id": 6, + "mutability": "mutable", + "name": "s", + "nameLocation": "52:1:1", + "nodeType": "VariableDeclaration", + "src": "50:3:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": {}, + "typeName": + { + "id": 5, + "nodeType": "UserDefinedTypeName", + "pathNode": + { + "id": 4, + "name": "S", + "nodeType": "IdentifierPath", + "src": "50:1:1" + }, + "src": "50:1:1", + "typeDescriptions": {} + }, + "visibility": "internal" + } + ], + "name": "S", + "nameLocation": "46:1:1", + "nodeType": "StructDefinition", + "src": "39:17:1", + "visibility": "public" + }, + { + "body": + { + "id": 27, + "nodeType": "Block", + "src": "85:88:1", + "statements": + [ + { + "assignments": + [ + 15 + ], + "declarations": + [ + { + "constant": false, + "id": 15, + "mutability": "mutable", + "name": "E", + "nameLocation": "101:1:1", + "nodeType": "VariableDeclaration", + "src": "95:7:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": {}, + "typeName": + { + "id": 14, + "nodeType": "UserDefinedTypeName", + "pathNode": + { + "id": 13, + "name": "error", + "nodeType": "IdentifierPath", + "src": "95:5:1" + }, + "src": "95:5:1", + "typeDescriptions": {} + }, + "visibility": "internal" + } + ], + "id": 16, + "nodeType": "VariableDeclarationStatement", + "src": "95:7:1" + }, + { + "eventCall": + { + "arguments": [], + "expression": + { + "id": 17, + "name": "E", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "src": "117:1:1", + "typeDescriptions": {} + }, + "id": 18, + "names": [], + "nodeType": "FunctionCall", + "src": "117:3:1", + "tryCall": false, + "typeDescriptions": {} + }, + "id": 19, + "nodeType": "EmitStatement", + "src": "112:8:1" + }, + { + "expression": + { + "id": 21, + "nodeType": "UnaryOperation", + "operator": "++", + "prefix": true, + "src": "130:3:1", + "subExpression": + { + "id": 20, + "name": "c", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "src": "132:1:1", + "typeDescriptions": {} + }, + "typeDescriptions": {} + }, + "id": 22, + "nodeType": "ExpressionStatement", + "src": "130:3:1" + }, + { + "assignments": + [ + 24 + ], + "declarations": + [ + { + "constant": false, + "id": 24, + "mutability": "mutable", + "name": "c", + "nameLocation": "157:1:1", + "nodeType": "VariableDeclaration", + "src": "143:15:1", + "stateVariable": false, + "storageLocation": "calldata", + "typeDescriptions": {}, + "typeName": + { + "id": 23, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "143:4:1", + "typeDescriptions": {} + }, + "visibility": "internal" + } + ], + "id": 26, + "initialValue": + { + "hexValue": "3132332e34", + "id": 25, + "kind": "number", + "nodeType": "Literal", + "src": "161:5:1", + "typeDescriptions": {}, + "value": "123.4" + }, + "nodeType": "VariableDeclarationStatement", + "src": "143:23:1" + } + ] + }, + "id": 28, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "f", + "nameLocation": "70:1:1", + "nodeType": "FunctionDefinition", + "parameters": + { + "id": 11, + "nodeType": "ParameterList", + "parameters": + [ + { + "constant": false, + "id": 10, + "mutability": "mutable", + "name": "e", + "nameLocation": "82:1:1", + "nodeType": "VariableDeclaration", + "src": "72:11:1", + "stateVariable": false, + "storageLocation": "storage", + "typeDescriptions": {}, + "typeName": + { + "id": 9, + "nodeType": "UserDefinedTypeName", + "pathNode": + { + "id": 8, + "name": "E", + "nodeType": "IdentifierPath", + "src": "72:1:1" + }, + "src": "72:1:1", + "typeDescriptions": {} + }, + "visibility": "internal" + } + ], + "src": "71:13:1" + }, + "returnParameters": + { + "id": 12, + "nodeType": "ParameterList", + "parameters": [], + "src": "85:0:1" + }, + "src": "61:112:1", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "public" + } + ], + "src": "21:154:1", + "usedErrors": [] + } + ], + "src": "0:176:1" +} diff --git a/test/libsolidity/ASTJSON/function_type.json b/test/libsolidity/ASTJSON/function_type.json index cef79e70be4f..924f9cdb9a63 100644 --- a/test/libsolidity/ASTJSON/function_type.json +++ b/test/libsolidity/ASTJSON/function_type.json @@ -33,7 +33,7 @@ { "id": 15, "nodeType": "Block", - "src": "120:2:1", + "src": "127:2:1", "statements": [] }, "functionSelector": "d6cd4974", @@ -144,7 +144,7 @@ "nameLocation": "-1:-1:-1", "nodeType": "VariableDeclaration", "scope": 16, - "src": "79:40:1", + "src": "86:40:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": @@ -161,7 +161,7 @@ "id": 8, "nodeType": "ParameterList", "parameters": [], - "src": "87:2:1" + "src": "94:2:1" }, "returnParameterTypes": { @@ -177,7 +177,7 @@ "nameLocation": "-1:-1:-1", "nodeType": "VariableDeclaration", "scope": 12, - "src": "113:4:1", + "src": "120:4:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": @@ -190,7 +190,7 @@ "id": 9, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "113:4:1", + "src": "120:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", @@ -200,9 +200,9 @@ "visibility": "internal" } ], - "src": "112:6:1" + "src": "119:6:1" }, - "src": "79:40:1", + "src": "86:40:1", "stateMutability": "view", "typeDescriptions": { @@ -214,19 +214,19 @@ "visibility": "internal" } ], - "src": "78:41:1" + "src": "85:41:1" }, "scope": 17, - "src": "13:109:1", + "src": "13:116:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" } ], "scope": 18, - "src": "0:124:1", + "src": "0:131:1", "usedErrors": [] } ], - "src": "0:125:1" + "src": "0:132:1" } diff --git a/test/libsolidity/ASTJSON/function_type.sol b/test/libsolidity/ASTJSON/function_type.sol index bed2742b2aa3..176cea37400b 100644 --- a/test/libsolidity/ASTJSON/function_type.sol +++ b/test/libsolidity/ASTJSON/function_type.sol @@ -1,3 +1,3 @@ -contract C { function f(function() external payable returns (uint) x) returns (function() external view returns (uint)) {} } +contract C { function f(function() external payable returns (uint) x) public returns (function() external view returns (uint)) {} } // ---- diff --git a/test/libsolidity/ASTJSON/function_type_parseOnly.json b/test/libsolidity/ASTJSON/function_type_parseOnly.json index e47f24ad18db..fd1d7637b071 100644 --- a/test/libsolidity/ASTJSON/function_type_parseOnly.json +++ b/test/libsolidity/ASTJSON/function_type_parseOnly.json @@ -20,7 +20,7 @@ { "id": 15, "nodeType": "Block", - "src": "120:2:1", + "src": "127:2:1", "statements": [] }, "id": 16, @@ -111,7 +111,7 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "VariableDeclaration", - "src": "79:40:1", + "src": "86:40:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, @@ -124,7 +124,7 @@ "id": 8, "nodeType": "ParameterList", "parameters": [], - "src": "87:2:1" + "src": "94:2:1" }, "returnParameterTypes": { @@ -139,7 +139,7 @@ "name": "", "nameLocation": "-1:-1:-1", "nodeType": "VariableDeclaration", - "src": "113:4:1", + "src": "120:4:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, @@ -148,15 +148,15 @@ "id": 9, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "113:4:1", + "src": "120:4:1", "typeDescriptions": {} }, "visibility": "internal" } ], - "src": "112:6:1" + "src": "119:6:1" }, - "src": "79:40:1", + "src": "86:40:1", "stateMutability": "view", "typeDescriptions": {}, "visibility": "external" @@ -164,17 +164,17 @@ "visibility": "internal" } ], - "src": "78:41:1" + "src": "85:41:1" }, - "src": "13:109:1", + "src": "13:116:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" } ], - "src": "0:124:1", + "src": "0:131:1", "usedErrors": [] } ], - "src": "0:125:1" + "src": "0:132:1" } diff --git a/test/libsolidity/ASTJSON/non_utf8.json b/test/libsolidity/ASTJSON/non_utf8.json index 2f7145fda54e..0e2a56f84b24 100644 --- a/test/libsolidity/ASTJSON/non_utf8.json +++ b/test/libsolidity/ASTJSON/non_utf8.json @@ -4,10 +4,10 @@ { "C": [ - 9 + 15 ] }, - "id": 10, + "id": 16, "nodeType": "SourceUnit", "nodes": [ @@ -18,10 +18,10 @@ "contractDependencies": [], "contractKind": "contract", "fullyImplemented": true, - "id": 9, + "id": 15, "linearizedBaseContracts": [ - 9 + 15 ], "name": "C", "nameLocation": "9:1:1", @@ -31,9 +31,9 @@ { "body": { - "id": 7, + "id": 13, "nodeType": "Block", - "src": "33:30:1", + "src": "33:45:1", "statements": [ { @@ -50,7 +50,7 @@ "name": "x", "nameLocation": "49:1:1", "nodeType": "VariableDeclaration", - "scope": 7, + "scope": 13, "src": "35:15:1", "stateVariable": false, "storageLocation": "memory", @@ -74,31 +74,131 @@ "visibility": "internal" } ], - "id": 6, + "id": 12, "initialValue": { - "hexValue": "ff", - "id": 5, + "arguments": + [ + { + "arguments": + [ + { + "hexValue": "ff", + "id": 9, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "hexString", + "lValueRequested": false, + "nodeType": "Literal", + "src": "66:7:1", + "typeDescriptions": + { + "typeIdentifier": "t_stringliteral_8b1a944cf13a9a1c08facb2c9e98623ef3254d2ddb48113885c3e8e97fec8db9", + "typeString": "literal_string hex\"ff\"" + } + } + ], + "expression": + { + "argumentTypes": + [ + { + "typeIdentifier": "t_stringliteral_8b1a944cf13a9a1c08facb2c9e98623ef3254d2ddb48113885c3e8e97fec8db9", + "typeString": "literal_string hex\"ff\"" + } + ], + "id": 8, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "60:5:1", + "typeDescriptions": + { + "typeIdentifier": "t_type$_t_bytes_storage_ptr_$", + "typeString": "type(bytes storage pointer)" + }, + "typeName": + { + "id": 7, + "name": "bytes", + "nodeType": "ElementaryTypeName", + "src": "60:5:1", + "typeDescriptions": {} + } + }, + "id": 10, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "60:14:1", + "tryCall": false, + "typeDescriptions": + { + "typeIdentifier": "t_bytes_memory_ptr", + "typeString": "bytes memory" + } + } + ], + "expression": + { + "argumentTypes": + [ + { + "typeIdentifier": "t_bytes_memory_ptr", + "typeString": "bytes memory" + } + ], + "id": 6, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "53:6:1", + "typeDescriptions": + { + "typeIdentifier": "t_type$_t_string_storage_ptr_$", + "typeString": "type(string storage pointer)" + }, + "typeName": + { + "id": 5, + "name": "string", + "nodeType": "ElementaryTypeName", + "src": "53:6:1", + "typeDescriptions": {} + } + }, + "id": 11, "isConstant": false, "isLValue": false, "isPure": true, - "kind": "hexString", + "kind": "typeConversion", "lValueRequested": false, - "nodeType": "Literal", - "src": "53:7:1", + "names": [], + "nodeType": "FunctionCall", + "src": "53:22:1", + "tryCall": false, "typeDescriptions": { - "typeIdentifier": "t_stringliteral_8b1a944cf13a9a1c08facb2c9e98623ef3254d2ddb48113885c3e8e97fec8db9", - "typeString": "literal_string hex\"ff\"" + "typeIdentifier": "t_string_memory_ptr", + "typeString": "string memory" } }, "nodeType": "VariableDeclarationStatement", - "src": "35:25:1" + "src": "35:40:1" } ] }, "functionSelector": "26121ff0", - "id": 8, + "id": 14, "implemented": true, "kind": "function", "modifiers": [], @@ -119,17 +219,17 @@ "parameters": [], "src": "33:0:1" }, - "scope": 9, - "src": "13:50:1", + "scope": 15, + "src": "13:65:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" } ], - "scope": 10, - "src": "0:65:1", + "scope": 16, + "src": "0:80:1", "usedErrors": [] } ], - "src": "0:66:1" + "src": "0:81:1" } diff --git a/test/libsolidity/ASTJSON/non_utf8.sol b/test/libsolidity/ASTJSON/non_utf8.sol index 3651a05fd62e..0f14102ccefd 100644 --- a/test/libsolidity/ASTJSON/non_utf8.sol +++ b/test/libsolidity/ASTJSON/non_utf8.sol @@ -1,3 +1,3 @@ -contract C { function f() public { string memory x = hex"ff"; } } +contract C { function f() public { string memory x = string(bytes(hex"ff")); } } // ---- diff --git a/test/libsolidity/ASTJSON/non_utf8_parseOnly.json b/test/libsolidity/ASTJSON/non_utf8_parseOnly.json index e33388a0715f..df358ae362f9 100644 --- a/test/libsolidity/ASTJSON/non_utf8_parseOnly.json +++ b/test/libsolidity/ASTJSON/non_utf8_parseOnly.json @@ -1,6 +1,6 @@ { "absolutePath": "a", - "id": 10, + "id": 16, "nodeType": "SourceUnit", "nodes": [ @@ -9,7 +9,7 @@ "baseContracts": [], "contractDependencies": [], "contractKind": "contract", - "id": 9, + "id": 15, "name": "C", "nameLocation": "9:1:1", "nodeType": "ContractDefinition", @@ -18,9 +18,9 @@ { "body": { - "id": 7, + "id": 13, "nodeType": "Block", - "src": "33:30:1", + "src": "33:45:1", "statements": [ { @@ -52,22 +52,74 @@ "visibility": "internal" } ], - "id": 6, + "id": 12, "initialValue": { - "hexValue": "ff", - "id": 5, - "kind": "hexString", - "nodeType": "Literal", - "src": "53:7:1", + "arguments": + [ + { + "arguments": + [ + { + "hexValue": "ff", + "id": 9, + "kind": "hexString", + "nodeType": "Literal", + "src": "66:7:1", + "typeDescriptions": {} + } + ], + "expression": + { + "id": 8, + "nodeType": "ElementaryTypeNameExpression", + "src": "60:5:1", + "typeDescriptions": {}, + "typeName": + { + "id": 7, + "name": "bytes", + "nodeType": "ElementaryTypeName", + "src": "60:5:1", + "typeDescriptions": {} + } + }, + "id": 10, + "names": [], + "nodeType": "FunctionCall", + "src": "60:14:1", + "tryCall": false, + "typeDescriptions": {} + } + ], + "expression": + { + "id": 6, + "nodeType": "ElementaryTypeNameExpression", + "src": "53:6:1", + "typeDescriptions": {}, + "typeName": + { + "id": 5, + "name": "string", + "nodeType": "ElementaryTypeName", + "src": "53:6:1", + "typeDescriptions": {} + } + }, + "id": 11, + "names": [], + "nodeType": "FunctionCall", + "src": "53:22:1", + "tryCall": false, "typeDescriptions": {} }, "nodeType": "VariableDeclarationStatement", - "src": "35:25:1" + "src": "35:40:1" } ] }, - "id": 8, + "id": 14, "implemented": true, "kind": "function", "modifiers": [], @@ -88,15 +140,15 @@ "parameters": [], "src": "33:0:1" }, - "src": "13:50:1", + "src": "13:65:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" } ], - "src": "0:65:1", + "src": "0:80:1", "usedErrors": [] } ], - "src": "0:66:1" + "src": "0:81:1" } diff --git a/test/libsolidity/ASTJSON/not_existing_import.json b/test/libsolidity/ASTJSON/not_existing_import.json deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/test/libsolidity/ASTJSON/not_existing_import.sol b/test/libsolidity/ASTJSON/not_existing_import.sol index 6353c7527bde..7251a02b84a5 100644 --- a/test/libsolidity/ASTJSON/not_existing_import.sol +++ b/test/libsolidity/ASTJSON/not_existing_import.sol @@ -6,3 +6,4 @@ contract C is NotExisting.X } // ---- +// failAfter: Parsed diff --git a/test/libsolidity/ASTJSON/source_location.json b/test/libsolidity/ASTJSON/source_location.json index 0591a30cc8a2..df51e49c6f6b 100644 --- a/test/libsolidity/ASTJSON/source_location.json +++ b/test/libsolidity/ASTJSON/source_location.json @@ -33,7 +33,7 @@ { "id": 10, "nodeType": "Block", - "src": "26:20:1", + "src": "33:20:1", "statements": [ { @@ -48,10 +48,10 @@ "id": 4, "mutability": "mutable", "name": "x", - "nameLocation": "33:1:1", + "nameLocation": "40:1:1", "nodeType": "VariableDeclaration", "scope": 10, - "src": "28:6:1", + "src": "35:6:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": @@ -64,7 +64,7 @@ "id": 3, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "28:4:1", + "src": "35:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", @@ -85,7 +85,7 @@ "kind": "number", "lValueRequested": false, "nodeType": "Literal", - "src": "37:1:1", + "src": "44:1:1", "typeDescriptions": { "typeIdentifier": "t_rational_2_by_1", @@ -94,7 +94,7 @@ "value": "2" }, "nodeType": "VariableDeclarationStatement", - "src": "28:10:1" + "src": "35:10:1" }, { "expression": @@ -107,7 +107,7 @@ "nodeType": "UnaryOperation", "operator": "++", "prefix": false, - "src": "40:3:1", + "src": "47:3:1", "subExpression": { "id": 7, @@ -115,7 +115,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4, - "src": "40:1:1", + "src": "47:1:1", "typeDescriptions": { "typeIdentifier": "t_uint256", @@ -130,7 +130,7 @@ }, "id": 9, "nodeType": "ExpressionStatement", - "src": "40:3:1" + "src": "47:3:1" } ] }, @@ -154,19 +154,19 @@ "id": 2, "nodeType": "ParameterList", "parameters": [], - "src": "26:0:1" + "src": "33:0:1" }, "scope": 12, - "src": "13:33:1", + "src": "13:40:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" } ], "scope": 13, - "src": "0:48:1", + "src": "0:55:1", "usedErrors": [] } ], - "src": "0:49:1" + "src": "0:56:1" } diff --git a/test/libsolidity/ASTJSON/source_location.sol b/test/libsolidity/ASTJSON/source_location.sol index 0960bcde6b49..756998e43a83 100644 --- a/test/libsolidity/ASTJSON/source_location.sol +++ b/test/libsolidity/ASTJSON/source_location.sol @@ -1,3 +1,3 @@ -contract C { function f() { uint x = 2; x++; } } +contract C { function f() public { uint x = 2; x++; } } // ---- diff --git a/test/libsolidity/ASTJSON/source_location_parseOnly.json b/test/libsolidity/ASTJSON/source_location_parseOnly.json index decc215fe243..88835788b85f 100644 --- a/test/libsolidity/ASTJSON/source_location_parseOnly.json +++ b/test/libsolidity/ASTJSON/source_location_parseOnly.json @@ -20,7 +20,7 @@ { "id": 10, "nodeType": "Block", - "src": "26:20:1", + "src": "33:20:1", "statements": [ { @@ -35,9 +35,9 @@ "id": 4, "mutability": "mutable", "name": "x", - "nameLocation": "33:1:1", + "nameLocation": "40:1:1", "nodeType": "VariableDeclaration", - "src": "28:6:1", + "src": "35:6:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": {}, @@ -46,7 +46,7 @@ "id": 3, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "28:4:1", + "src": "35:4:1", "typeDescriptions": {} }, "visibility": "internal" @@ -59,12 +59,12 @@ "id": 5, "kind": "number", "nodeType": "Literal", - "src": "37:1:1", + "src": "44:1:1", "typeDescriptions": {}, "value": "2" }, "nodeType": "VariableDeclarationStatement", - "src": "28:10:1" + "src": "35:10:1" }, { "expression": @@ -73,21 +73,21 @@ "nodeType": "UnaryOperation", "operator": "++", "prefix": false, - "src": "40:3:1", + "src": "47:3:1", "subExpression": { "id": 7, "name": "x", "nodeType": "Identifier", "overloadedDeclarations": [], - "src": "40:1:1", + "src": "47:1:1", "typeDescriptions": {} }, "typeDescriptions": {} }, "id": 9, "nodeType": "ExpressionStatement", - "src": "40:3:1" + "src": "47:3:1" } ] }, @@ -110,17 +110,17 @@ "id": 2, "nodeType": "ParameterList", "parameters": [], - "src": "26:0:1" + "src": "33:0:1" }, - "src": "13:33:1", + "src": "13:40:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" } ], - "src": "0:48:1", + "src": "0:55:1", "usedErrors": [] } ], - "src": "0:49:1" + "src": "0:56:1" } diff --git a/test/libsolidity/ASTJSON/used_errors.json b/test/libsolidity/ASTJSON/used_errors.json index a0e8e28ba472..f00336d20936 100644 --- a/test/libsolidity/ASTJSON/used_errors.json +++ b/test/libsolidity/ASTJSON/used_errors.json @@ -39,7 +39,7 @@ { "id": 8, "nodeType": "Block", - "src": "24:15:1", + "src": "29:15:1", "statements": [ { @@ -54,7 +54,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2, - "src": "33:1:1", + "src": "38:1:1", "typeDescriptions": { "typeIdentifier": "t_function_error_pure$__$returns$__$", @@ -69,7 +69,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "33:3:1", + "src": "38:3:1", "tryCall": false, "typeDescriptions": { @@ -79,7 +79,7 @@ }, "id": 7, "nodeType": "RevertStatement", - "src": "26:10:1" + "src": "31:10:1" } ] }, @@ -102,11 +102,11 @@ "id": 4, "nodeType": "ParameterList", "parameters": [], - "src": "24:0:1" + "src": "29:0:1" }, "scope": 20, - "src": "11:28:1", - "stateMutability": "nonpayable", + "src": "11:33:1", + "stateMutability": "pure", "virtual": false, "visibility": "internal" }, @@ -123,7 +123,7 @@ 19 ], "name": "C", - "nameLocation": "49:1:1", + "nameLocation": "54:1:1", "nodeType": "ContractDefinition", "nodes": [ @@ -131,23 +131,23 @@ "errorSelector": "2bc80f3a", "id": 11, "name": "T", - "nameLocation": "63:1:1", + "nameLocation": "68:1:1", "nodeType": "ErrorDefinition", "parameters": { "id": 10, "nodeType": "ParameterList", "parameters": [], - "src": "64:2:1" + "src": "69:2:1" }, - "src": "57:10:1" + "src": "62:10:1" }, { "body": { "id": 17, "nodeType": "Block", - "src": "92:8:1", + "src": "97:8:1", "statements": [ { @@ -162,11 +162,11 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 9, - "src": "94:1:1", + "src": "99:1:1", "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", - "typeString": "function ()" + "typeIdentifier": "t_function_internal_pure$__$returns$__$", + "typeString": "function () pure" } }, "id": 15, @@ -177,7 +177,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "94:3:1", + "src": "99:3:1", "tryCall": false, "typeDescriptions": { @@ -187,7 +187,7 @@ }, "id": 16, "nodeType": "ExpressionStatement", - "src": "94:3:1" + "src": "99:3:1" } ] }, @@ -197,31 +197,31 @@ "kind": "function", "modifiers": [], "name": "h", - "nameLocation": "81:1:1", + "nameLocation": "86:1:1", "nodeType": "FunctionDefinition", "parameters": { "id": 12, "nodeType": "ParameterList", "parameters": [], - "src": "82:2:1" + "src": "87:2:1" }, "returnParameters": { "id": 13, "nodeType": "ParameterList", "parameters": [], - "src": "92:0:1" + "src": "97:0:1" }, "scope": 19, - "src": "72:28:1", + "src": "77:28:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" } ], "scope": 20, - "src": "40:62:1", + "src": "45:62:1", "usedErrors": [ 2, @@ -229,5 +229,5 @@ ] } ], - "src": "0:103:1" + "src": "0:108:1" } diff --git a/test/libsolidity/ASTJSON/used_errors.sol b/test/libsolidity/ASTJSON/used_errors.sol index ead3e2dcf4d0..24c03982fed6 100644 --- a/test/libsolidity/ASTJSON/used_errors.sol +++ b/test/libsolidity/ASTJSON/used_errors.sol @@ -1,5 +1,5 @@ error X(); -function f() { revert X(); } +function f() pure { revert X(); } contract C { error T(); function h() public { f(); } diff --git a/test/libsolidity/ASTJSON/used_errors_parseOnly.json b/test/libsolidity/ASTJSON/used_errors_parseOnly.json index 58b476005f05..b7500b445e15 100644 --- a/test/libsolidity/ASTJSON/used_errors_parseOnly.json +++ b/test/libsolidity/ASTJSON/used_errors_parseOnly.json @@ -23,7 +23,7 @@ { "id": 8, "nodeType": "Block", - "src": "24:15:1", + "src": "29:15:1", "statements": [ { @@ -36,19 +36,19 @@ "name": "X", "nodeType": "Identifier", "overloadedDeclarations": [], - "src": "33:1:1", + "src": "38:1:1", "typeDescriptions": {} }, "id": 6, "names": [], "nodeType": "FunctionCall", - "src": "33:3:1", + "src": "38:3:1", "tryCall": false, "typeDescriptions": {} }, "id": 7, "nodeType": "RevertStatement", - "src": "26:10:1" + "src": "31:10:1" } ] }, @@ -71,10 +71,10 @@ "id": 4, "nodeType": "ParameterList", "parameters": [], - "src": "24:0:1" + "src": "29:0:1" }, - "src": "11:28:1", - "stateMutability": "nonpayable", + "src": "11:33:1", + "stateMutability": "pure", "virtual": false, "visibility": "internal" }, @@ -85,30 +85,30 @@ "contractKind": "contract", "id": 19, "name": "C", - "nameLocation": "49:1:1", + "nameLocation": "54:1:1", "nodeType": "ContractDefinition", "nodes": [ { "id": 11, "name": "T", - "nameLocation": "63:1:1", + "nameLocation": "68:1:1", "nodeType": "ErrorDefinition", "parameters": { "id": 10, "nodeType": "ParameterList", "parameters": [], - "src": "64:2:1" + "src": "69:2:1" }, - "src": "57:10:1" + "src": "62:10:1" }, { "body": { "id": 17, "nodeType": "Block", - "src": "92:8:1", + "src": "97:8:1", "statements": [ { @@ -121,19 +121,19 @@ "name": "f", "nodeType": "Identifier", "overloadedDeclarations": [], - "src": "94:1:1", + "src": "99:1:1", "typeDescriptions": {} }, "id": 15, "names": [], "nodeType": "FunctionCall", - "src": "94:3:1", + "src": "99:3:1", "tryCall": false, "typeDescriptions": {} }, "id": 16, "nodeType": "ExpressionStatement", - "src": "94:3:1" + "src": "99:3:1" } ] }, @@ -142,31 +142,31 @@ "kind": "function", "modifiers": [], "name": "h", - "nameLocation": "81:1:1", + "nameLocation": "86:1:1", "nodeType": "FunctionDefinition", "parameters": { "id": 12, "nodeType": "ParameterList", "parameters": [], - "src": "82:2:1" + "src": "87:2:1" }, "returnParameters": { "id": 13, "nodeType": "ParameterList", "parameters": [], - "src": "92:0:1" + "src": "97:0:1" }, - "src": "72:28:1", + "src": "77:28:1", "stateMutability": "nonpayable", "virtual": false, "visibility": "public" } ], - "src": "40:62:1", + "src": "45:62:1", "usedErrors": [] } ], - "src": "0:103:1" + "src": "0:108:1" } diff --git a/test/libsolidity/ASTJSONTest.cpp b/test/libsolidity/ASTJSONTest.cpp index 82c6e7e18664..14e2c2a8a477 100644 --- a/test/libsolidity/ASTJSONTest.cpp +++ b/test/libsolidity/ASTJSONTest.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -49,6 +50,30 @@ namespace string const sourceDelimiter("==== Source: "); +string compilerStateToString(CompilerStack::State _state) +{ + switch (_state) + { + case CompilerStack::State::Empty: return "Empty"; + case CompilerStack::State::SourcesSet: return "SourcesSet"; + case CompilerStack::State::Parsed: return "Parsed"; + case CompilerStack::State::ParsedAndImported: return "ParsedAndImported"; + case CompilerStack::State::AnalysisPerformed: return "AnalysisPerformed"; + case CompilerStack::State::CompilationSuccessful: return "CompilationSuccessful"; + } + soltestAssert(false, "Unexpected value of state parameter"); +} + +CompilerStack::State stringToCompilerState(const string& _state) +{ + for (unsigned int i = CompilerStack::State::Empty; i <= CompilerStack::State::CompilationSuccessful; ++i) + { + if (_state == compilerStateToString(CompilerStack::State(i))) + return CompilerStack::State(i); + } + BOOST_THROW_EXCEPTION(runtime_error("Unsupported compiler state (" + _state + ") in test contract file")); +} + void replaceVersionWithTag(string& _input) { boost::algorithm::replace_all( @@ -69,20 +94,30 @@ void replaceTagWithVersion(string& _input) } - -ASTJSONTest::ASTJSONTest(string const& _filename) +void ASTJSONTest::generateTestVariants(string const& _filename) { - if (!boost::algorithm::ends_with(_filename, ".sol")) - BOOST_THROW_EXCEPTION(runtime_error("Invalid test contract file name: \"" + _filename + "\".")); - string_view baseName = _filename; baseName.remove_suffix(4); - m_variants = { - TestVariant(baseName, CompilerStack::State::Parsed), - TestVariant(baseName, CompilerStack::State::AnalysisPerformed), + const std::vector variantCompileStates = { + CompilerStack::State::Parsed, + CompilerStack::State::AnalysisPerformed }; + for (const auto state: variantCompileStates) + { + auto variant = TestVariant(baseName, state); + if (boost::filesystem::exists(variant.astFilename())) + { + variant.expectation = readFileAsString(variant.astFilename()); + boost::replace_all(variant.expectation, "\r\n", "\n"); + m_variants.push_back(variant); + } + } +} + +void ASTJSONTest::fillSources(string const& _filename) +{ ifstream file(_filename); if (!file) BOOST_THROW_EXCEPTION(runtime_error("Cannot open test contract: \"" + _filename + "\".")); @@ -92,6 +127,7 @@ ASTJSONTest::ASTJSONTest(string const& _filename) string source; string line; string const delimiter("// ----"); + string const failMarker("// failAfter:"); while (getline(file, line)) { if (boost::algorithm::starts_with(line, sourceDelimiter)) @@ -105,20 +141,55 @@ ASTJSONTest::ASTJSONTest(string const& _filename) ); source = string(); } + else if (boost::algorithm::starts_with(line, failMarker)) + { + string state = line.substr(failMarker.size()); + boost::algorithm::trim(state); + if (m_expectedFailAfter.has_value()) + BOOST_THROW_EXCEPTION(runtime_error("Duplicated \"failAfter\" directive")); + m_expectedFailAfter = stringToCompilerState(state); + + } else if (!line.empty() && !boost::algorithm::starts_with(line, delimiter)) source += line + "\n"; } - m_sources.emplace_back(sourceName.empty() ? "a" : sourceName, source); file.close(); +} - for (TestVariant& variant: m_variants) +void ASTJSONTest::validateTestConfiguration() const +{ + if (m_variants.empty()) + BOOST_THROW_EXCEPTION(runtime_error("No file with expected result found.")); + + if (m_expectedFailAfter.has_value()) { - variant.expectation = readFileAsString(variant.astFilename()); - boost::replace_all(variant.expectation, "\r\n", "\n"); + auto unexpectedTestVariant = std::find_if( + m_variants.begin(), m_variants.end(), + [failAfter = m_expectedFailAfter](TestVariant v) { return v.stopAfter > failAfter; } + ); + + if (unexpectedTestVariant != m_variants.end()) + BOOST_THROW_EXCEPTION( + runtime_error( + string("Unexpected JSON file: ") + unexpectedTestVariant->astFilename() + + " in \"failAfter: " + + compilerStateToString(m_expectedFailAfter.value()) + "\" scenario." + ) + ); } } +ASTJSONTest::ASTJSONTest(string const& _filename) +{ + if (!boost::algorithm::ends_with(_filename, ".sol")) + BOOST_THROW_EXCEPTION(runtime_error("Invalid test contract file name: \"" + _filename + "\".")); + + generateTestVariants(_filename); + fillSources(_filename); + validateTestConfiguration(); +} + TestCase::TestResult ASTJSONTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted) { CompilerStack c; @@ -141,13 +212,12 @@ TestCase::TestResult ASTJSONTest::run(ostream& _stream, string const& _linePrefi if (!c.parseAndAnalyze(variant.stopAfter)) { - // Ignore non-fatal analysis errors, we only want to export. - if (c.state() > CompilerStack::State::Parsed) - continue; - - SourceReferenceFormatter formatter(_stream, c, _formatted, false); - formatter.printErrorInformation(c.errors()); - return TestResult::FatalError; + if (!m_expectedFailAfter.has_value() || m_expectedFailAfter.value() + 1 != c.state()) + { + SourceReferenceFormatter formatter(_stream, c, _formatted, false); + formatter.printErrorInformation(c.errors()); + return TestResult::FatalError; + } } resultsMatch = resultsMatch && runTest( diff --git a/test/libsolidity/ASTJSONTest.h b/test/libsolidity/ASTJSONTest.h index 3365de589df3..648f3bbc3234 100644 --- a/test/libsolidity/ASTJSONTest.h +++ b/test/libsolidity/ASTJSONTest.h @@ -89,7 +89,12 @@ class ASTJSONTest: public TestCase std::string const& _variant ) const; + void generateTestVariants(std::string const& _filename); + void fillSources(std::string const& _filename); + void validateTestConfiguration() const; + std::vector m_variants; + std::optional m_expectedFailAfter; std::vector> m_sources; };