Add syntax and semantic tests for underscore

This commit is contained in:
Alex Beregszaszi 2020-11-03 14:49:28 +00:00
parent 7f1f192f8d
commit b0864a4af9
6 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,20 @@
contract C {
function _() public pure returns (uint) {
return 88;
}
function g() public pure returns (uint){
return _();
}
function h() public pure returns (uint) {
_;
return 33;
}
}
// ====
// compileViaYul: also
// ----
// _() -> 88
// g() -> 88
// h() -> 33

View File

@ -0,0 +1,16 @@
contract C {
function f() public pure returns (uint) {
uint _;
return _;
}
function g() public pure returns (uint) {
uint _ = 1;
return _;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0
// g() -> 1

View File

@ -0,0 +1,23 @@
contract C {
modifier m() {
_;
}
modifier n() {
string memory _ = "failed";
_;
revert(_);
}
function f() m() public returns (uint) {
return 88;
}
function g() n() public returns (uint) {
}
}
// ====
// EVMVersion: >=byzantium
// ----
// f() -> 88
// g() -> FAILURE, hex"08c379a0", 0x20, 6, "failed"

View File

@ -0,0 +1,12 @@
contract C {
function _() public pure {
}
function g() public pure {
_();
}
function h() public pure {
_;
}
}

View File

@ -0,0 +1,17 @@
contract C {
function f() public pure returns (uint) {
uint _;
return _;
}
function g() public pure returns (uint) {
uint _ = 1;
return _;
}
function h() public pure {
_;
}
}
// ----
// DeclarationError 7576: (230-231): Undeclared identifier.

View File

@ -0,0 +1,18 @@
contract C {
modifier m() {
_;
}
modifier n() {
string memory _ = "";
_;
revert(_);
}
function f() m() public {
}
function g() n() public {
}
}
// ----