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

This commit is contained in:
chriseth
2020-10-08 20:18:04 +02:00
91 changed files with 924 additions and 171 deletions
@@ -1,4 +1,4 @@
Error: Expected pragma, import directive or contract/interface/library/struct/enum/function definition.
Error: Expected pragma, import directive or contract/interface/library/struct/enum/constant/function definition.
--> recovery_ast_empty_contract/input.sol:3:1:
|
3 | c
+4 -4
View File
@@ -1,5 +1,5 @@
Error (1834): Unimplemented feature error: setToZero for type t_struct$_S_$4_storage not yet implemented! in FILENAME REMOVED
--> yul_unimplemented/input.sol:9:9:
Error (1834): Unimplemented feature error: Byte Arrays not yet implemented! in FILENAME REMOVED
--> yul_unimplemented/input.sol:6:9:
|
9 | delete str;
| ^^^^^^^^^^
6 | delete a;
| ^^^^^^^^
@@ -1,11 +1,8 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract test {
struct S {
uint x;
}
S str;
constructor() {
delete str;
bytes a;
function f() public {
delete a;
}
}
@@ -1,4 +1,6 @@
pragma solidity ^99.99.0;
this is surely invalid
// ----
// ParserError 7858: (26-30): Expected pragma, import directive or contract/interface/library/struct/enum/function definition.
// ParserError 6635: (31-33): Expected identifier but got 'is'
// ParserError 6635: (34-40): Expected ';' but got identifier
// ParserError 6635: (49-49): Expected ';' but got end of source
@@ -16,5 +16,7 @@ contract c {
}
}
// ====
// compileViaYul: also
// ----
// test() -> 0x20, 0x8, -1, -1, 8, -16, -2, 6, 8, -1
@@ -6,5 +6,7 @@ contract C {
return (b[0], b.length);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 1, 3
@@ -8,5 +8,7 @@ contract c {
}
}
// ====
// compileViaYul: also
// ----
// test() -> 0x20, 29, 0x0303030303030303030303030303030303030303030303030303030303000000
@@ -8,5 +8,7 @@ contract c {
}
}
// ====
// compileViaYul: also
// ----
// test() -> 0x20, 33, 0x303030303030303030303030303030303030303030303030303030303030303, 0x0300000000000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,21 @@
contract C {
uint72[5][] a;
function f() public returns (uint72, uint72, uint72, uint72, uint72, uint72, uint72) {
for (uint i = 0; i < 4; i++)
a.push();
a[0][0] = 1;
a[0][3] = 2;
a[1][1] = 3;
a[1][4] = 4;
a[2][0] = 5;
a[3][2] = 6;
a[3][3] = 7;
uint72[5][] memory m = a;
return (m[0][0], m[0][3], m[1][1], m[1][4], m[2][0], m[3][2], m[3][3]);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 1, 2, 3, 4, 5, 6, 7
@@ -0,0 +1,13 @@
pragma experimental ABIEncoderV2;
contract C {
bytes[] a;
function f() public returns (bytes[] memory) {
a.push("abc");
a.push("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ");
bytes[] memory m = a;
return m;
}
}
// ----
// f() -> 0x20, 0x02, 0x40, 0x80, 3, 0x6162630000000000000000000000000000000000000000000000000000000000, 0x99, 44048183304486788312148433451363384677562265908331949128489393215789685032262, 32241931068525137014058842823026578386641954854143559838526554899205067598957, 49951309422467613961193228765530489307475214998374779756599339590522149884499, 0x54555658595a6162636465666768696a6b6c6d6e6f707172737475767778797a, 0x4142434445464748494a4b4c4d4e4f5051525354555658595a00000000000000
@@ -0,0 +1,22 @@
contract C {
uint72[5][] a;
function f() public returns (uint72, uint72, uint72, uint72, uint72, uint72, uint72) {
for (uint i = 0; i < 4; i++)
a.push();
a[0][0] = 1;
a[0][3] = 2;
a[1][1] = 3;
a[1][4] = 4;
a[2][0] = 5;
a[3][2] = 6;
a[3][3] = 7;
uint72[5][] storage a_ = a;
uint72[5][] memory m = a_;
return (m[0][0], m[0][3], m[1][1], m[1][4], m[2][0], m[3][2], m[3][3]);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 1, 2, 3, 4, 5, 6, 7
@@ -0,0 +1,26 @@
contract C {
struct T { uint8 x; uint8 y; uint[] z; }
T[3][] a;
function f() public returns (uint8, uint8, uint, uint, uint, uint8, uint8, uint, uint, uint) {
a.push();
a.push();
a[0][1].x = 11;
a[0][1].y = 12;
a[0][1].z.push(1);
a[0][1].z.push(2);
a[0][1].z.push(3);
a[1][2].x = 21;
a[1][2].y = 22;
a[1][2].z.push(4);
a[1][2].z.push(5);
a[1][2].z.push(6);
T[3][] memory m = a;
return (
m[0][1].x, m[0][1].y, m[0][1].z[0], m[0][1].z[1], m[0][1].z[2],
m[1][2].x, m[1][2].y, m[1][2].z[0], m[1][2].z[1], m[1][2].z[2]
);
}
}
// ----
// f() -> 11, 0x0c, 1, 2, 3, 0x15, 22, 4, 5, 6
@@ -0,0 +1,15 @@
contract C {
uint8[33] a;
function f() public returns (uint8, uint8, uint8) {
a[0] = 2;
a[16] = 3;
a[32] = 4;
uint8[33] memory m = a;
return (m[0], m[16], m[32]);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 2, 3, 4
@@ -0,0 +1,17 @@
contract C {
uint8[] a;
function f() public returns (uint8, uint8, uint8) {
for (uint i = 0; i < 33; i++)
a.push(7);
a[0] = 2;
a[16] = 3;
a[32] = 4;
uint8[] memory m = a;
return (m[0], m[16], m[32]);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 2, 3, 4
@@ -16,5 +16,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> true # This code interprets x as an array length and thus will go out of gas. neither of the two should throw due to out-of-bounds access #
@@ -15,5 +15,7 @@ contract Test {
return set(data)[1];
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x20, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07
@@ -31,6 +31,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// l() -> 0
// f(uint256): 42 ->
@@ -8,5 +8,7 @@ contract c {
return keccak256(abi.encodePacked("b", keccak256(data), "a"));
}
}
// ====
// compileViaYul: also
// ----
// foo() -> 0xb338eefce206f9f57b83aa738deecd5326dc4b72dd81ee6a7c621a6facb7acdc
@@ -9,5 +9,7 @@ contract c {
}
}
// ====
// compileViaYul: also
// ----
// foo() -> true
@@ -0,0 +1,9 @@
address constant e = 0x1212121212121212121212121000002134593163;
contract C {
function f() public returns (address z) {
assembly { z := e }
}
}
// ----
// f() -> 0x1212121212121212121212121000002134593163
@@ -0,0 +1,33 @@
bytes constant a = "\x03\x01\x02";
bytes constant b = hex"030102";
string constant c = "hello";
uint256 constant x = 56;
enum ActionChoices {GoLeft, GoRight, GoStraight, Sit}
ActionChoices constant choices = ActionChoices.GoRight;
bytes32 constant st = "abc\x00\xff__";
contract C {
function f() public returns (bytes memory) {
return a;
}
function g() public returns (bytes memory) {
return b;
}
function h() public returns (bytes memory) {
return bytes(c);
}
function i() public returns (uint, ActionChoices, bytes32) {
return (x, choices, st);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x20, 3, "\x03\x01\x02"
// g() -> 0x20, 3, "\x03\x01\x02"
// h() -> 0x20, 5, "hello"
// i() -> 0x38, 1, 0x61626300ff5f5f00000000000000000000000000000000000000000000000000
@@ -0,0 +1,41 @@
==== Source: s1.sol ====
bytes constant a = b;
bytes constant b = hex"030102";
function fre() pure returns (bytes memory) {
return a;
}
==== Source: s2.sol ====
import "s1.sol";
uint256 constant c = uint8(a[0]) + 2;
contract C {
function f() public returns (bytes memory) {
return a;
}
function g() public returns (bytes memory) {
return b;
}
function h() public returns (uint) {
return c;
}
function i() public returns (bytes memory) {
return fre();
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x20, 3, "\x03\x01\x02"
// g() -> 0x20, 3, "\x03\x01\x02"
// h() -> 5
// i() -> 0x20, 3, "\x03\x01\x02"
@@ -0,0 +1,26 @@
==== Source: s1.sol ====
uint constant a = 89;
function fre() pure returns (uint) {
return a;
}
==== Source: s2.sol ====
import {a as b, fre} from "s1.sol";
import "s1.sol" as M;
uint256 constant a = 13;
contract C {
function f() public returns (uint, uint, uint, uint) {
return (a, fre(), M.a, b);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x0d, 0x59, 0x59, 0x59
@@ -23,6 +23,8 @@ contract test {
return ret;
}
}
// ====
// compileViaYul: also
// ----
// f(bool): true -> 1
// f(bool): false -> 2
@@ -0,0 +1,15 @@
==== Source: a.sol ====
function f(uint) pure returns (uint) { return 7; }
function f(bytes memory x) pure returns (uint) { return x.length; }
==== Source: b.sol ====
import "a.sol" as M;
contract C {
function f() public pure returns (uint, uint) {
return (M.f(2), M.f("abc"));
}
}
// ====
// compileViaYul: also
// ----
// f() -> 7, 3
@@ -18,6 +18,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> true
// a() -> 7
@@ -21,5 +21,7 @@ contract C {
return (s.f(), h(s));
}
}
// ====
// compileViaYul: also
// ----
// g() -> 7, 7
@@ -0,0 +1,26 @@
contract C {
struct S {
uint16 v;
S[] x;
}
uint8[77] padding;
S s;
constructor() {
s.v = 21;
s.x.push(); s.x.push(); s.x.push();
s.x[0].v = 101; s.x[1].v = 102; s.x[2].v = 103;
}
function f() public returns (uint256 a, uint256 b, uint256 c, uint256 d) {
S storage sptr1 = s.x[0];
S storage sptr2 = s.x[1];
S storage sptr3 = s.x[2];
uint256 slot1; uint256 slot2; uint256 slot3;
assembly { slot1 := sptr1.slot slot2 := sptr2.slot slot3 := sptr3.slot }
delete s;
assembly { a := sload(s.slot) b := sload(slot1) c := sload(slot2) d := sload(slot3) }
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0, 0, 0, 0
@@ -15,5 +15,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> 1
@@ -16,5 +16,7 @@ contract test {
}
}
// ====
// compileViaYul: also
// ----
// deleteMember() -> 0
@@ -0,0 +1,23 @@
contract C {
struct S {
uint256 x;
uint128 y;
uint32 z;
}
uint8 b = 23;
S s;
uint8 a = 17;
function f() public {
s.x = 42; s.y = 42; s.y = 42;
delete s;
assert(s.x == 0);
assert(s.y == 0);
assert(s.z == 0);
assert(b == 23);
assert(a == 17);
}
}
// ====
// compileViaYul: also
// ----
// f() ->
@@ -0,0 +1,47 @@
pragma experimental ABIEncoderV2;
contract C {
struct S {
uint128 a;
uint256[] x;
uint240 b;
}
uint8 b = 23;
S s;
uint8 a = 17;
function f() public {
delete s;
s.x.push(42); s.x.push(42); s.x.push(42);
delete s;
assert(s.x.length == 0);
uint256[] storage x = s.x;
assembly { sstore(x.slot, 3) }
assert(s.x[0] == 0);
assert(s.x[1] == 0);
assert(s.x[2] == 0);
assert(b == 23);
assert(a == 17);
}
function g() public {
delete s;
s.x.push(42); s.x.push(42); s.x.push(42);
s.a = 1; s.b = 2;
delete s.x;
assert(s.x.length == 0);
uint256[] storage x = s.x;
assembly { sstore(x.slot, 3) }
assert(s.x[0] == 0);
assert(s.x[1] == 0);
assert(s.x[2] == 0);
assert(b == 23);
assert(a == 17);
assert(s.a == 1);
assert(s.b == 2);
}
}
// ====
// compileViaYul: also
// ----
// f() ->
// g() ->
@@ -14,5 +14,7 @@ contract test {
}
}
// ====
// compileViaYul: also
// ----
// deleteIt() -> 0
@@ -18,6 +18,8 @@ contract test {
inner.recursive[0].z = inner.recursive[1].z + 1;
}
}
// ====
// compileViaYul: also
// ----
// check() -> false
// set() ->
@@ -22,5 +22,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> true
@@ -4,6 +4,6 @@ contract C {
}
}
// ----
// DeclarationError 1788: (28-45): The "constant" keyword can only be used for state variables.
// DeclarationError 1788: (28-45): The "constant" keyword can only be used for state variables or variables at file level.
// TypeError 5462: (69-72): Invalid array length, expected integer literal or constant expression.
// TypeError 6651: (64-75): Data location must be "storage", "memory" or "calldata" for variable, but none was given.
@@ -0,0 +1,3 @@
/// @dev Documentation
uint constant x = 8;
// ----
@@ -0,0 +1,4 @@
/// Documentation
uint constant x = 8;
// ----
// DocstringParsingError 6546: (0-18): Documentation tag @notice not valid for file-level variables.
@@ -0,0 +1,3 @@
uint constant override x = 2;
// ----
// ParserError 2314: (14-22): Expected identifier but got 'override'
@@ -0,0 +1,3 @@
uint constant x;
// ----
// TypeError 4266: (0-15): Uninitialized "constant" variable.
@@ -0,0 +1,3 @@
uint constant virtual x;
// ----
// ParserError 2314: (14-21): Expected identifier but got 'virtual'
@@ -0,0 +1,3 @@
uint public constant x = 7;
// ----
// ParserError 2314: (5-11): Expected identifier but got 'public'
@@ -0,0 +1,3 @@
uint constant public y = 7;
// ----
// ParserError 2314: (14-20): Expected identifier but got 'public'
@@ -0,0 +1,15 @@
==== Source: a ====
import "b";
uint constant c = d;
==== Source: b ====
import "a";
uint constant b = c;
uint constant d = b;
contract C {
uint constant a = b;
}
// ----
// TypeError 6161: (b:12-31): The value of the constant b has a cyclic dependency via c.
// TypeError 6161: (b:33-52): The value of the constant d has a cyclic dependency via b.
// TypeError 6161: (b:71-90): The value of the constant a has a cyclic dependency via b.
// TypeError 6161: (a:12-31): The value of the constant c has a cyclic dependency via d.
@@ -0,0 +1,15 @@
==== Source: a ====
import "b";
uint constant c = d;
==== Source: b ====
import "a" as M;
uint constant b = M.c;
uint constant d = b;
contract C {
uint constant a = b;
}
// ----
// TypeError 6161: (b:17-38): The value of the constant b has a cyclic dependency via c.
// TypeError 6161: (b:40-59): The value of the constant d has a cyclic dependency via b.
// TypeError 6161: (b:78-97): The value of the constant a has a cyclic dependency via b.
// TypeError 6161: (a:12-31): The value of the constant c has a cyclic dependency via d.
@@ -0,0 +1,3 @@
uint[] memory constant x = 2;
// ----
// ParserError 2314: (7-13): Expected identifier but got 'memory'
@@ -0,0 +1,3 @@
uint[] constant memory x = 2;
// ----
// ParserError 2314: (16-22): Expected identifier but got 'memory'
@@ -0,0 +1,4 @@
uint immutable x = 7;
// ----
// DeclarationError 8342: (0-20): Only constant variables are allowed at file level.
// DeclarationError 8297: (0-20): The "immutable" keyword can only be used for state variables.
@@ -0,0 +1,3 @@
mapping(uint => uint) constant b = b;
// ----
// TypeError 9259: (0-36): Constants of non-value type not yet implemented.
@@ -0,0 +1,7 @@
==== Source: a ====
uint constant c = 7;
==== Source: b ====
import {c as d} from "a";
uint constant d = 7;
// ----
// DeclarationError 2333: (b:26-45): Identifier already declared.
@@ -0,0 +1,3 @@
uint x = 7;
// ----
// DeclarationError 8342: (0-10): Only constant variables are allowed at file level.
@@ -0,0 +1,8 @@
==== Source: a ====
import "b";
uint constant c = 7;
==== Source: b ====
import "a";
uint constant c = 7;
// ----
// DeclarationError 2333: (b:12-31): Identifier already declared.
@@ -0,0 +1,4 @@
uint constant c = 7;
uint constant c = 8;
// ----
// DeclarationError 2333: (21-40): Identifier already declared.
@@ -0,0 +1,5 @@
struct S { uint x; }
S constant s;
// ----
// TypeError 9259: (21-33): Constants of non-value type not yet implemented.
// TypeError 4266: (21-33): Uninitialized "constant" variable.
@@ -1,3 +1,3 @@
constructor() {}
// ----
// ParserError 7858: (0-11): Expected pragma, import directive or contract/interface/library/struct/enum/function definition.
// ParserError 7858: (0-11): Expected pragma, import directive or contract/interface/library/struct/enum/constant/function definition.
@@ -1,3 +1,3 @@
fallback(){}
// ----
// ParserError 7858: (0-8): Expected pragma, import directive or contract/interface/library/struct/enum/function definition.
// ParserError 7858: (0-8): Expected pragma, import directive or contract/interface/library/struct/enum/constant/function definition.
@@ -1,3 +1,3 @@
receive() {}
// ----
// ParserError 7858: (0-7): Expected pragma, import directive or contract/interface/library/struct/enum/function definition.
// ParserError 7858: (0-7): Expected pragma, import directive or contract/interface/library/struct/enum/constant/function definition.
@@ -2,4 +2,4 @@ contract test {
function f(uint[] memory constant a) public { }
}
// ----
// DeclarationError 1788: (31-55): The "constant" keyword can only be used for state variables.
// DeclarationError 1788: (31-55): The "constant" keyword can only be used for state variables or variables at file level.
@@ -0,0 +1,4 @@
uint constant c = 7;
function c() returns (uint) {}
// ----
// DeclarationError 2333: (21-51): Identifier already declared.
@@ -11,4 +11,4 @@ contract C {
}
}
// ----
// ParserError 2837: (290-295): Only state variables can have a docstring.
// ParserError 2837: (290-295): Only state variables or file-level variables can have a docstring.
@@ -2,4 +2,4 @@ contract Foo {
function f(uint[] storage constant x, uint[] memory y) internal { }
}
// ----
// DeclarationError 1788: (30-55): The "constant" keyword can only be used for state variables.
// DeclarationError 1788: (30-55): The "constant" keyword can only be used for state variables or variables at file level.
@@ -0,0 +1,6 @@
struct S { mapping(uint => uint)[2] a; }
contract C {
function f(S storage s) public {}
}
// ----
// TypeError 6651: (69-80): Data location must be "memory" or "calldata" for parameter in function, but "storage" was given.
@@ -0,0 +1,4 @@
struct S { mapping(uint => uint)[2] a; }
library L {
function f(S storage s) public {}
}
@@ -0,0 +1,5 @@
library Test {
struct Nested { mapping(uint => uint)[2][] a; }
struct X { Nested n; }
function f(X storage x) public {}
}
+1 -1
View File
@@ -1,3 +1,3 @@
unexpected
// ----
// ParserError 7858: (0-10): Expected pragma, import directive or contract/interface/library/struct/enum/function definition.
// ParserError 7858: (0-10): Expected pragma, import directive or contract/interface/library/struct/enum/constant/function definition.