Changelog and tests

This commit is contained in:
Harikrishnan Mulackal 2020-05-11 14:13:51 +05:30
parent e54c4eecfc
commit e4e200f29f
8 changed files with 62 additions and 1 deletions

View File

@ -1,7 +1,7 @@
### 0.6.8 (unreleased)
Language Features:
* Implemented ``type(X).min`` and ``type(X).max`` for every integer type ``X`` that returns the smallest and largest value representable by the type.
Compiler Features:

View File

@ -8,5 +8,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// test() -> 0

View File

@ -19,6 +19,8 @@ contract C {
y[0] = 23;
return x[2];
}}
// ====
// compileViaYul: also
// ----
// f() -> FAILURE
// g() -> FAILURE

View File

@ -0,0 +1,7 @@
contract Min {
function contractMin() public {
type(Min).min;
}
}
// ----
// TypeError: (50-63): Member "min" not found or not visible after argument-dependent lookup in type(contract Min).

View File

@ -0,0 +1,7 @@
contract test {
function intName() public {
type(int).name;
}
}
// ----
// TypeError: (47-61): Member "name" not found or not visible after argument-dependent lookup in type(int256).

View File

@ -0,0 +1,12 @@
contract Test {
function basic() public pure {
uint uintMax = type(uint).max;
uintMax;
int intMax = type(int).max;
intMax;
uint uintMin = type(uint).min;
uintMin;
int intMin = type(int).min;
intMin;
}
}

View File

@ -0,0 +1,15 @@
contract Test {
function assignment() public {
uint8 uint8Min = type(int).min;
uint uintMin = type(int).min;
if (type(int).min == 2**256 - 1) {
uintMin;
}
}
}
// ----
// TypeError: (59-89): Type int256 is not implicitly convertible to expected type uint8.
// TypeError: (99-127): Type int256 is not implicitly convertible to expected type uint256.
// TypeError: (142-169): Operator == not compatible with types int256 and int_const 1157...(70 digits omitted)...9935

View File

@ -0,0 +1,16 @@
contract test {
function viewAssignment() public view {
int min = type(int).min;
min;
}
function assignment() public {
int max = type(int).max;
max;
}
}
// ----
// Warning: (21-112): Function state mutability can be restricted to pure
// Warning: (118-200): Function state mutability can be restricted to pure