-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5206451
commit 5d4520e
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
contract C { | ||
function max() public returns (uint8) { | ||
return type(int8).max; | ||
} | ||
} | ||
// ---- | ||
// TypeError 6359: (72-86): Return argument type int8 is not implicitly convertible to expected type (type of first return variable) uint8. |
8 changes: 8 additions & 0 deletions
8
test/libsolidity/syntaxTests/metaTypes/type_max_from_ternary_expression.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
contract C { | ||
function max(bool isUint) public returns (uint8) { | ||
return (isUint ? type(uint8) : type(int8)).max; | ||
} | ||
} | ||
// ---- | ||
// TypeError 9717: (93-104): Invalid mobile type in true expression. | ||
// TypeError 3703: (107-117): Invalid mobile type in false expression. |
11 changes: 11 additions & 0 deletions
11
test/libsolidity/syntaxTests/metaTypes/type_runtimecode.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
contract A { | ||
function f() public {} | ||
} | ||
|
||
contract C { | ||
function f() public returns (bytes memory) { | ||
return type(A).runtimeCode; | ||
} | ||
} | ||
// ---- | ||
// Warning 2018: (60-146): Function state mutability can be restricted to pure |
16 changes: 16 additions & 0 deletions
16
test/libsolidity/syntaxTests/metaTypes/type_runtimecode_from_ternary_expression_.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
contract A { | ||
function f() public {} | ||
} | ||
|
||
contract B { | ||
function g() public {} | ||
} | ||
|
||
contract C { | ||
function f(bool getA) public returns (bytes memory) { | ||
return (getA ? type(A) : type(B)).runtimeCode; | ||
} | ||
} | ||
// ---- | ||
// TypeError 9717: (180-187): Invalid mobile type in true expression. | ||
// TypeError 3703: (190-197): Invalid mobile type in false expression. |