Add more comprehensive tests for embedded inline assembly LValue/RValue access

This commit is contained in:
Alex Beregszaszi 2018-07-24 00:36:39 +01:00
parent 167fe7c370
commit d647761058
7 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,9 @@
contract C {
function f() public pure {
assembly {
let x := C
}
}
}
// ----
// TypeError: (72-73): Expected a library.

View File

@ -0,0 +1,7 @@
contract C {
function f() public pure {
assembly {
let x := f
}
}
}

View File

@ -0,0 +1,10 @@
library L {
}
contract C {
function f() public pure {
assembly {
let x := L
}
}
}

View File

@ -0,0 +1,9 @@
contract C {
function f() public pure {
assembly {
let x := super
}
}
}
// ----
// DeclarationError: (72-77): Identifier not found.

View File

@ -0,0 +1,13 @@
contract C {
function f() public {
assembly {
super := 1
f := 1
C := 1
}
}
}
// ----
// TypeError: (58-63): Only local variables can be assigned to in inline assembly.
// TypeError: (75-76): Only local variables can be assigned to in inline assembly.
// TypeError: (88-89): Only local variables can be assigned to in inline assembly.

View File

@ -0,0 +1,13 @@
contract C {
uint[] x;
function() external {
uint[] storage y = x;
assembly {
y_slot := 1
y_offset := 2
}
}
}
// ----
// TypeError: (115-121): Storage variables cannot be assigned to.
// TypeError: (139-147): Storage variables cannot be assigned to.

View File

@ -0,0 +1,13 @@
contract C {
uint[] x;
function() external {
uint[] memory y = x;
assembly {
pop(y_slot)
pop(y_offset)
}
}
}
// ----
// TypeError: (118-124): The suffixes _offset and _slot can only be used on storage variables.
// TypeError: (142-150): The suffixes _offset and _slot can only be used on storage variables.