Add more syntax tests for uncovered cases

This commit is contained in:
Alex Beregszaszi 2020-11-04 23:18:44 +00:00
parent 5b4125447b
commit 1536e49b3d
17 changed files with 153 additions and 9 deletions

View File

@ -220,15 +220,15 @@ def examine_id_coverage(top_dir, source_id_to_file_names, new_ids_only=False):
return False return False
old_source_only_ids = { old_source_only_ids = {
"1123", "1218", "1220", "1584", "1823", "1950", "1123", "1220", "1584", "1823", "1950",
"1988", "2461", "2512", "2592", "2657", "2800", "2842", "2856", "1988", "2512", "2657", "2800",
"3046", "3263", "3356", "3441", "3682", "3876", "3046", "3263", "3356", "3682", "3876",
"3893", "3996", "4010", "4281", "4802", "3893", "3996", "4010", "4802",
"5052", "5073", "5170", "5188", "5272", "5347", "5473", "5073", "5188", "5272",
"5622", "6041", "6084", "6272", "7110", "7128", "7186", "5622", "6084", "6272", "7128", "7186",
"7589", "7593", "7653", "7812", "7885", "8065", "8084", "8140", "7589", "7593", "7653", "7885", "8065", "8084", "8140",
"8261", "8312", "8592", "8758", "9011", "8312", "8592", "9011",
"9085", "9390", "9440", "9547", "9551", "9615", "9980", "9085", "9390", "9551",
} }
new_source_only_ids = source_only_ids - old_source_only_ids new_source_only_ids = source_only_ids - old_source_only_ids

View File

@ -0,0 +1,10 @@
contract C {
function foo() pure internal {
address(10).staticcall{value: 7, gas: 3}("");
}
}
// ====
// EVMVersion: >=byzantium
// ----
// TypeError 2842: (56-96): Cannot set option "value" for staticcall.
// Warning 9302: (56-100): Return value of low-level calls not used.

View File

@ -0,0 +1,10 @@
contract C {
function f() public {
(bool success, ) = address(10).staticcall{gas: 3}("");
success;
}
}
// ====
// EVMVersion: <byzantium
// ----
// TypeError 5052: (66-100): "staticcall" is not supported by the VM version.

View File

@ -0,0 +1,5 @@
function fun() {}
contract C is fun {}
// ----
// TypeError 8758: (33-36): Contract expected.

View File

@ -0,0 +1,11 @@
function ff() {}
contract C {
function f() public pure {
assembly {
let x := ff
}
}
}
// ----
// DeclarationError 2025: (90-92): Access to functions is not allowed in inline assembly.

View File

@ -0,0 +1,10 @@
contract C {
function f() public pure {
uint mload;
assembly {
let x := mload
}
}
}
// ----
// ParserError 2314: (118-119): Expected '(' but got '}'

View File

@ -0,0 +1,10 @@
contract C {
function f() public pure {
uint mload;
assembly {
mload := 1
}
}
}
// ----
// ParserError 2314: (101-103): Expected '(' but got ':='

View File

@ -11,6 +11,11 @@ contract C {
ret := create2(0, 0, 0, 0) ret := create2(0, 0, 0, 0)
} }
} }
function h() view external returns (bytes32 ret) {
assembly {
ret := extcodehash(address())
}
}
} }
// ==== // ====
// EVMVersion: >=constantinople // EVMVersion: >=constantinople

View File

@ -11,6 +11,11 @@ contract C {
ret := create2(0, 0, 0, 0) ret := create2(0, 0, 0, 0)
} }
} }
function h() view external returns (bytes32 ret) {
assembly {
ret := extcodehash(address())
}
}
} }
// ==== // ====
// EVMVersion: =byzantium // EVMVersion: =byzantium
@ -23,3 +28,5 @@ contract C {
// DeclarationError 8678: (160-178): Variable count does not match number of values (1 vs. 0) // DeclarationError 8678: (160-178): Variable count does not match number of values (1 vs. 0)
// TypeError 6166: (283-290): The "create2" instruction is only available for Constantinople-compatible VMs (you are currently compiling for "byzantium"). // TypeError 6166: (283-290): The "create2" instruction is only available for Constantinople-compatible VMs (you are currently compiling for "byzantium").
// DeclarationError 8678: (276-302): Variable count does not match number of values (1 vs. 0) // DeclarationError 8678: (276-302): Variable count does not match number of values (1 vs. 0)
// TypeError 7110: (412-423): The "extcodehash" instruction is only available for Constantinople-compatible VMs (you are currently compiling for "byzantium").
// DeclarationError 8678: (405-434): Variable count does not match number of values (1 vs. 0)

View File

@ -0,0 +1,14 @@
contract C {
function f() public pure {
uint mload;
}
function g() public pure {
uint mload;
assembly {
}
}
}
// ----
// Warning 8261: (109-119): Variable is shadowed in inline assembly by an instruction of the same name
// Warning 2072: (52-62): Unused local variable.
// Warning 2072: (109-119): Unused local variable.

View File

@ -0,0 +1,13 @@
contract D {
}
contract C {
function f() public {
try new D() {
} catch (bytes memory x) {
x;
}
}
}
// ====
// EVMVersion: >=byzantium
// ----

View File

@ -0,0 +1,18 @@
contract C {
function f() public returns (uint, uint) {
try this {
} catch {
}
try gasleft() {
} catch {
}
try type(address) {
} catch {
}
}
}
// ----
// TypeError 5347: (72-76): Try can only be used with external function calls and contract creation calls.
// TypeError 2536: (119-128): Try can only be used with external function calls and contract creation calls.
// TypeError 4259: (176-183): Invalid type for argument in the function call. A contract type or an integer type is required, but type(address) provided.
// TypeError 2536: (171-184): Try can only be used with external function calls and contract creation calls.

View File

@ -0,0 +1,6 @@
{
function f() {}
let x := f
}
// ----
// TypeError 6041: (35-36): Function f used without being called.

View File

@ -0,0 +1,6 @@
{
// Test for the unreachable 6272_error
add := 1
}
// ----
// ParserError 2314: (47-49): Expected '(' but got ':='

View File

@ -0,0 +1,7 @@
{
// Test for the unreachable 6272_error
function f() -> a, b {}
add, mul := f()
}
// ----
// ParserError 2314: (71-72): Expected '(' but got ','

View File

@ -0,0 +1,5 @@
{
1()
}
// ----
// ParserError 9980: (7-8): Function name expected.

View File

@ -0,0 +1,7 @@
{
let x:bool := true:unhappy
}
// ----
// TypeError 5473: (20-32): "unhappy" is not a valid type (user defined types are not yet supported).
// TypeError 5170: (20-32): Invalid type "unhappy" for literal "true".
// TypeError 3947: (10-16): Assigning value of type "unhappy" to variable of type "bool".