Constants at file-level.

This commit is contained in:
chriseth
2020-10-08 18:56:17 +02:00
parent 21dee1c8ba
commit 346fe1c6c5
11 changed files with 104 additions and 25 deletions
@@ -0,0 +1,32 @@
bytes constant a = "\x03\x01\x02";
bytes constant b = hex"030102";
string constant c = "hello";
uint256 constant x = 56;
enum ActionChoices {GoLeft, GoRight, GoStraight, Sit}
ActionChoices constant choices = ActionChoices.GoLeft;
bytes32 constant st = "abc\x00\xff__";
contract C {
function f() public returns (bytes memory) {
return a;
}
function g() public returns (bytes memory) {
return b;
}
function h() public returns (bytes memory) {
return bytes(c);
}
function i() public returns (uint, ActionChoices, bytes32) {
return (x, choices, st);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x20, 3, "\x03\x01\x02"
// g() -> 0x20, 3, "\x03\x01\x02"
// h() -> 0x20, 5, "hello"