-
Notifications
You must be signed in to change notification settings - Fork 55
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
Showing
11 changed files
with
429 additions
and
4 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
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,20 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
contract Assign { | ||
|
||
function doAssignment() public { | ||
// Multi-value LHS (tuple) | ||
(uint x, uint y) = (uint16(1), 2); | ||
|
||
// Single value RHS | ||
uint z = 3; | ||
|
||
(x, y) = (z, z); | ||
|
||
// uint[2] memory a = [uint(1), uint(2)]; | ||
// uint[2] memory b = [uint(3), uint(4)]; | ||
|
||
|
||
// (a, b) = (b, a); | ||
} | ||
} |
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,10 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
contract BinOp { | ||
|
||
function testBinOp(int y) public { | ||
int x = 1; | ||
int z = 5 + x; | ||
int a = x * y; | ||
} | ||
} |
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,10 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
contract Cmp { | ||
|
||
function testCmp(int x) public { | ||
uint a = 5; | ||
bool b = (5 < 6) || (5 == 6 && 0 < 1); // Correct the tuple comparison | ||
|
||
} | ||
} |
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,53 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
contract CondOp { | ||
|
||
function if_both_possible(uint x) public returns (uint) { | ||
if (x > 100) { | ||
return 1; | ||
} else { | ||
return 2; | ||
} | ||
} | ||
|
||
function if_first_possible() public returns (uint) { | ||
uint x = 101; | ||
if (x > 100) { | ||
return 1; | ||
} else { | ||
return 2; | ||
} | ||
} | ||
|
||
function if_second_possible() public returns (uint) { | ||
uint x = 99; | ||
if (x > 100) { | ||
return 1; | ||
} else { | ||
return 2; | ||
} | ||
} | ||
|
||
function if_neither_possible(uint x) public returns (uint) { | ||
if (x > 100) { | ||
require(x < 100); // not possible | ||
return 1; | ||
} else { | ||
require(x > 100); // not possible | ||
return 2; | ||
} | ||
return 0; | ||
} | ||
|
||
|
||
function ternaryParam(uint x) public returns (uint) { | ||
uint y = x > 2 ? 1 : 2; | ||
return y; | ||
} | ||
|
||
function ternaryLiteral() public returns (uint) { | ||
uint y = 1 > 2 ? 1 : 2; | ||
"pyro::variable::y::range::[2,2]"; | ||
return y; | ||
} | ||
} |
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
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
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
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,39 @@ | ||
contract Literals { | ||
|
||
function foo() public returns (string memory) { | ||
uint a = 115792089237316195423570985008687907853269984665640564039457584007913129639935; // ok | ||
// uint b = 115792089237316195423570985008687907853269984665640564039457584007913129639936; // too big | ||
// uint c = 115792089237316195423570985008687907853269984665640564039457584007913129639935 ** 2; // too big | ||
int d = -57896044618658097711785492504343953926634992332820282019728792003956564819968; // ok | ||
// int e = -57896044618658097711785492504343953926634992332820282019728792003956564819969; // too big | ||
uint f = 1.0 ** 2; // ok | ||
// uint g = 1.5 ** 2; // not uint | ||
uint h = 1.5 ** 0; // ok | ||
"pyro::variable::h::range::[1,1]"; | ||
uint256 i = 123 ** 10; // 792594609605189126649 | ||
address w = address(0xdCad3a6d3569DF655070DEd06cb7A1b2Ccd1D3AF); | ||
w = 0xdCad3a6d3569D_F655070DEd06cb7A_1b2Ccd1D3AF; | ||
|
||
uint j = 0.000000002e18; | ||
j = 25; | ||
j = 1.5e0 ether; | ||
"pyro::variable::j::range::[1500000000000000000,1500000000000000000]"; | ||
int k = -0; | ||
k = 25.5e5; | ||
k = -23.5e5 ether; | ||
"pyro::variable::k::range::[-2350000000000000000000000,-2350000000000000000000000]"; | ||
|
||
k = -23.5e5 seconds; | ||
k = -23.5e5 minutes; | ||
k = -23.5e5 hours; | ||
k = -23.5e5 days; | ||
k = -23.5e5 weeks; | ||
k = -0x54; | ||
"pyro::variable::k::range::[-84,-84]"; | ||
string memory s = unicode"🔥🔫"; // TODO unicode string values is not correct yet | ||
|
||
bytes memory r = hex"11111111111111111111111111111111111111111111111111111111111111111111111111111111"; | ||
r = hex"1111111111111111111111111111111111111111" hex"111111111111111111111111111111111111111111111111"; | ||
return s; | ||
} | ||
} |
Oops, something went wrong.