From d41ffd1dcfd1a4c41065c5e163ba52c52d5e9754 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Mon, 11 Feb 2019 11:23:20 +0100 Subject: [PATCH 1/2] Rename & move tests to get rid of old number prefix in name --- .../tuple.sol} | 0 .../creating_memory_array.sol} | 0 .../creating_struct.sol} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename test/libsolidity/syntaxTests/nameAndTypeResolution/{249_tuple_compound_assignment.sol => compoundAssignment/tuple.sol} (100%) rename test/libsolidity/syntaxTests/nameAndTypeResolution/{266_invalid_args_creating_memory_array.sol => invalidArgs/creating_memory_array.sol} (100%) rename test/libsolidity/syntaxTests/nameAndTypeResolution/{267_invalid_args_creating_struct.sol => invalidArgs/creating_struct.sol} (100%) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/249_tuple_compound_assignment.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/tuple.sol similarity index 100% rename from test/libsolidity/syntaxTests/nameAndTypeResolution/249_tuple_compound_assignment.sol rename to test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/tuple.sol diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/266_invalid_args_creating_memory_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/creating_memory_array.sol similarity index 100% rename from test/libsolidity/syntaxTests/nameAndTypeResolution/266_invalid_args_creating_memory_array.sol rename to test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/creating_memory_array.sol diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/267_invalid_args_creating_struct.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/creating_struct.sol similarity index 100% rename from test/libsolidity/syntaxTests/nameAndTypeResolution/267_invalid_args_creating_struct.sol rename to test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/creating_struct.sol From feae01f0424e8b04ce6748cb0de0f46e20b0c13a Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Mon, 11 Feb 2019 11:23:56 +0100 Subject: [PATCH 2/2] Add tests to increase coverage of TypeChecker --- .../compoundAssignment/incomp_types.sol | 7 +++++++ .../tuple_invalid_inline_array_type.sol | 8 ++++++++ .../invalidArgs/creating_struct_members_skipped.sol | 9 +++++++++ .../invalidArgs/explicit_conversions.sol | 9 +++++++++ 4 files changed, 33 insertions(+) create mode 100644 test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/incomp_types.sol create mode 100644 test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/tuple_invalid_inline_array_type.sol create mode 100644 test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/creating_struct_members_skipped.sol create mode 100644 test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/explicit_conversions.sol diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/incomp_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/incomp_types.sol new file mode 100644 index 000000000..7f2139bf7 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/incomp_types.sol @@ -0,0 +1,7 @@ +contract C { + function f() public returns (uint a, uint b) { + a += (1, 1); + } +} +// ---- +// TypeError: (72-83): Operator += not compatible with types uint256 and tuple(int_const 1,int_const 1) diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/tuple_invalid_inline_array_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/tuple_invalid_inline_array_type.sol new file mode 100644 index 000000000..17892ec05 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/tuple_invalid_inline_array_type.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public { + uint x; + (x, ) = ([100e100]); + } +} +// ---- +// TypeError: (78-85): Invalid mobile type. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/creating_struct_members_skipped.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/creating_struct_members_skipped.sol new file mode 100644 index 000000000..1e954ab6c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/creating_struct_members_skipped.sol @@ -0,0 +1,9 @@ +contract C { + struct S { uint a; uint b; mapping(uint=>uint) c; } + + function f() public { + S memory s = S({a: 1}); + } +} +// ---- +// TypeError: (117-126): Wrong argument count for struct constructor: 1 arguments given but expected 2. Members that have to be skipped in memory: c diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/explicit_conversions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/explicit_conversions.sol new file mode 100644 index 000000000..c81b60351 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/invalidArgs/explicit_conversions.sol @@ -0,0 +1,9 @@ +contract test { + function f() public { + uint(1, 1); + uint({arg:1}); + } +} +// ---- +// TypeError: (50-60): Exactly one argument expected for explicit type conversion. +// TypeError: (70-83): Type conversion cannot allow named arguments.