Move inline assembly tests from nameAndTypeResolution to inlineAssembly

This commit is contained in:
Alex Beregszaszi
2019-02-20 11:00:02 +00:00
parent c5577145d3
commit 687522a2f5
20 changed files with 0 additions and 0 deletions
@@ -0,0 +1,11 @@
contract C {
function f() view public {
assembly {
address
pop
}
}
}
// ----
// SyntaxError: (75-82): The use of non-functional instructions is disallowed. Please use functional notation instead.
// SyntaxError: (95-98): The use of non-functional instructions is disallowed. Please use functional notation instead.
@@ -0,0 +1,9 @@
contract C {
function f(bytes calldata bytesAsCalldata) external {
assembly {
let x := bytesAsCalldata
}
}
}
// ----
// TypeError: (111-126): Call data elements cannot be accessed directly. Copy to a local variable first or use "calldataload" or "calldatacopy" with manually determined offsets and sizes.
@@ -0,0 +1,10 @@
contract test {
uint constant x = 1;
function f() public {
assembly {
let y := x
}
}
}
// ----
// TypeError: (107-108): Constant variables not supported by inline assembly.
@@ -0,0 +1,10 @@
contract test {
uint constant x = 1;
function f() public {
assembly {
x := 2
}
}
}
// ----
// TypeError: (98-99): Constant variables not supported by inline assembly.
@@ -0,0 +1,10 @@
contract test {
uint constant x = 2;
function f() pure public {
assembly {
let r := x_offset
}
}
}
// ----
// TypeError: (112-120): Constant variables not supported by inline assembly.
@@ -0,0 +1,9 @@
contract C {
function f() pure public {
assembly {
jump(2)
}
}
}
// ----
// SyntaxError: (75-82): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
@@ -0,0 +1,10 @@
contract C {
function f() pure public {
assembly {
label:
}
}
}
// ----
// SyntaxError: (75-80): The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead.
// SyntaxError: (75-80): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
@@ -0,0 +1,10 @@
contract C {
function f() pure public {
assembly {
mload(0)
}
}
}
// ----
// SyntaxError: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
// DeclarationError: (61-93): Unbalanced stack at the end of a block: 1 surplus item(s).
@@ -0,0 +1,10 @@
contract C {
function f() pure public {
assembly {
1
}
}
}
// ----
// SyntaxError: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
// DeclarationError: (61-86): Unbalanced stack at the end of a block: 1 surplus item(s).
@@ -0,0 +1,10 @@
contract test {
function f() public {
uint a;
assembly {
function g() -> x { x := a }
}
}
}
// ----
// DeclarationError: (114-115): Cannot access local Solidity variables from inside an inline assembly function.
@@ -0,0 +1,11 @@
contract test {
uint[] r;
function f() public {
uint[] storage a = r;
assembly {
function g() -> x { x := a_offset }
}
}
}
// ----
// DeclarationError: (142-150): Cannot access local Solidity variables from inside an inline assembly function.
@@ -0,0 +1,10 @@
contract test {
uint x = 1;
function f() public {
assembly {
x := 2
}
}
}
// ----
// TypeError: (89-90): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.
@@ -0,0 +1,13 @@
contract test {
uint x = 1;
modifier m {
assembly {
x := 2
}
_;
}
function f() public m {
}
}
// ----
// TypeError: (80-81): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.
@@ -0,0 +1,8 @@
contract test {
uint a;
function f() pure public {
assembly {
function g() -> x { x := a_slot }
}
}
}
@@ -0,0 +1,10 @@
contract test {
function f() public {
assembly {
pop
}
}
}
// ----
// SyntaxError: (73-76): The use of non-functional instructions is disallowed. Please use functional notation instead.
// DeclarationError: (59-86): Unbalanced stack at the end of a block: 1 missing item(s).
@@ -0,0 +1,10 @@
contract test {
function f() public {
assembly {
1
}
}
}
// ----
// SyntaxError: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
// DeclarationError: (59-84): Unbalanced stack at the end of a block: 1 surplus item(s).
@@ -0,0 +1,8 @@
contract c {
uint8 x;
function f() public {
assembly { pop(x) }
}
}
// ----
// TypeError: (75-76): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.