mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Minor tweaks to immutable tests for better diffs
This commit is contained in:
parent
703fa6c8b5
commit
0afe025f19
@ -4,7 +4,7 @@ contract C {
|
|||||||
x = f();
|
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.
|
// TypeError 7733: (136-137): Immutable variables cannot be read before they are initialized.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
contract C {
|
contract C {
|
||||||
uint immutable x = f();
|
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.
|
// TypeError 7733: (99-100): Immutable variables cannot be read before they are initialized.
|
||||||
|
@ -7,7 +7,7 @@ abstract contract B {
|
|||||||
}
|
}
|
||||||
|
|
||||||
contract C is B(C.f) {
|
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.
|
||||||
|
@ -2,7 +2,7 @@ contract C {
|
|||||||
uint immutable x = 0;
|
uint immutable x = 0;
|
||||||
uint y = f();
|
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.
|
||||||
|
@ -5,15 +5,15 @@ contract B {
|
|||||||
x = xInit();
|
x = xInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function xInit() internal virtual returns(uint) {
|
function xInit() internal view virtual returns(uint) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract C is B {
|
contract C is B {
|
||||||
function xInit() internal override returns(uint) {
|
function xInit() internal view override returns(uint) {
|
||||||
return x;
|
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.
|
||||||
|
@ -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.
|
@ -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.
|
|
@ -13,7 +13,7 @@ contract B {
|
|||||||
return f();
|
return f();
|
||||||
}
|
}
|
||||||
|
|
||||||
function f() internal virtual returns(uint) { return 3; }
|
function f() internal view virtual returns(uint) { return 3; }
|
||||||
}
|
}
|
||||||
|
|
||||||
contract C is A, B {
|
contract C is A, B {
|
||||||
@ -21,9 +21,9 @@ contract C is A, B {
|
|||||||
return B.xInit();
|
return B.xInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function f() internal override(A, B) returns(uint) {
|
function f() internal view override(A, B) returns(uint) {
|
||||||
return x;
|
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.
|
||||||
|
@ -13,7 +13,7 @@ contract B {
|
|||||||
return f();
|
return f();
|
||||||
}
|
}
|
||||||
|
|
||||||
function f() internal virtual returns(uint) { return 3; }
|
function f() internal view virtual returns(uint) { return 3; }
|
||||||
}
|
}
|
||||||
|
|
||||||
contract C is A, B {
|
contract C is A, B {
|
||||||
@ -21,9 +21,9 @@ contract C is A, B {
|
|||||||
return super.xInit();
|
return super.xInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function f() internal override(A, B) returns(uint) {
|
function f() internal view override(A, B) returns(uint) {
|
||||||
return x;
|
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.
|
||||||
|
@ -2,11 +2,11 @@ abstract contract A {
|
|||||||
uint public t;
|
uint public t;
|
||||||
constructor() { t = f(); }
|
constructor() { t = f(); }
|
||||||
|
|
||||||
function f() virtual view internal returns (uint);
|
function f() virtual pure internal returns (uint);
|
||||||
}
|
}
|
||||||
contract B is A {
|
contract B is A {
|
||||||
uint immutable x = 2;
|
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.
|
// TypeError 7733: (223-224): Immutable variables cannot be read before they are initialized.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
contract C {
|
contract C {
|
||||||
uint immutable x ;
|
uint immutable x;
|
||||||
|
|
||||||
constructor()
|
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.
|
||||||
|
@ -31,7 +31,6 @@ contract B
|
|||||||
revert();
|
revert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====
|
// ====
|
||||||
// EVMVersion: >=byzantium
|
// EVMVersion: >=byzantium
|
||||||
// ----
|
// ----
|
||||||
|
Loading…
Reference in New Issue
Block a user