Fix shadowing struct types by struct member names

This commit is contained in:
a3d4
2021-06-09 12:37:11 +02:00
committed by chriseth
parent 70b8b1c834
commit f59145f21f
11 changed files with 133 additions and 15 deletions
@@ -0,0 +1,26 @@
pragma abicoder v2;
contract C {
enum EnumType {A, B, C}
struct StructType {
uint x;
}
error E1(StructType StructType);
error E2(EnumType StructType, StructType EnumType);
function f() public {
revert E1({StructType: StructType(42)});
}
function g() public {
revert E2({EnumType: StructType(42), StructType: EnumType.B});
}
}
// ====
// compileToEwasm: also
// compileViaYul: also
// ----
// f() -> FAILURE, hex"33a54193", hex"000000000000000000000000000000000000000000000000000000000000002a"
// g() -> FAILURE, hex"374b9387", hex"0000000000000000000000000000000000000000000000000000000000000001", hex"000000000000000000000000000000000000000000000000000000000000002a"
@@ -0,0 +1,12 @@
contract C {
struct S {
uint x;
}
enum E {E, S, C, a, f}
uint a;
function f() public pure {}
}
// ----
@@ -0,0 +1,5 @@
contract C {
error E(int bytes, bytes x);
}
// ----
// ParserError 2314: (29-34): Expected ',' but got 'bytes'
@@ -0,0 +1,12 @@
contract C {
enum EnumType {A, B, C}
struct StructType {
uint x;
}
error E1(StructType StructType);
error E2(EnumType EnumType);
error E3(EnumType StructType, StructType EnumType);
}
// ----
@@ -0,0 +1,13 @@
contract C {
enum EnumType {A, B, C}
struct StructType {
uint x;
}
event E1(StructType StructType);
event E2(EnumType EnumType);
event E3(EnumType StructType, StructType EnumType);
event E4(StructType indexed StructType) anonymous;
}
// ----
@@ -3,4 +3,4 @@ contract C {
function f(function(S memory) external) public {}
}
// ----
// TypeError 5172: (25-26): Name has to refer to a struct, enum or contract.
// DeclarationError 7920: (25-26): Identifier not found or not unique.
@@ -0,0 +1,6 @@
contract C {
enum E {a, b, c}
struct S {E X; uint E;}
struct T {E T; uint E;}
struct U {E E;}
}