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

This commit is contained in:
chriseth
2020-04-07 11:14:28 +02:00
288 changed files with 6927 additions and 2129 deletions
@@ -2,8 +2,10 @@ contract C {
function f() public {
uint[] storage x;
uint[10] storage y;
x;
y;
}
}
// ----
// DeclarationError: (38-54): Uninitialized storage pointer.
// DeclarationError: (58-76): Uninitialized storage pointer.
// TypeError: (80-81): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (85-86): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,38 @@
contract C {
struct S { bool f; }
S s;
function f() internal pure {
S storage c;
assembly {
for {} eq(0,0) { c_slot := s_slot } {}
}
c;
}
function g() internal pure {
S storage c;
assembly {
for {} eq(0,1) { c_slot := s_slot } {}
}
c;
}
function h() internal pure {
S storage c;
assembly {
for {} eq(0,0) {} { c_slot := s_slot }
}
c;
}
function i() internal pure {
S storage c;
assembly {
for {} eq(0,1) {} { c_slot := s_slot }
}
c;
}
}
// ----
// TypeError: (189-190): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (340-341): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (491-492): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (642-643): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,19 @@
contract C {
struct S { bool f; }
S s;
function f() internal pure {
S storage c;
assembly {
for { c_slot := s_slot } iszero(0) {} {}
}
c;
}
function g() internal pure {
S storage c;
assembly {
for { c_slot := s_slot } iszero(1) {} {}
}
c;
}
}
// ----
@@ -0,0 +1,13 @@
contract C {
struct S { bool f; }
S s;
function f(bool flag) internal pure {
S storage c;
assembly {
if flag { c_slot := s_slot }
}
c;
}
}
// ----
// TypeError: (188-189): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,15 @@
contract C {
struct S { bool f; }
S s;
function f() internal pure {
S storage c;
// this should warn about unreachable code, but currently function flow is ignored
assembly {
function f() { return(0, 0) }
f()
c_slot := s_slot
}
c;
}
}
// ----
@@ -0,0 +1,15 @@
contract C {
struct S { bool f; }
S s;
function f() internal pure {
S storage c;
// this could be allowed, but currently control flow for functions is not analysed
assembly {
function f() { revert(0, 0) }
f()
}
c;
}
}
// ----
// TypeError: (287-288): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,12 @@
contract C {
struct S { bool f; }
S s;
function f() internal pure {
S storage c;
assembly {
c_slot := s_slot
}
c;
}
}
// ----
@@ -0,0 +1,33 @@
contract C {
struct S { bool f; }
S s;
function f(uint256 a) internal pure {
S storage c;
assembly {
switch a
case 0 { c_slot := s_slot }
}
c;
}
function g(bool flag) internal pure {
S storage c;
assembly {
switch flag
case 0 { c_slot := s_slot }
case 1 { c_slot := s_slot }
}
c;
}
function h(uint256 a) internal pure {
S storage c;
assembly {
switch a
case 0 { c_slot := s_slot }
default { return(0,0) }
}
c;
}
}
// ----
// TypeError: (208-209): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (421-422): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,31 @@
contract C {
struct S { bool f; }
S s;
function f(uint256 a) internal pure {
S storage c;
assembly {
switch a
default { c_slot := s_slot }
}
c;
}
function g(bool flag) internal pure {
S storage c;
assembly {
switch flag
case 0 { c_slot := s_slot }
default { c_slot := s_slot }
}
c;
}
function h(uint256 a) internal pure {
S storage c;
assembly {
switch a
case 0 { revert(0, 0) }
default { c_slot := s_slot }
}
c;
}
}
// ----
@@ -0,0 +1,66 @@
contract C {
struct S { bool f; }
S s;
function f() internal view {
S storage c;
do {
break;
c = s;
} while(false);
c;
}
function g() internal view {
S storage c;
do {
if (s.f) {
continue;
c = s;
}
else {
}
} while(false);
c;
}
function h() internal view {
S storage c;
do {
if (s.f) {
break;
}
else {
c = s;
}
} while(false);
c;
}
function i() internal view {
S storage c;
do {
if (s.f) {
continue;
}
else {
c = s;
}
} while(false);
c;
}
function j() internal view {
S storage c;
do {
continue;
c = s;
} while(false);
c;
}
}
// ----
// TypeError: (184-185): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// Warning: (145-150): Unreachable code.
// Warning: (168-173): Unreachable code.
// TypeError: (411-412): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// Warning: (325-330): Unreachable code.
// TypeError: (635-636): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (862-863): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (1011-1012): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// Warning: (972-977): Unreachable code.
@@ -0,0 +1,44 @@
contract C {
struct S { bool f; }
S s;
function f() internal view {
S storage c;
do {} while((c = s).f);
c;
}
function g() internal view {
S storage c;
do { c = s; } while(false);
c;
}
function h() internal view {
S storage c;
c = s;
do {} while(false);
c;
}
function i() internal view {
S storage c;
do {} while(false);
c = s;
c;
}
function j() internal view {
S storage c;
do {
c = s;
break;
} while(false);
c;
}
function k() internal view {
S storage c;
do {
c = s;
continue;
} while(false);
c;
}
}
// ----
// Warning: (606-611): Unreachable code.
@@ -0,0 +1,20 @@
contract C {
struct S { bool f; }
S s;
function f() internal view {
S storage c;
for(;; c = s) {
}
c;
}
function g() internal view {
S storage c;
for(;;) {
c = s;
}
c;
}
}
// ----
//TypeError: (143-144): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (261-262): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,17 @@
contract C {
struct S { bool f; }
S s;
function f() internal view {
S storage c;
for(c = s;;) {
}
c;
}
function g() internal view {
S storage c;
for(; (c = s).f;) {
}
c;
}
}
// ----
@@ -0,0 +1,22 @@
contract C {
struct S { bool f; }
S s;
function f(bool flag) internal {
S storage c;
if (flag) c = s;
c;
}
function g(bool flag) internal {
S storage c;
if (flag) c = s;
else
{
if (!flag) c = s;
else s.f = true;
}
c;
}
}
// ----
// TypeError: (138-139): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (330-331): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,39 @@
contract C {
struct S { bool f; }
S s;
function f(bool flag) internal view {
S storage c;
if (flag) c = s;
else c = s;
c;
}
function g(bool flag) internal view {
S storage c;
if (flag) c = s;
else { c = s; }
c;
}
function h(bool flag) internal view {
S storage c;
if (flag) c = s;
else
{
if (!flag) c = s;
else c = s;
}
c;
}
function i() internal view {
S storage c;
if ((c = s).f) {
}
c;
}
function j() internal view {
S storage c;
if ((c = s).f && !(c = s).f) {
}
c;
}
}
// ----
@@ -0,0 +1,20 @@
contract C {
modifier revertIfNoReturn() {
_;
revert();
}
modifier ifFlag(bool flag) {
if (flag)
_;
}
struct S { uint a; }
S s;
function f(bool flag) revertIfNoReturn() internal view {
if (flag) s;
}
function g(bool flag) revertIfNoReturn() ifFlag(flag) internal view {
s;
}
}
// ----
@@ -0,0 +1,11 @@
contract C {
struct S { bool f; }
S s;
function g(bool flag) internal view {
S storage c;
if (flag) c = s;
else revert();
s;
}
}
// ----
@@ -0,0 +1,24 @@
contract C {
struct S { bool f; }
S s;
function f() internal view {
S storage c;
false && (c = s).f;
c;
}
function g() internal view {
S storage c;
true || (c = s).f;
c;
}
function h() internal view {
S storage c;
// expect error, although this is always fine
true && (false || (c = s).f);
c;
}
}
// ----
// TypeError: (137-138): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (235-236): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (398-399): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,15 @@
contract C {
struct S { bool f; }
S s;
function f() internal view {
S storage c;
(c = s).f && false;
c;
}
function g() internal view {
S storage c;
(c = s).f || true;
c;
}
}
// ----
@@ -0,0 +1,17 @@
contract C {
struct S { bool f; }
S s;
function f() internal pure {}
function g() internal view { s; }
function h() internal view {
S storage c;
c = s;
c;
}
function i() internal view {
S storage c;
(c) = s;
c;
}
}
// ----
@@ -0,0 +1,11 @@
contract C {
uint256[] s;
function f() public {
bool d;
uint256[] storage x;
uint256[] storage y = d ? (x = s) : x;
y;
}
}
// ----
// TypeError: (145-146): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,9 @@
contract C {
uint256[] s;
function f() public view {
uint256[] storage x;
uint256[] storage y = (x = s)[0] > 0 ? x : x;
y;
}
}
// ---
@@ -0,0 +1,17 @@
contract C {
struct S { bool f; }
S s;
function f(bool flag) internal view {
S storage c;
flag ? (c = s).f : false;
c;
}
function g(bool flag) internal view {
S storage c;
flag ? false : (c = s).f;
c;
}
}
// ----
// TypeError: (152-153): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (266-267): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,20 @@
contract C {
struct S { bool f; }
S s;
function f(bool flag) internal view {
S storage c;
flag ? c = s : c = s;
c;
}
function g(bool flag) internal view {
S storage c;
flag ? c = s : (c = s);
c;
}
function h(bool flag) internal view {
S storage c;
flag ? (c = s).f : (c = s).f;
c;
}
}
// ----
@@ -0,0 +1,42 @@
contract C {
struct S { bool f; }
S s;
function ext() external {}
function f() internal
{
S storage r;
try this.ext() { }
catch (bytes memory) { r = s; }
r;
}
function g() internal
{
S storage r;
try this.ext() { r = s; }
catch (bytes memory) { }
r;
}
function h() internal
{
S storage r;
try this.ext() {}
catch Error (string memory) { r = s; }
catch (bytes memory) { r = s; }
r;
}
function i() internal
{
S storage r;
try this.ext() { r = s; }
catch (bytes memory) { r; }
r = s;
r;
}
}
// ====
// EVMVersion: >=byzantium
// ----
// TypeError: (206-207): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (343-344): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (526-527): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError: (653-654): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,30 @@
contract C {
struct S { bool f; }
S s;
function ext() external { }
function f() internal
{
S storage r;
try this.ext() { r = s; }
catch (bytes memory) { r = s; }
r;
}
function g() internal
{
S storage r;
try this.ext() { r = s; }
catch Error (string memory) { r = s; }
catch (bytes memory) { r = s; }
r;
}
function h() internal
{
S storage r;
try this.ext() { }
catch (bytes memory) { }
r = s;
r;
}
}
// ====
// EVMVersion: >=byzantium
@@ -0,0 +1,17 @@
contract C {
struct S { bool f; }
S s;
function f() internal view returns (S storage, uint) {
return (s,2);
}
function g() internal view {
uint a;
S storage c;
(c, a) = f();
c;
}
function h() internal view {
(s, s);
}
}
// ----
@@ -0,0 +1,13 @@
contract C {
struct S { bool f; }
S s;
function f() internal view {
S storage c;
while(false) {
c = s;
}
c;
}
}
// ----
// TypeError: (161-162): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,25 @@
contract C {
struct S { bool f; }
S s;
function f() internal view {
S storage c;
while((c = s).f) {
}
c;
}
function g() internal view {
S storage c;
c = s;
while(false) {
}
c;
}
function h() internal view {
S storage c;
while(false) {
}
c = s;
c;
}
}
// ----
@@ -0,0 +1,11 @@
contract C {
uint immutable x;
constructor() public {
if (false)
return;
x = 1;
}
}
// ----
// TypeError: (93-100): Construction control flow ends without initializing all immutable state variables.
@@ -0,0 +1,9 @@
contract C {
uint immutable x;
constructor() public {
if (false)
x = 1;
}
}
// ----
// TypeError: (93-94): Immutable variables must be initialized unconditionally, not in an if statement.
@@ -0,0 +1,12 @@
contract C {
uint immutable x;
constructor() public {
initX();
}
function initX() internal {
x = 3;
}
}
// ----
// TypeError: (126-127): Immutable variables can only be initialized inline or assigned directly in the constructor.
@@ -0,0 +1,10 @@
contract C {
uint immutable x;
constructor() public {
x = f();
}
function f() public pure returns (uint) { return 3 + x; }
}
// ----
// TypeError: (143-144): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,8 @@
contract C {
uint immutable x;
constructor() public {
x = 3 + x;
}
}
// ----
// TypeError: (78-79): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,13 @@
contract C {
uint immutable x;
uint immutable y;
constructor() public {
(x, y) = f();
}
function f() internal pure returns(uint _x, uint _y) {
_x = 3;
_y = 4;
}
}
// ----
@@ -0,0 +1,12 @@
contract C {
uint immutable x;
constructor() readX(x = 3) public { }
modifier readX(uint _x) {
_; f(_x);
}
function f(uint a) internal pure {}
}
// ----
// TypeError: (59-60): Immutable variables can only be initialized inline or assigned directly in the constructor.
@@ -0,0 +1,11 @@
contract C {
uint immutable x;
constructor() initX public {
}
modifier initX() {
_; x = 23;
}
}
// ----
// TypeError: (109-110): Immutable variables can only be initialized inline or assigned directly in the constructor.
@@ -0,0 +1,14 @@
contract C {
uint immutable x;
constructor() readX public {
x = 3;
}
modifier readX() {
_; f(x);
}
function f(uint a) internal pure {}
}
// ----
// TypeError: (126-127): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,8 @@
contract C {
uint immutable x = 3;
constructor() public {
x--;
}
}
// ----
// TypeError: (74-75): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,8 @@
contract C {
uint immutable x = 3;
constructor() public {
delete x;
}
}
// ----
// TypeError: (81-82): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,5 @@
contract C {
function() external immutable f;
}
// ----
// TypeError: (17-48): Immutable variables of external function type are not yet supported.
@@ -0,0 +1,5 @@
contract C {
uint immutable x = f();
function f() public pure returns (uint) { return 3; }
}
@@ -0,0 +1,7 @@
contract C {
uint immutable x = f();
function f() public pure returns (uint) { return 3 + x; }
}
// ----
// TypeError: (99-100): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,14 @@
contract B {
uint immutable x;
constructor(function() internal returns(uint) fp) internal {
x = fp();
}
}
contract C is B(C.f) {
function f() internal returns(uint) { return x = 2; }
}
// ----
// TypeError: (200-201): Immutable variables can only be initialized inline or assigned directly in the constructor.
// TypeError: (200-201): Immutable state variable already initialized.
@@ -0,0 +1,13 @@
contract B {
uint immutable x;
constructor(function() internal returns(uint) fp) internal {
x = fp();
}
}
contract C is B(C.f) {
function f() internal returns(uint) { return x + 2; }
}
// ----
// TypeError: (200-201): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -1,5 +0,0 @@
contract C {
uint immutable public x;
}
// ----
// UnimplementedFeatureError: NONE
@@ -1,3 +1,3 @@
contract C {
uint immutable x;
}
uint immutable x = 0;
}
@@ -0,0 +1,8 @@
contract C {
uint immutable x = 3;
constructor() public {
x++;
}
}
// ----
// TypeError: (74-75): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,8 @@
contract C {
uint immutable x = 0;
uint y = f();
function f() internal returns(uint) { return x; }
}
// ----
// TypeError: (107-108): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,15 @@
contract B {
uint immutable x;
constructor() public {
x = 3;
}
}
contract C is B {
uint immutable y;
constructor() public {
y = 3;
}
}
// ----
@@ -0,0 +1,14 @@
contract B {
uint immutable x;
constructor(uint _x) public {
x = _x;
}
}
contract C is B {
uint immutable y;
constructor() B(y = 3) public { }
}
// ----
// TypeError: (155-156): Immutable variables can only be initialized inline or assigned directly in the constructor.
@@ -0,0 +1,13 @@
contract B {
uint immutable x;
constructor(uint _x) public {
x = _x;
}
}
contract C is B(C.y = 3) {
uint immutable y;
}
// ----
// TypeError: (111-114): Immutable variables can only be initialized inline or assigned directly in the constructor.
@@ -0,0 +1,16 @@
contract B {
uint immutable x;
constructor(uint _x) public {
x = _x;
}
}
contract C is B(C.y) {
uint immutable y;
constructor() public {
y = 3;
}
}
// ----
// TypeError: (111-114): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,19 @@
contract B {
uint immutable x;
constructor() public {
x = xInit();
}
function xInit() internal virtual returns(uint) {
return 3;
}
}
contract C is B {
function xInit() internal override returns(uint) {
return x;
}
}
// ----
// TypeError: (260-261): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,19 @@
contract B {
uint immutable x = 3;
function readX() internal virtual returns(uint) {
return x;
}
}
contract C is B {
constructor() public {
B.readX;
}
function readX() internal override returns(uint) {
return 3;
}
}
// ----
// TypeError: (109-110): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,19 @@
contract B {
uint immutable x = 3;
function readX() internal view virtual returns(uint) {
return x;
}
}
contract C is B {
constructor() public {
super.readX();
}
function readX() internal view override returns(uint) {
return 1;
}
}
// ----
// TypeError: (114-115): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,21 @@
contract B {
uint immutable x;
constructor() readX public {
x = 3;
}
modifier readX() virtual {
_; f(3);
}
function f(uint a) internal pure {}
}
contract C is B {
modifier readX() override {
_; f(x);
}
}
// ----
// TypeError: (252-253): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,12 @@
contract B {
uint immutable x = 4;
}
contract C is B {
constructor() public {
x = 3;
}
}
// ----
// TypeError: (95-96): Immutable variables must be initialized in the constructor of the contract they are defined in.
// TypeError: (95-96): Immutable state variable already initialized.
@@ -0,0 +1,8 @@
contract C {
constructor() public {
return;
}
uint immutable x = 3;
}
// ----
@@ -0,0 +1,9 @@
contract C {
uint immutable x;
constructor() public {
while (true)
x = 1;
}
}
// ----
// TypeError: (95-96): Immutable variables can only be initialized once, not in a while statement.
@@ -0,0 +1,29 @@
contract A {
function f() internal virtual returns(uint) { return 3; }
}
contract B {
uint immutable x;
constructor() public {
x = xInit();
}
function xInit() internal virtual returns(uint) {
return f();
}
function f() internal virtual returns(uint) { return 3; }
}
contract C is A, B {
function xInit() internal override returns(uint) {
return B.xInit();
}
function f() internal override(A, B) returns(uint) {
return x;
}
}
// ----
// TypeError: (496-497): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,29 @@
contract A {
function f() internal virtual returns(uint) { return 3; }
}
contract B {
uint immutable x;
constructor() public {
x = xInit();
}
function xInit() internal virtual returns(uint) {
return f();
}
function f() internal virtual returns(uint) { return 3; }
}
contract C is A, B {
function xInit() internal override returns(uint) {
return super.xInit();
}
function f() internal override(A, B) returns(uint) {
return x;
}
}
// ----
// TypeError: (500-501): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,9 @@
contract C {
uint immutable x;
constructor() public {
x = 1;
x = 4;
}
}
// ----
// TypeError: (85-86): Immutable state variable already initialized.
@@ -0,0 +1,20 @@
contract B {
uint immutable private x = f();
constructor() public {
}
function f() internal view virtual returns(uint) { return 1; }
function readX() internal view returns(uint) { return x; }
}
contract C is B {
uint immutable y;
constructor() public {
y = 3;
}
function f() internal view override returns(uint) { return readX(); }
}
// ----
// TypeError: (209-210): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,8 @@
contract C {
uint immutable x = 0;
uint y = 0;
function f() internal {
y = x + 1;
}
}
@@ -0,0 +1,12 @@
contract C {
uint immutable x = 0;
uint y = 0;
function f() readX internal {
}
modifier readX() {
_;
y = x + 1;
}
}
@@ -0,0 +1,6 @@
contract C {
uint immutable x = 0;
uint y = x;
}
// ----
// TypeError: (52-53): Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
@@ -0,0 +1,10 @@
contract C {
uint immutable x;
constructor() public {
return;
x = 1;
}
}
// ----
// TypeError: (70-77): Construction control flow ends without initializing all immutable state variables.
@@ -0,0 +1,12 @@
contract C {
uint immutable x;
constructor() public {
x = 3;
this.readX.selector;
}
function readX() external view returns(uint) { return x; }
}
// ----
// Warning: (85-104): Statement has no effect.
// Warning: (85-89): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed.
@@ -0,0 +1,13 @@
contract C {
uint immutable x;
constructor() public {
x = 3;
C.selector.selector;
C.selector;
}
function selector() external view returns(uint) { return x; }
}
// ----
// Warning: (85-104): Statement has no effect.
// Warning: (114-124): Statement has no effect.
@@ -0,0 +1,16 @@
contract C {
uint immutable x;
constructor() public {
x = 3;
readX().selector;
}
function f() external view returns(uint) {
return x;
}
function readX() public view returns(function() external view returns(uint) _f) {
_f = this.f;
}
}
// ----
@@ -0,0 +1,5 @@
contract C {
uint immutable x;
}
// ----
// TypeError: (0-36): Construction control flow ends without initializing all immutable state variables.
@@ -0,0 +1,21 @@
contract B {
uint immutable private x;
constructor() public {
}
function f() internal view virtual returns(uint) { return 1; }
function readX() internal view returns(uint) { return x; }
}
contract C is B {
uint immutable y;
constructor() public {
y = 3;
}
function f() internal view override returns(uint) { return readX(); }
}
// ----
// TypeError: (0-209): Construction control flow ends without initializing all immutable state variables.
// TypeError: (211-375): Construction control flow ends without initializing all immutable state variables.
@@ -0,0 +1,8 @@
contract C {
uint immutable x = 1;
function readX() internal view returns(uint) {
return x + 3;
}
}
// ----
@@ -0,0 +1,10 @@
contract C {
uint immutable x = 0;
function f() internal {
x = 1;
}
}
// ----
// TypeError: (76-77): Immutable variables can only be initialized inline or assigned directly in the constructor.
// TypeError: (76-77): Immutable state variable already initialized.
@@ -0,0 +1,12 @@
contract C {
uint immutable x = 0;
function f() readX internal { }
modifier readX() {
_; x = 1;
}
}
// ----
// TypeError: (111-112): Immutable variables can only be initialized inline or assigned directly in the constructor.
// TypeError: (111-112): Immutable state variable already initialized.
@@ -5,3 +5,5 @@ contract C {
}
}
}
// ----
// DeclarationError: (72-73): Access to functions is not allowed in inline assembly.
@@ -0,0 +1,10 @@
contract C {
function f() public pure {}
constructor() public {
assembly {
let x := f
}
}
}
// ----
// DeclarationError: (112-113): Access to functions is not allowed in inline assembly.
@@ -5,4 +5,4 @@ contract C {
}
}
// ----
// DeclarationError: (52-85): Uninitialized storage pointer.
// TypeError: (95-96): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -8,4 +8,4 @@ contract C {
}
}
// ----
// DeclarationError: (84-95): Uninitialized storage pointer.
// TypeError: (105-106): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,6 @@
interface I {
function f() external m pure returns (uint);
modifier m() { _; }
}
// ----
// SyntaxError: (16-60): Functions in interfaces cannot have modifiers.
@@ -0,0 +1,8 @@
abstract contract C {
/// @param id Some identifier
/// @return value Some value
/// @return value2 Some value 2
function vote(uint id) public virtual returns (uint value);
}
// ----
// DocstringParsingError: (26-121): Documentation tag "@return value2 Some value 2" exceeds the number of return parameters.
@@ -3,4 +3,3 @@ contract c {
}
// ----
// TypeError: (39-58): Type int_const 7 is not implicitly convertible to expected type contract c[10] storage pointer.
// DeclarationError: (60-83): Uninitialized storage pointer.
@@ -0,0 +1,7 @@
contract C {
struct S {t t;}
function f(function(S memory) external) public {}
}
// ----
// TypeError: (25-26): Name has to refer to a struct, enum or contract.
// TypeError: (53-61): Internal type cannot be used for external function type.
@@ -0,0 +1,8 @@
contract C {
function f() public {}
struct S {f x;}
function g(function(S memory) external) public {}
}
// ----
// TypeError: (50-51): Name has to refer to a struct, enum or contract.
// TypeError: (78-86): Internal type cannot be used for external function type.
@@ -0,0 +1,12 @@
contract C {
function f() {
(((((((((((,2),)),)),),))=4)));
}
}
// ----
// SyntaxError: (15-69): No visibility specified. Did you intend to add "public"?
// TypeError: (46-47): Expression has to be an lvalue.
// TypeError: (60-61): Type int_const 4 is not implicitly convertible to expected type tuple(tuple(tuple(tuple(tuple(,int_const 2),),),),).
// TypeError: (37-61): Tuple component cannot be empty.
// TypeError: (36-62): Tuple component cannot be empty.
// TypeError: (35-63): Tuple component cannot be empty.
@@ -0,0 +1,6 @@
contract C {
function f() public pure {
int a;
(((a,),)) = ((1,2),3);
}
}
@@ -1,8 +1,8 @@
contract B {
uint immutable x;
uint immutable x = 1;
function f() public pure returns (uint) {
return x;
}
}
// ----
// TypeError: (96-97): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
// TypeError: (100-101): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".