Merge pull request #12050 from ethereum/signedImmutablesBug

Fix signed immutables bug.
This commit is contained in:
chriseth
2021-09-29 11:46:58 +02:00
committed by GitHub
8 changed files with 96 additions and 17 deletions
@@ -0,0 +1,15 @@
contract C {
int8 immutable a = -2;
bytes2 immutable b = "ab";
function() internal returns (uint) immutable f = g;
function viaasm() view external returns (bytes32 x, bytes32 y) {
int8 _a = a;
bytes2 _b = b;
assembly { x := _a y := _b }
}
function g() internal pure returns (uint) { return 2; }
}
// ====
// compileViaYul: also
// ----
// viaasm() -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x6162000000000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,21 @@
contract A {
uint16 public immutable a;
uint16 public immutable b;
uint16 public immutable c;
uint16[3] public x;
constructor() {
c = 0xffff;
b = 0x0f0f;
a = 0x1234;
x = [a, b, c];
}
}
// ====
// compileViaYul: also
// ----
// a() -> 4660
// b() -> 0x0f0f
// c() -> 0xffff
// x(uint256): 0 -> 4660
// x(uint256): 1 -> 0x0f0f
// x(uint256): 2 -> 0xffff