Minor tweaks to immutable tests for better diffs

This commit is contained in:
Kamil Śliwak 2023-06-02 12:40:19 +02:00
parent 703fa6c8b5
commit 0afe025f19
13 changed files with 27 additions and 28 deletions

View File

@ -4,7 +4,7 @@ contract C {
x = f();
}
function f() public pure returns (uint) { return 3 + x; }
function f() public view returns (uint) { return 3 + x; }
}
// ----
// TypeError 7733: (136-137): Immutable variables cannot be read before they are initialized.

View File

@ -1,7 +1,7 @@
contract C {
uint immutable x = f();
function f() public pure returns (uint) { return 3 + x; }
function f() public view returns (uint) { return 3 + x; }
}
// ----
// TypeError 7733: (99-100): Immutable variables cannot be read before they are initialized.

View File

@ -7,7 +7,7 @@ abstract contract B {
}
contract C is B(C.f) {
function f() internal returns(uint) { return x + 2; }
function f() internal view returns(uint) { return x + 2; }
}
// ----
// TypeError 7733: (200-201): Immutable variables cannot be read before they are initialized.
// TypeError 7733: (205-206): Immutable variables cannot be read before they are initialized.

View File

@ -2,7 +2,7 @@ contract C {
uint immutable x = 0;
uint y = f();
function f() internal returns(uint) { return x; }
function f() internal pure returns(uint) { return x; }
}
// ----
// TypeError 7733: (107-108): Immutable variables cannot be read before they are initialized.
// TypeError 7733: (112-113): Immutable variables cannot be read before they are initialized.

View File

@ -5,15 +5,15 @@ contract B {
x = xInit();
}
function xInit() internal virtual returns(uint) {
function xInit() internal view virtual returns(uint) {
return 3;
}
}
contract C is B {
function xInit() internal override returns(uint) {
function xInit() internal view override returns(uint) {
return x;
}
}
// ----
// TypeError 7733: (253-254): Immutable variables cannot be read before they are initialized.
// TypeError 7733: (263-264): Immutable variables cannot be read before they are initialized.

View File

@ -0,0 +1,7 @@
contract D {
uint immutable t;
modifier m(uint) { _; }
constructor() m(t = 2) {}
}
// ----
// TypeError 1581: (83-84): Cannot write to immutable here: Immutable variables can only be initialized inline or assigned directly in the constructor.

View File

@ -1,6 +1,6 @@
contract C { constructor(uint) {} }
contract D is C(D.t = 2) {
uint immutable t;
uint immutable t;
}
// ----
// TypeError 1581: (52-55): Cannot write to immutable here: Immutable variables can only be initialized inline or assigned directly in the constructor.

View File

@ -1,7 +0,0 @@
contract D {
uint immutable t;
modifier m(uint) { _; }
constructor() m(t=2) {}
}
// ----
// TypeError 1581: (77-78): Cannot write to immutable here: Immutable variables can only be initialized inline or assigned directly in the constructor.

View File

@ -13,7 +13,7 @@ contract B {
return f();
}
function f() internal virtual returns(uint) { return 3; }
function f() internal view virtual returns(uint) { return 3; }
}
contract C is A, B {
@ -21,9 +21,9 @@ contract C is A, B {
return B.xInit();
}
function f() internal override(A, B) returns(uint) {
function f() internal view override(A, B) returns(uint) {
return x;
}
}
// ----
// TypeError 7733: (489-490): Immutable variables cannot be read before they are initialized.
// TypeError 7733: (499-500): Immutable variables cannot be read before they are initialized.

View File

@ -13,7 +13,7 @@ contract B {
return f();
}
function f() internal virtual returns(uint) { return 3; }
function f() internal view virtual returns(uint) { return 3; }
}
contract C is A, B {
@ -21,9 +21,9 @@ contract C is A, B {
return super.xInit();
}
function f() internal override(A, B) returns(uint) {
function f() internal view override(A, B) returns(uint) {
return x;
}
}
// ----
// TypeError 7733: (493-494): Immutable variables cannot be read before they are initialized.
// TypeError 7733: (503-504): Immutable variables cannot be read before they are initialized.

View File

@ -2,11 +2,11 @@ abstract contract A {
uint public t;
constructor() { t = f(); }
function f() virtual view internal returns (uint);
function f() virtual pure internal returns (uint);
}
contract B is A {
uint immutable x = 2;
function f() override view internal returns (uint) { return x; }
function f() override pure internal returns (uint) { return x; }
}
// ----
// TypeError 7733: (223-224): Immutable variables cannot be read before they are initialized.

View File

@ -1,5 +1,5 @@
contract C {
uint immutable x ;
uint immutable x;
constructor()
{
@ -13,4 +13,4 @@ contract C {
}
}
// ----
// TypeError 7733: (145-146): Immutable variables cannot be read before they are initialized.
// TypeError 7733: (141-142): Immutable variables cannot be read before they are initialized.

View File

@ -31,7 +31,6 @@ contract B
revert();
}
}
// ====
// EVMVersion: >=byzantium
// ----