Merge remote-tracking branch 'origin/develop' into breaking

This commit is contained in:
chriseth
2020-04-22 17:21:32 +02:00
270 changed files with 5249 additions and 1817 deletions
+3 -3
View File
@@ -29,13 +29,13 @@ namespace solidity::test
#ifdef _WIN32
static constexpr auto evmoneFilename = "evmone.dll";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.3.0/evmone-0.3.0-windows-amd64.zip";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.4.1/evmone-0.4.1-windows-amd64.zip";
#elif defined(__APPLE__)
static constexpr auto evmoneFilename = "libevmone.dylib";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.3.0/evmone-0.3.0-darwin-x86_64.tar.gz";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.4.1/evmone-0.4.1-darwin-x86_64.tar.gz";
#else
static constexpr auto evmoneFilename = "libevmone.so";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.3.0/evmone-0.3.0-linux-x86_64.tar.gz";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.4.1/evmone-0.4.1-linux-x86_64.tar.gz";
#endif
+7 -7
View File
@@ -31,19 +31,19 @@ set -e
## GLOBAL VARIABLES
REPO_ROOT=$(cd $(dirname "$0")/.. && pwd)
SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-build}
SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}
source "${REPO_ROOT}/scripts/common.sh"
source "${REPO_ROOT}/scripts/common_cmdline.sh"
case "$OSTYPE" in
msys)
SOLC="$REPO_ROOT/${SOLIDITY_BUILD_DIR}/solc/Release/solc.exe"
SOLC="${SOLIDITY_BUILD_DIR}/solc/Release/solc.exe"
# prevents msys2 path translation for a remapping test
export MSYS2_ARG_CONV_EXCL="="
;;
*)
SOLC="$REPO_ROOT/${SOLIDITY_BUILD_DIR}/solc/solc"
SOLC="${SOLIDITY_BUILD_DIR}/solc/solc"
;;
esac
echo "${SOLC}"
@@ -214,7 +214,7 @@ printTask "Testing unknown options..."
then
echo "Passed"
else
printError "Incorrect response to unknown options: $STDERR"
printError "Incorrect response to unknown options: $output"
exit 1
fi
)
@@ -385,7 +385,7 @@ SOLTMPDIR=$(mktemp -d)
# This should fail
if [[ !("$output" =~ "No input files given") || ($result == 0) ]]
then
printError "Incorrect response to empty input arg list: $STDERR"
printError "Incorrect response to empty input arg list: $output"
exit 1
fi
@@ -431,8 +431,8 @@ SOLTMPDIR=$(mktemp -d)
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/test/
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/ docs
echo *.sol | xargs -P 4 -n 50 "$REPO_ROOT"/${SOLIDITY_BUILD_DIR}/test/tools/solfuzzer --quiet --input-files
echo *.sol | xargs -P 4 -n 50 "$REPO_ROOT"/${SOLIDITY_BUILD_DIR}/test/tools/solfuzzer --without-optimizer --quiet --input-files
echo *.sol | xargs -P 4 -n 50 "${SOLIDITY_BUILD_DIR}/test/tools/solfuzzer" --quiet --input-files
echo *.sol | xargs -P 4 -n 50 "${SOLIDITY_BUILD_DIR}/test/tools/solfuzzer" --without-optimizer --quiet --input-files
)
rm -rf "$SOLTMPDIR"
@@ -160,6 +160,7 @@ JSON AST:
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "",
"overrides": null,
"scope": 17,
@@ -10,8 +10,6 @@ object \"C_6\" {
mstore(64, 128)
codecopy(0, dataoffset(\"C_6_deployed\"), datasize(\"C_6_deployed\"))
return(0, datasize(\"C_6_deployed\"))
function fun_f_5()
{ }
}
object \"C_6_deployed\" {
code {
@@ -18,11 +18,6 @@ object \"C_6\" {
return(0, datasize(\"C_6_deployed\"))
function fun_f_5() {
}
}
object \"C_6_deployed\" {
code {
@@ -18,35 +18,6 @@ object \"C_10\" {
return(0, datasize(\"C_10_deployed\"))
function allocateMemory(size) -> memPtr {
memPtr := mload(64)
let newFreePtr := add(memPtr, size)
// protect against overflow
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { revert(0, 0) }
mstore(64, newFreePtr)
}
function convert_t_stringliteral_9f0adad0a59b05d2e04a1373342b10b9eb16c57c164c8a3bfcbf46dccee39a21_to_t_string_memory_ptr() -> converted {
converted := allocateMemory(64)
mstore(converted, 6)
mstore(add(converted, 32), \"abcabc\")
}
function fun_f_9() -> vloc__4_mpos {
let zero_value_for_type_t_string_memory_ptr_1_mpos := zero_value_for_split_t_string_memory_ptr()
vloc__4_mpos := zero_value_for_type_t_string_memory_ptr_1_mpos
vloc__4_mpos := convert_t_stringliteral_9f0adad0a59b05d2e04a1373342b10b9eb16c57c164c8a3bfcbf46dccee39a21_to_t_string_memory_ptr()
leave
}
function zero_value_for_split_t_string_memory_ptr() -> ret {
ret := 96
}
}
object \"C_10_deployed\" {
code {
@@ -18,23 +18,6 @@ object \"C_10\" {
return(0, datasize(\"C_10_deployed\"))
function convert_t_stringliteral_9f0adad0a59b05d2e04a1373342b10b9eb16c57c164c8a3bfcbf46dccee39a21_to_t_bytes32() -> converted {
converted := 0x6162636162630000000000000000000000000000000000000000000000000000
}
function fun_f_9() -> vloc__4 {
let zero_value_for_type_t_bytes32_1 := zero_value_for_split_t_bytes32()
vloc__4 := zero_value_for_type_t_bytes32_1
vloc__4 := convert_t_stringliteral_9f0adad0a59b05d2e04a1373342b10b9eb16c57c164c8a3bfcbf46dccee39a21_to_t_bytes32()
leave
}
function zero_value_for_split_t_bytes32() -> ret {
ret := 0
}
}
object \"C_10_deployed\" {
code {
@@ -18,35 +18,6 @@ object \"C_10\" {
return(0, datasize(\"C_10_deployed\"))
function cleanup_t_rational_1633837924_by_1(value) -> cleaned {
cleaned := value
}
function convert_t_rational_1633837924_by_1_to_t_bytes4(value) -> converted {
converted := shift_left_224(cleanup_t_rational_1633837924_by_1(value))
}
function fun_f_9() -> vloc__4 {
let zero_value_for_type_t_bytes4_1 := zero_value_for_split_t_bytes4()
vloc__4 := zero_value_for_type_t_bytes4_1
let expr_6 := 0x61626364
vloc__4 := convert_t_rational_1633837924_by_1_to_t_bytes4(expr_6)
leave
}
function shift_left_224(value) -> newValue {
newValue :=
shl(224, value)
}
function zero_value_for_split_t_bytes4() -> ret {
ret := 0
}
}
object \"C_10_deployed\" {
code {
@@ -18,39 +18,6 @@ object \"C_10\" {
return(0, datasize(\"C_10_deployed\"))
function allocateMemory(size) -> memPtr {
memPtr := mload(64)
let newFreePtr := add(memPtr, size)
// protect against overflow
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { revert(0, 0) }
mstore(64, newFreePtr)
}
function convert_t_stringliteral_d6604f85ac07e2b33103a620b3d3d75b0473c7214912beded67b9b624d41c571_to_t_string_memory_ptr() -> converted {
converted := allocateMemory(128)
mstore(converted, 85)
mstore(add(converted, 32), \"abcdabcdcafecafeabcdabcdcafecafe\")
mstore(add(converted, 64), \"ffffzzzzoooo0123456789,.<,>.?:;'\")
mstore(add(converted, 96), \"[{]}|`~!@#$%^&*()-_=+\")
}
function fun_f_9() -> vloc__4_mpos {
let zero_value_for_type_t_string_memory_ptr_1_mpos := zero_value_for_split_t_string_memory_ptr()
vloc__4_mpos := zero_value_for_type_t_string_memory_ptr_1_mpos
vloc__4_mpos := convert_t_stringliteral_d6604f85ac07e2b33103a620b3d3d75b0473c7214912beded67b9b624d41c571_to_t_string_memory_ptr()
leave
}
function zero_value_for_split_t_string_memory_ptr() -> ret {
ret := 96
}
}
object \"C_10_deployed\" {
code {
@@ -18,35 +18,6 @@ object \"C_10\" {
return(0, datasize(\"C_10_deployed\"))
function cleanup_t_rational_2864434397_by_1(value) -> cleaned {
cleaned := value
}
function convert_t_rational_2864434397_by_1_to_t_bytes4(value) -> converted {
converted := shift_left_224(cleanup_t_rational_2864434397_by_1(value))
}
function fun_f_9() -> vloc__4 {
let zero_value_for_type_t_bytes4_1 := zero_value_for_split_t_bytes4()
vloc__4 := zero_value_for_type_t_bytes4_1
let expr_6 := 0xaabbccdd
vloc__4 := convert_t_rational_2864434397_by_1_to_t_bytes4(expr_6)
leave
}
function shift_left_224(value) -> newValue {
newValue :=
shl(224, value)
}
function zero_value_for_split_t_bytes4() -> ret {
ret := 0
}
}
object \"C_10_deployed\" {
code {
+1 -1
View File
@@ -1,3 +1,3 @@
# EVMC
This is an import of [EVMC](https://github.com/ethereum/evmc) version [7.0.0](https://github.com/ethereum/evmc/releases/tag/v7.0.0).
This is an import of [EVMC](https://github.com/ethereum/evmc) version [7.1.0](https://github.com/ethereum/evmc/releases/tag/v7.1.0).
+3
View File
@@ -42,6 +42,9 @@ def ISZERO(x):
def AND(x, y):
return x & y
def OR(x, y):
return x | y
def SHL(x, y):
return y << x
+39
View File
@@ -0,0 +1,39 @@
from rule import Rule
from opcodes import *
"""
Rule:
AND(AND(X, Y), Y) -> AND(X, Y)
AND(Y, AND(X, Y)) -> AND(X, Y)
AND(AND(Y, X), Y) -> AND(Y, X)
AND(Y, AND(Y, X)) -> AND(Y, X)
Requirements:
"""
rule = Rule()
n_bits = 256
# Input vars
X = BitVec('X', n_bits)
Y = BitVec('Y', n_bits)
# Constants
BitWidth = BitVecVal(n_bits, n_bits)
# Requirements
# Non optimized result
nonopt_1 = AND(AND(X, Y), Y)
nonopt_2 = AND(Y, AND(X, Y))
nonopt_3 = AND(AND(Y, X), Y)
nonopt_4 = AND(Y, AND(Y, X))
# Optimized result
opt_1 = AND(X, Y)
opt_2 = AND(Y, X)
rule.check(nonopt_1, opt_1)
rule.check(nonopt_2, opt_1)
rule.check(nonopt_3, opt_2)
rule.check(nonopt_4, opt_2)
+39
View File
@@ -0,0 +1,39 @@
from rule import Rule
from opcodes import *
"""
Rule:
OR(OR(X, Y), Y) -> OR(X, Y)
OR(Y, OR(X, Y)) -> OR(X, Y)
OR(OR(Y, X), Y) -> OR(Y, X)
OR(Y, OR(Y, X)) -> OR(Y, X)
Requirements:
"""
rule = Rule()
n_bits = 256
# Input vars
X = BitVec('X', n_bits)
Y = BitVec('Y', n_bits)
# Constants
BitWidth = BitVecVal(n_bits, n_bits)
# Requirements
# Non optimized result
nonopt_1 = OR(OR(X, Y), Y)
nonopt_2 = OR(Y, OR(X, Y))
nonopt_3 = OR(OR(Y, X), Y)
nonopt_4 = OR(Y, OR(Y, X))
# Optimized result
opt_1 = OR(X, Y)
opt_2 = OR(Y, X)
rule.check(nonopt_1, opt_1)
rule.check(nonopt_2, opt_1)
rule.check(nonopt_3, opt_2)
rule.check(nonopt_4, opt_2)
@@ -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,
@@ -130,8 +131,8 @@
"storageLocation": "default",
"typeDescriptions":
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
"typeIdentifier": null,
"typeString": null
},
"typeName":
{
@@ -141,8 +142,8 @@
"src": "49:4:1",
"typeDescriptions":
{
"typeIdentifier": "t_uint256",
"typeString": "uint256"
"typeIdentifier": null,
"typeString": null
}
},
"value": null,
@@ -77,12 +77,13 @@
"attributes":
{
"constant": false,
"mutability": "mutable",
"name": "x",
"overrides": null,
"scope": 7,
"stateVariable": false,
"storageLocation": "default",
"type": "uint256",
"type": null,
"value": null,
"visibility": "internal"
},
@@ -92,7 +93,7 @@
"attributes":
{
"name": "uint",
"type": "uint256"
"type": null
},
"id": 2,
"name": "ElementaryTypeName",
@@ -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,
+8
View File
@@ -27,6 +27,7 @@
#include <liblangutil/Scanner.h>
#include <libsolidity/parsing/Parser.h>
#include <libsolidity/analysis/DeclarationTypeChecker.h>
#include <libsolidity/analysis/NameAndTypeResolver.h>
#include <libsolidity/codegen/Compiler.h>
#include <libsolidity/ast/AST.h>
@@ -60,6 +61,7 @@ evmasm::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes;
GlobalContext globalContext;
NameAndTypeResolver resolver(globalContext, solidity::test::CommonOptions::get().evmVersion(), scopes, errorReporter);
DeclarationTypeChecker declarationTypeChecker(errorReporter, solidity::test::CommonOptions::get().evmVersion());
solAssert(Error::containsOnlyWarnings(errorReporter.errors()), "");
resolver.registerDeclarations(*sourceUnit);
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
@@ -69,6 +71,12 @@ evmasm::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
if (!Error::containsOnlyWarnings(errorReporter.errors()))
return AssemblyItems();
}
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
{
BOOST_REQUIRE_NO_THROW(declarationTypeChecker.check(*node));
if (!Error::containsOnlyWarnings(errorReporter.errors()))
return AssemblyItems();
}
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
@@ -25,6 +25,7 @@
#include <liblangutil/Scanner.h>
#include <libsolidity/parsing/Parser.h>
#include <libsolidity/analysis/NameAndTypeResolver.h>
#include <libsolidity/analysis/DeclarationTypeChecker.h>
#include <libsolidity/codegen/CompilerContext.h>
#include <libsolidity/codegen/ExpressionCompiler.h>
#include <libsolidity/ast/AST.h>
@@ -118,10 +119,12 @@ bytes compileFirstExpression(
map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes;
NameAndTypeResolver resolver(globalContext, solidity::test::CommonOptions::get().evmVersion(), scopes, errorReporter);
resolver.registerDeclarations(*sourceUnit);
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
BOOST_REQUIRE_MESSAGE(resolver.resolveNamesAndTypes(*contract), "Resolving names failed");
DeclarationTypeChecker declarationTypeChecker(errorReporter, solidity::test::CommonOptions::get().evmVersion());
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
BOOST_REQUIRE(declarationTypeChecker.check(*node));
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
+1
View File
@@ -184,6 +184,7 @@ BOOST_AUTO_TEST_CASE(type_identifiers)
BOOST_CHECK_EQUAL(ContractType(c, true).identifier(), "t_super$_MyContract$$$_$2");
StructDefinition s(++id, {}, make_shared<string>("Struct"), {});
s.annotation().recursive = false;
BOOST_CHECK_EQUAL(s.type()->identifier(), "t_type$_t_struct$_Struct_$3_storage_ptr_$");
EnumDefinition e(++id, {}, make_shared<string>("Enum"), {});
@@ -19,6 +19,8 @@ contract C {
return this.x.selector;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x26121ff000000000000000000000000000000000000000000000000000000000
// g() -> 0x26121ff000000000000000000000000000000000000000000000000000000000
@@ -6,5 +6,7 @@ contract test {
}
}
// ====
// compileViaYul: also
// ----
// answer() -> 1
@@ -12,5 +12,7 @@ contract test {
ActionChoices choices;
}
// ====
// compileViaYul: also
// ----
// getChoice() -> 2
@@ -8,6 +8,7 @@ contract test is base {
_ret = Choice.B;
}
}
// ====
// compileViaYul: also
// ----
// answer() -> 1
@@ -8,6 +8,7 @@ contract test is base {
_ret = base.Choice.B;
}
}
// ====
// compileViaYul: also
// ----
// answer() -> 1
@@ -0,0 +1,19 @@
contract test {
uint8 x;
uint v;
function f() public returns (uint x, uint y, uint z) {
uint16 a;
uint32 b;
assembly {
a := 0x0f0f0f0f0f
b := 0xff0fff0fff
}
x = a & b;
y = a | b;
z = a ^ b;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 3855, 268374015, 268370160
@@ -15,6 +15,8 @@ contract C {
return (a.f.selector, a.g.selector, b.f.selector, b.g.selector);
}
}
// ====
// compileViaYul: also
// ----
// test1() -> left(0x26121ff0), left(0xe420264a), left(0x26121ff0), left(0xe420264a)
// test2() -> left(0x26121ff0), left(0xe420264a), left(0x26121ff0), left(0xe420264a)
@@ -21,7 +21,8 @@ contract Derived is Base {
return 3;
}
}
// ====
// compileViaYul: also
// ----
// g() -> 3
// f() -> 1
@@ -14,6 +14,7 @@ contract B is A {
return A.f();
}
}
// ====
// compileViaYul: also
// ----
// g() -> 1
@@ -12,6 +12,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >=byzantium
// ----
// f(bool): true -> 1, 2, 96, 0
@@ -26,6 +26,7 @@ contract C {
}
// ====
// EVMVersion: >=byzantium
// compileViaYul: also
// ----
// f(bool,bool): true, true -> 1, 2, 96, 7, "success"
// f(bool,bool): true, false -> 12, 0, 96, 7, "failure"
@@ -13,5 +13,7 @@ contract C {
}
function fun() public pure {}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x1, 0xfdd67305928fcac8d213d1e47bfa6165cd0b87b946644cd0000000000000000, 9
@@ -1,10 +1,10 @@
contract C {
function g(bool b) public pure returns (uint, uint) {
function g(bool b) public pure returns (uint x, uint y) {
require(b);
return (1, 2);
}
function f(bool b) public returns (uint x, uint y) {
try this.g(b) returns (uint a, uint b) {
function f(bool flag) public view returns (uint x, uint y) {
try this.g(flag) returns (uint a, uint b) {
(x, y) = (a, b);
} catch {
(x, y) = (9, 10);
@@ -13,6 +13,7 @@ contract C {
}
// ====
// EVMVersion: >=byzantium
// compileViaYul: also
// ----
// f(bool): true -> 1, 2
// f(bool): false -> 9, 10
@@ -0,0 +1,19 @@
contract C {
function g(bool b) public pure returns (uint x) {
require(b);
return 13;
}
function f(bool flag) public view returns (uint x) {
try this.g(flag) returns (uint a) {
x = a;
} catch {
x = 9;
}
}
}
// ====
// EVMVersion: >=byzantium
// compileViaYul: also
// ----
// f(bool): true -> 13
// f(bool): false -> 9
@@ -14,6 +14,7 @@ contract C {
}
// ====
// EVMVersion: >=byzantium
// compileViaYul: also
// ----
// f(bool): true -> 1, 2, 0x60, 7, "success"
// f(bool): false -> 0, 0, 0x60, 7, "message"
@@ -18,6 +18,7 @@ contract C {
}
// ====
// EVMVersion: >=byzantium
// compileViaYul: also
// ----
// f(bool): true -> 1, 2, 96, 7, "success"
// f(bool): false -> 99, 0, 96, 82, "message longer than 32 bytes 32 ", "bytes 32 bytes 32 bytes 32 bytes", " 32 bytes 32 bytes"
@@ -0,0 +1,18 @@
contract C {
function g(bool x) external pure {
require(x);
}
function f(bool x) public returns (uint) {
try this.g(x) {
return 1;
} catch {
return 2;
}
}
}
// ====
// EVMVersion: >=byzantium
// compileViaYul: also
// ----
// f(bool): true -> 1
// f(bool): false -> 2
@@ -15,6 +15,16 @@ contract test {
(((, a),)) = ((1, 2), 3);
return a;
}
function f3() public returns(int) {
int a = 3;
((, ), ) = ((7, 8), 9);
return a;
}
function f4() public returns(int) {
int a;
(a, ) = (4, (8, 16, 32));
return a;
}
}
// ====
// compileViaYul: also
@@ -22,3 +32,5 @@ contract test {
// f0() -> 2, true
// f1() -> 1
// f2() -> 2
// f3() -> 3
// f4() -> 4
@@ -0,0 +1,13 @@
contract C {
function f() public pure returns (uint, uint, uint) {
bytes memory a; bytes memory b; bytes memory c;
(a, (b, c)) = ("0", ("1", "2"));
return (uint8(a[0]), uint8(b[0]), uint8(c[0]));
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x30, 0x31, 0x32
@@ -6,6 +6,7 @@ contract A {
x = A.y;
}
}
// ====
// compileViaYul: also
// ----
// a() -> 2
@@ -5,6 +5,7 @@ contract Scope {
stateVar = Scope.stateVar;
}
}
// ====
// compileViaYul: also
// ----
// getStateVar() -> 42
@@ -0,0 +1,21 @@
contract Base {
function f() public returns (uint256 i) {
return g();
}
function g() internal virtual returns (uint256 i) {
return 1;
}
}
contract Derived is Base {
function g() internal override returns (uint256 i) {
return 2;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 2
@@ -18,5 +18,4 @@ contract C {
// Warning: (212-219): Assertion checker does not yet implement this type of function call.
// Warning: (255-257): Internal error: Expression undefined for SMT solver.
// Warning: (255-257): Assertion checker does not yet implement type function (function (uint256))
// Warning: (212-214): Assertion checker does not yet implement type function (function (uint256))
// Warning: (212-219): Assertion checker does not yet implement this type of function call.
@@ -22,6 +22,4 @@ contract C {
// Warning: (284-291): Assertion checker does not yet implement this type of function call.
// Warning: (327-329): Internal error: Expression undefined for SMT solver.
// Warning: (327-329): Assertion checker does not yet implement type function (function (uint256))
// Warning: (284-286): Assertion checker does not yet implement type function (function (uint256))
// Warning: (287-288): Assertion checker does not yet support this global variable.
// Warning: (284-291): Assertion checker does not yet implement this type of function call.
@@ -19,7 +19,5 @@ contract C {
// Warning: (137-141): Assertion checker does not yet implement type struct C.S memory
// Warning: (137-141): Assertion checker does not yet implement this expression.
// Warning: (193-203): Assertion checker does not yet support the type of this variable.
// Warning: (137-138): Assertion checker does not yet implement type type(struct C.S storage pointer)
// Warning: (137-141): Assertion checker does not yet implement type struct C.S memory
// Warning: (137-141): Assertion checker does not yet implement this expression.
// Warning: (227-228): Assertion checker does not yet implement type struct C.S memory
@@ -6,3 +6,4 @@ contract C {
// ----
// DeclarationError: (28-45): The "constant" keyword can only be used for state variables.
// TypeError: (69-72): Invalid array length, expected integer literal or constant expression.
// TypeError: (64-75): Data location must be "storage" or "memory" for variable, but none was given.
@@ -0,0 +1,14 @@
contract C {
function f() public pure
{
bytes32[1263941234127518272][500] memory x;
uint[2**30][] memory y;
uint[2**30][2**30][] memory z;
uint[2**16][2**16][] memory w;
}
}
// ----
// TypeError: (48-90): Type too large for memory.
// TypeError: (96-118): Type too large for memory.
// TypeError: (124-153): Type too large for memory.
// TypeError: (159-188): Type too large for memory.
@@ -2,4 +2,4 @@ contract C {
function f(bytes32[1263941234127518272] memory) public pure {}
}
// ----
// TypeError: (26-61): Array is too large to be encoded.
// TypeError: (26-61): Type too large for memory.
@@ -5,7 +5,7 @@ contract C {
function f(uint[2**16][2**16][] memory) public pure {}
}
// ----
// TypeError: (26-66): Array is too large to be encoded.
// TypeError: (96-116): Array is too large to be encoded.
// TypeError: (146-173): Array is too large to be encoded.
// TypeError: (203-230): Array is too large to be encoded.
// TypeError: (26-66): Type too large for memory.
// TypeError: (96-116): Type too large for memory.
// TypeError: (146-173): Type too large for memory.
// TypeError: (203-230): Type too large for memory.
@@ -5,5 +5,5 @@ contract C {
function f(uint[2**30][2**30][][] memory) public pure {}
}
// ----
// TypeError: (61-101): Array is too large to be encoded.
// TypeError: (131-160): Array is too large to be encoded.
// TypeError: (61-101): Type too large for memory.
// TypeError: (131-160): Type too large for memory.
@@ -0,0 +1,5 @@
contract C {
constructor() override public {}
}
// ----
// TypeError: (17-49): Constructors cannot override.
@@ -0,0 +1,5 @@
contract C {
constructor() virtual public {}
}
// ----
// TypeError: (17-48): Constructors cannot be virtual.
@@ -8,4 +8,3 @@ library L
}
// ----
// DeclarationError: (32-35): Identifier not found or not unique.
// TypeError: (63-76): Internal type cannot be used for external function type.
@@ -0,0 +1,5 @@
contract C {
function ( uint ) external returns ( a [ ] calldata ) public a = ( 1 / 2 ) ;
}
// ----
// TypeError: (58-59): Name has to refer to a struct, enum or contract.
@@ -0,0 +1,17 @@
contract C {
struct X { bytes31 [ 3 ] x1 ;
uint x2 ;
}
struct S { uint256 [ ] [ 0.425781 ether ] s1 ;
uint [ 2 ** 0xFF ] [ 2 ** 0x42 ] s2 ;
X s3 ;
mapping ( uint => address payable ) c ;
uint [ 9 hours ** 16 ] d ;
string s ;
}
function f ( ) public { function ( function ( bytes9 , uint ) external pure returns ( uint ) , uint ) external pure returns ( uint ) [ 3 ] memory s2 ;
S memory s ;
}
}
// ----
// TypeError: (530-540): Type too large for memory.
@@ -0,0 +1,12 @@
contract C {
struct R { uint[10][10] y; }
struct S { uint a; uint b; R d; uint[20][20][2999999999999999999999999990] c; }
function f() public pure {
C.S memory y;
C.S[10] memory z;
y.a < 2;
z; y;
}
}
// ----
// TypeError: (169-181): Type too large for memory.
@@ -7,3 +7,4 @@ contract C {
}
}
// ----
// TypeError: (226-234): Type too large for memory.
@@ -0,0 +1,7 @@
contract C {
function h ( bool flag ) public returns ( bool c ) {
mapping ( string => uint24 ) [ 1 ] memory val ;
}
}
// ----
// TypeError: (91-136): Data location must be "storage" for variable, but "memory" was given.
@@ -0,0 +1,13 @@
contract Test {
struct RecursiveStruct {
address payable d ;
mapping ( uint => address payable ) c ;
mapping ( uint => address payable [ ] ) d ;
}
function func ( ) private pure {
RecursiveStruct [ 1 ] memory val ;
val ;
}
}
// ----
// DeclarationError: (157-198): Identifier already declared.
@@ -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"
@@ -3,3 +3,4 @@ contract c {
}
// ----
// TypeError: (51-52): Invalid array length, expected integer literal or constant expression.
// TypeError: (45-55): Data location must be "storage" or "memory" for variable, but none was given.
@@ -3,3 +3,4 @@ contract c {
}
// ----
// TypeError: (51-53): Array with negative length specified.
// TypeError: (45-56): Data location must be "storage" or "memory" for variable, but none was given.
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
// TypeError: (47-77): Type mapping(uint256 => uint256)[] memory is only valid in storage.
// TypeError: (47-77): Data location must be "storage" for variable, but "memory" was given.
@@ -5,3 +5,4 @@ contract test {
}
// ----
// TypeError: (55-58): Array with fractional length specified.
// TypeError: (50-61): Data location must be "storage" or "memory" for variable, but none was given.
@@ -5,3 +5,4 @@ contract test {
}
// ----
// TypeError: (55-65): Invalid array length, expected integer literal or constant expression.
// TypeError: (50-68): Data location must be "storage" or "memory" for variable, but none was given.
@@ -5,3 +5,4 @@ contract test {
}
// ----
// TypeError: (55-66): Invalid array length, expected integer literal or constant expression.
// TypeError: (50-69): Data location must be "storage" or "memory" for variable, but none was given.
@@ -3,4 +3,4 @@ contract C {
}
}
// ----
// TypeError: (28-56): Array is too large to be encoded.
// TypeError: (28-56): Type too large for calldata.
@@ -3,4 +3,4 @@ contract C {
}
}
// ----
// TypeError: (28-54): Array is too large to be encoded.
// TypeError: (28-54): Type too large for memory.

Some files were not shown because too many files have changed in this diff Show More