Merge pull request #8628 from ethereum/fiximmutableastexport

Export immutability.
This commit is contained in:
chriseth
2020-04-07 18:37:09 +02:00
committed by GitHub
42 changed files with 493 additions and 20 deletions
@@ -160,6 +160,7 @@ JSON AST:
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "",
"overrides": null,
"scope": 17,
@@ -31,6 +31,7 @@
"constant": false,
"functionSelector": "97682884",
"id": 4,
"mutability": "mutable",
"name": "m",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -100,6 +101,7 @@
{
"constant": false,
"id": 12,
"mutability": "mutable",
"name": "a",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -241,6 +243,7 @@
{
"constant": false,
"id": 22,
"mutability": "mutable",
"name": "c",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -507,6 +510,7 @@
{
"constant": false,
"id": 6,
"mutability": "mutable",
"name": "arg",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -547,6 +551,7 @@
{
"constant": false,
"id": 9,
"mutability": "mutable",
"name": "r",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -41,6 +41,7 @@
{
"constant": false,
"functionSelector": "97682884",
"mutability": "mutable",
"name": "m",
"overrides": null,
"scope": 39,
@@ -118,6 +119,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "arg",
"overrides": null,
"scope": 38,
@@ -157,6 +159,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "r",
"overrides": null,
"scope": 38,
@@ -206,6 +209,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "a",
"overrides": null,
"scope": 37,
@@ -359,6 +363,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "c",
"overrides": null,
"scope": 37,
@@ -30,6 +30,7 @@
{
"constant": false,
"id": 3,
"mutability": "mutable",
"name": "i",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -40,6 +40,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "i",
"overrides": null,
"scope": 4,
@@ -121,6 +121,7 @@
{
"constant": false,
"id": 3,
"mutability": "mutable",
"name": "x",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -77,6 +77,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "x",
"overrides": null,
"scope": 7,
@@ -35,6 +35,7 @@
{
"constant": false,
"id": 2,
"mutability": "mutable",
"name": "x",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -72,6 +73,7 @@
{
"constant": false,
"id": 5,
"mutability": "mutable",
"name": "s",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -50,6 +50,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "x",
"overrides": null,
"scope": 3,
@@ -85,6 +86,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "s",
"overrides": null,
"scope": 11,
@@ -45,6 +45,7 @@
{
"constant": false,
"id": 4,
"mutability": "mutable",
"name": "x",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -101,6 +101,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "x",
"overrides": null,
"scope": 7,
@@ -53,6 +53,7 @@
{
"constant": false,
"id": 6,
"mutability": "mutable",
"name": "x",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -85,6 +86,7 @@
{
"constant": false,
"id": 3,
"mutability": "mutable",
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -139,6 +141,7 @@
{
"constant": false,
"id": 13,
"mutability": "mutable",
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -171,6 +174,7 @@
{
"constant": false,
"id": 10,
"mutability": "mutable",
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -64,6 +64,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "x",
"overrides": null,
"scope": 16,
@@ -104,6 +105,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "",
"overrides": null,
"scope": 5,
@@ -157,6 +159,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "",
"overrides": null,
"scope": 16,
@@ -197,6 +200,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "",
"overrides": null,
"scope": 12,
@@ -19,6 +19,7 @@
{
"constant": false,
"id": 2,
"mutability": "mutable",
"name": "a",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -26,6 +26,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "a",
"overrides": null,
"scope": 3,
@@ -45,6 +45,7 @@
{
"constant": false,
"id": 4,
"mutability": "mutable",
"name": "a",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -100,6 +100,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "a",
"overrides": null,
"scope": 9,
@@ -30,6 +30,7 @@
{
"constant": false,
"id": 3,
"mutability": "mutable",
"name": "a",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -87,6 +88,7 @@
{
"constant": false,
"id": 10,
"mutability": "mutable",
"name": "b",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -40,6 +40,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "a",
"overrides": null,
"scope": 15,
@@ -143,6 +144,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "b",
"overrides": null,
"scope": 13,
+3
View File
@@ -58,6 +58,7 @@
{
"constant": false,
"id": 8,
"mutability": "mutable",
"name": "a",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -113,6 +114,7 @@
{
"constant": false,
"id": 12,
"mutability": "mutable",
"name": "b",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -166,6 +168,7 @@
{
"constant": false,
"id": 16,
"mutability": "mutable",
"name": "c",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -80,6 +80,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "a",
"overrides": null,
"scope": 17,
@@ -134,6 +135,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "b",
"overrides": null,
"scope": 17,
@@ -186,6 +188,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "c",
"overrides": null,
"scope": 17,
@@ -56,6 +56,7 @@
{
"constant": false,
"id": 2,
"mutability": "mutable",
"name": "i",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -54,6 +54,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "i",
"overrides": null,
"scope": 6,
@@ -56,6 +56,7 @@
{
"constant": false,
"id": 2,
"mutability": "mutable",
"name": "i",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -54,6 +54,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "i",
"overrides": null,
"scope": 6,
+189
View File
@@ -0,0 +1,189 @@
{
"absolutePath": "a",
"exportedSymbols":
{
"C":
[
10
]
},
"id": 11,
"nodeType": "SourceUnit",
"nodes":
[
{
"abstract": false,
"baseContracts": [],
"contractDependencies": [],
"contractKind": "contract",
"documentation": null,
"fullyImplemented": true,
"id": 10,
"linearizedBaseContracts":
[
10
],
"name": "C",
"nodeType": "ContractDefinition",
"nodes":
[
{
"constant": false,
"functionSelector": "0dbe671f",
"id": 3,
"mutability": "immutable",
"name": "a",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 10,
"src": "17:27:1",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions":
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName":
{
"id": 1,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "17:4:1",
"typeDescriptions":
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value":
{
"argumentTypes": null,
"hexValue": "34",
"id": 2,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "43:1:1",
"subdenomination": null,
"typeDescriptions":
{
"typeIdentifier": "t_rational_4_by_1",
"typeString": "int_const 4"
},
"value": "4"
},
"visibility": "public"
},
{
"constant": true,
"functionSelector": "4df7e3d0",
"id": 6,
"mutability": "constant",
"name": "b",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 10,
"src": "50:26:1",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions":
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName":
{
"id": 4,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "50:4:1",
"typeDescriptions":
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value":
{
"argumentTypes": null,
"hexValue": "32",
"id": 5,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "75:1:1",
"subdenomination": null,
"typeDescriptions":
{
"typeIdentifier": "t_rational_2_by_1",
"typeString": "int_const 2"
},
"value": "2"
},
"visibility": "public"
},
{
"constant": false,
"functionSelector": "c3da42b8",
"id": 9,
"mutability": "mutable",
"name": "c",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 10,
"src": "82:17:1",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions":
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName":
{
"id": 7,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "82:4:1",
"typeDescriptions":
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value":
{
"argumentTypes": null,
"hexValue": "33",
"id": 8,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "98:1:1",
"subdenomination": null,
"typeDescriptions":
{
"typeIdentifier": "t_rational_3_by_1",
"typeString": "int_const 3"
},
"value": "3"
},
"visibility": "public"
}
],
"scope": 11,
"src": "0:102:1"
}
],
"src": "0:103:1"
}
+8
View File
@@ -0,0 +1,8 @@
contract C
{
uint public immutable a = 4;
uint public constant b = 2;
uint public c = 3;
}
// ----
@@ -0,0 +1,195 @@
{
"attributes":
{
"absolutePath": "a",
"exportedSymbols":
{
"C":
[
10
]
}
},
"children":
[
{
"attributes":
{
"abstract": false,
"baseContracts":
[
null
],
"contractDependencies":
[
null
],
"contractKind": "contract",
"documentation": null,
"fullyImplemented": true,
"linearizedBaseContracts":
[
10
],
"name": "C",
"scope": 11
},
"children":
[
{
"attributes":
{
"constant": false,
"functionSelector": "0dbe671f",
"mutability": "immutable",
"name": "a",
"overrides": null,
"scope": 10,
"stateVariable": true,
"storageLocation": "default",
"type": "uint256",
"visibility": "public"
},
"children":
[
{
"attributes":
{
"name": "uint",
"type": "uint256"
},
"id": 1,
"name": "ElementaryTypeName",
"src": "17:4:1"
},
{
"attributes":
{
"argumentTypes": null,
"hexvalue": "34",
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"subdenomination": null,
"token": "number",
"type": "int_const 4",
"value": "4"
},
"id": 2,
"name": "Literal",
"src": "43:1:1"
}
],
"id": 3,
"name": "VariableDeclaration",
"src": "17:27:1"
},
{
"attributes":
{
"constant": true,
"functionSelector": "4df7e3d0",
"mutability": "constant",
"name": "b",
"overrides": null,
"scope": 10,
"stateVariable": true,
"storageLocation": "default",
"type": "uint256",
"visibility": "public"
},
"children":
[
{
"attributes":
{
"name": "uint",
"type": "uint256"
},
"id": 4,
"name": "ElementaryTypeName",
"src": "50:4:1"
},
{
"attributes":
{
"argumentTypes": null,
"hexvalue": "32",
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"subdenomination": null,
"token": "number",
"type": "int_const 2",
"value": "2"
},
"id": 5,
"name": "Literal",
"src": "75:1:1"
}
],
"id": 6,
"name": "VariableDeclaration",
"src": "50:26:1"
},
{
"attributes":
{
"constant": false,
"functionSelector": "c3da42b8",
"mutability": "mutable",
"name": "c",
"overrides": null,
"scope": 10,
"stateVariable": true,
"storageLocation": "default",
"type": "uint256",
"visibility": "public"
},
"children":
[
{
"attributes":
{
"name": "uint",
"type": "uint256"
},
"id": 7,
"name": "ElementaryTypeName",
"src": "82:4:1"
},
{
"attributes":
{
"argumentTypes": null,
"hexvalue": "33",
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"subdenomination": null,
"token": "number",
"type": "int_const 3",
"value": "3"
},
"id": 8,
"name": "Literal",
"src": "98:1:1"
}
],
"id": 9,
"name": "VariableDeclaration",
"src": "82:17:1"
}
],
"id": 10,
"name": "ContractDefinition",
"src": "0:102:1"
}
],
"id": 11,
"name": "SourceUnit",
"src": "0:103:1"
}
+1
View File
@@ -45,6 +45,7 @@
{
"constant": false,
"id": 3,
"mutability": "mutable",
"name": "x",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -100,6 +100,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "x",
"overrides": null,
"scope": 6,
@@ -45,6 +45,7 @@
{
"constant": false,
"id": 7,
"mutability": "mutable",
"name": "x",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -101,6 +101,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "x",
"overrides": null,
"scope": 9,
@@ -45,6 +45,7 @@
{
"constant": false,
"id": 8,
"mutability": "mutable",
"name": "rows",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -101,6 +101,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "rows",
"overrides": null,
"scope": 10,
@@ -45,6 +45,7 @@
{
"constant": false,
"id": 3,
"mutability": "mutable",
"name": "x",
"nodeType": "VariableDeclaration",
"overrides": null,
@@ -100,6 +100,7 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "x",
"overrides": null,
"scope": 9,
@@ -3,5 +3,5 @@ contract C {
uint immutable constant x;
}
// ----
// ParserError: (32-41): Constantness already set to "immutable"
// ParserError: (64-72): Constantness already set to "immutable"
// ParserError: (32-41): Mutability already set to "immutable"
// ParserError: (64-72): Mutability already set to "immutable"