diff --git a/test/libsolidity/semanticTests/underscore/as_function.sol b/test/libsolidity/semanticTests/underscore/as_function.sol new file mode 100644 index 000000000..fe18f3d90 --- /dev/null +++ b/test/libsolidity/semanticTests/underscore/as_function.sol @@ -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 diff --git a/test/libsolidity/semanticTests/underscore/in_function.sol b/test/libsolidity/semanticTests/underscore/in_function.sol new file mode 100644 index 000000000..9d116cb8b --- /dev/null +++ b/test/libsolidity/semanticTests/underscore/in_function.sol @@ -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 diff --git a/test/libsolidity/semanticTests/underscore/in_modifier.sol b/test/libsolidity/semanticTests/underscore/in_modifier.sol new file mode 100644 index 000000000..7f04c43b0 --- /dev/null +++ b/test/libsolidity/semanticTests/underscore/in_modifier.sol @@ -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" diff --git a/test/libsolidity/syntaxTests/underscore/as_function.sol b/test/libsolidity/syntaxTests/underscore/as_function.sol new file mode 100644 index 000000000..ef8e59f27 --- /dev/null +++ b/test/libsolidity/syntaxTests/underscore/as_function.sol @@ -0,0 +1,12 @@ +contract C { + function _() public pure { + } + + function g() public pure { + _(); + } + + function h() public pure { + _; + } +} diff --git a/test/libsolidity/syntaxTests/underscore/in_function.sol b/test/libsolidity/syntaxTests/underscore/in_function.sol new file mode 100644 index 000000000..cd1db69f2 --- /dev/null +++ b/test/libsolidity/syntaxTests/underscore/in_function.sol @@ -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. diff --git a/test/libsolidity/syntaxTests/underscore/in_modifier.sol b/test/libsolidity/syntaxTests/underscore/in_modifier.sol new file mode 100644 index 000000000..2724fc724 --- /dev/null +++ b/test/libsolidity/syntaxTests/underscore/in_modifier.sol @@ -0,0 +1,18 @@ +contract C { + modifier m() { + _; + } + + modifier n() { + string memory _ = ""; + _; + revert(_); + } + + function f() m() public { + } + + function g() n() public { + } +} +// ----