Support constant numbers in inline assembly.

This commit is contained in:
chriseth
2019-07-02 14:01:05 +02:00
parent b8dbf7d2a8
commit cdd137e3d1
11 changed files with 122 additions and 10 deletions
@@ -0,0 +1,13 @@
contract C {
uint constant x = 2**20;
bool constant b = true;
bytes4 constant s = "ab";
function f() public pure {
assembly {
let c1 := x
let c2 := b
let c3 := s
}
}
}
// ----
@@ -0,0 +1,10 @@
contract C {
string constant x = "abc";
function f() public pure {
assembly {
let a := x
}
}
}
// ----
// TypeError: (115-116): Only direct number constants are supported by inline assembly.
@@ -0,0 +1,9 @@
contract C {
uint constant x = 2**20;
function f() public pure {
assembly {
let a := x
}
}
}
// ----
@@ -0,0 +1,11 @@
contract C {
uint constant a = 2;
uint constant b = a;
function f() public pure {
assembly {
let x := b
}
}
}
// ----
// TypeError: (134-135): Only direct number constants are supported by inline assembly.
@@ -1,10 +1,9 @@
contract test {
uint constant x = 1;
function f() public {
function f() public pure {
assembly {
let y := x
}
}
}
// ----
// TypeError: (107-108): Constant variables not supported by inline assembly.
@@ -7,4 +7,4 @@ contract test {
}
}
// ----
// TypeError: (98-99): Constant variables not supported by inline assembly.
// TypeError: (98-99): Constant variables cannot be assigned to.
@@ -7,4 +7,4 @@ contract test {
}
}
// ----
// TypeError: (112-120): Constant variables not supported by inline assembly.
// TypeError: (112-120): The suffixes _offset and _slot can only be used on non-constant storage variables.