forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding event and error selector fields on the lines of the function s…
…elector fields
- Loading branch information
1 parent
2cb29db
commit d4c06d2
Showing
13 changed files
with
273 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
library L { | ||
error E(); | ||
} | ||
library S { | ||
error E(uint); | ||
} | ||
library T { | ||
error E(); | ||
} | ||
|
||
error E(); | ||
|
||
interface I { | ||
error E(); | ||
function f() external pure; | ||
} | ||
|
||
contract D { | ||
error F(); | ||
} | ||
|
||
contract C is D { | ||
function test1() public pure returns (bytes4, bytes4, bytes4, bytes4) { | ||
assert(L.E.selector == T.E.selector); | ||
assert(L.E.selector != S.E.selector); | ||
assert(E.selector == L.E.selector); | ||
assert(I.E.selector == L.E.selector); | ||
return (L.E.selector, S.E.selector, E.selector, I.E.selector); | ||
} | ||
|
||
bytes4 s1 = L.E.selector; | ||
bytes4 s2 = S.E.selector; | ||
bytes4 s3 = T.E.selector; | ||
bytes4 s4 = I.E.selector; | ||
function test2() external returns (bytes4, bytes4, bytes4, bytes4) { | ||
return (s1, s2, s3, s4); | ||
} | ||
|
||
function test3() external returns (bytes4) { | ||
return (F.selector); | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// test1() -> 0x92bbf6e800000000000000000000000000000000000000000000000000000000, 0x2ff06700000000000000000000000000000000000000000000000000000000, 0x92bbf6e800000000000000000000000000000000000000000000000000000000, 0x92bbf6e800000000000000000000000000000000000000000000000000000000 | ||
// test2() -> 0x92bbf6e800000000000000000000000000000000000000000000000000000000, 0x2ff06700000000000000000000000000000000000000000000000000000000, 0x92bbf6e800000000000000000000000000000000000000000000000000000000, 0x92bbf6e800000000000000000000000000000000000000000000000000000000 | ||
// test3() -> 0x28811f5900000000000000000000000000000000000000000000000000000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
library L { | ||
event E(); | ||
} | ||
library S { | ||
event E(uint); | ||
} | ||
library T { | ||
event E(); | ||
} | ||
interface I { | ||
event E(); | ||
} | ||
|
||
contract D { | ||
event F(); | ||
} | ||
|
||
contract C is D { | ||
function test1() external pure returns (bytes32, bytes32, bytes32) { | ||
assert(L.E.selector == T.E.selector); | ||
assert(I.E.selector == L.E.selector); | ||
|
||
assert(L.E.selector != S.E.selector); | ||
assert(T.E.selector != S.E.selector); | ||
assert(I.E.selector != S.E.selector); | ||
|
||
return (L.E.selector, S.E.selector, I.E.selector); | ||
} | ||
|
||
bytes32 s1 = L.E.selector; | ||
bytes32 s2 = S.E.selector; | ||
bytes32 s3 = T.E.selector; | ||
bytes32 s4 = I.E.selector; | ||
function test2() external returns (bytes32, bytes32, bytes32, bytes32) { | ||
return (s1, s2, s3, s4); | ||
} | ||
|
||
function test3() external returns (bytes32) { | ||
return (F.selector); | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// test1() -> 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028, 0x2ff0672f372fbe844b353429d4510ea5e43683af134c54f75f789ff57bc0c0, 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028 | ||
// test2() -> 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028, 0x2ff0672f372fbe844b353429d4510ea5e43683af134c54f75f789ff57bc0c0, 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028, 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028 | ||
// test3() -> 0x28811f5935c16a099486acb976b3a6b4942950a1425a74e9eb3e9b7f7135e12a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
contract C { | ||
event E(); | ||
} | ||
|
||
contract Test { | ||
event E(uint256, uint256); | ||
function f() public { | ||
emit C.E(); | ||
emit E(1,2); | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// f() -> | ||
// ~ emit E() | ||
// ~ emit E(uint256,uint256): 0x01, 0x02 |
48 changes: 48 additions & 0 deletions
48
test/libsolidity/syntaxTests/errors/error_selector_syntax.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
library L { | ||
error E(); | ||
} | ||
library S { | ||
error E(uint); | ||
} | ||
library T { | ||
error E(); | ||
} | ||
|
||
error E(); | ||
|
||
interface I { | ||
error E(); | ||
function f() external pure; | ||
} | ||
|
||
contract D { | ||
error F(); | ||
} | ||
|
||
contract C is D { | ||
function test1() public pure returns (bytes4, bytes4, bytes4, bytes4) { | ||
assert(L.E.selector == T.E.selector); | ||
assert(L.E.selector != S.E.selector); | ||
assert(E.selector == L.E.selector); | ||
assert(I.E.selector == L.E.selector); | ||
return (L.E.selector, S.E.selector, E.selector, I.E.selector); | ||
} | ||
|
||
bytes4 s1 = L.E.selector; | ||
bytes4 s2 = S.E.selector; | ||
bytes4 s3 = T.E.selector; | ||
bytes4 s4 = I.E.selector; | ||
|
||
function test2() view external returns (bytes4, bytes4, bytes4, bytes4) { | ||
return (s1, s2, s3, s4); | ||
} | ||
|
||
function test3() pure external returns (bytes4) { | ||
return (F.selector); | ||
} | ||
} | ||
// ---- | ||
// Warning 2519: (16-26): This declaration shadows an existing declaration. | ||
// Warning 2519: (45-59): This declaration shadows an existing declaration. | ||
// Warning 2519: (78-88): This declaration shadows an existing declaration. | ||
// Warning 2519: (122-132): This declaration shadows an existing declaration. |
12 changes: 12 additions & 0 deletions
12
test/libsolidity/syntaxTests/events/event_selector_library_called_inside_function.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
library Y { | ||
event E() anonymous; | ||
} | ||
|
||
contract D { | ||
function test1() external pure returns (bytes32) { | ||
return Y.E.selector; | ||
} | ||
|
||
} | ||
// ---- | ||
// TypeError 9582: (123-135): Member "selector" not found or not visible after argument-dependent lookup in function (). |
13 changes: 13 additions & 0 deletions
13
...syntaxTests/events/event_selector_library_declared_outside_but_called_inside_function.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
library Y { | ||
event E() anonymous; | ||
} | ||
|
||
contract C { | ||
bytes32 s5 = Y.E.selector; | ||
|
||
function test2() view external returns (bytes32) { | ||
return s5; | ||
} | ||
} | ||
// ---- | ||
// TypeError 9582: (70-82): Member "selector" not found or not visible after argument-dependent lookup in function (). |
43 changes: 43 additions & 0 deletions
43
test/libsolidity/syntaxTests/events/event_selector_syntax.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
library L { | ||
event E(); | ||
} | ||
library S { | ||
event E(uint); | ||
} | ||
library T { | ||
event E(); | ||
} | ||
interface I { | ||
event E(); | ||
} | ||
|
||
contract D { | ||
event F(); | ||
} | ||
|
||
contract C is D { | ||
function test1() external pure returns (bytes32, bytes32, bytes32) { | ||
assert(L.E.selector == T.E.selector); | ||
assert(I.E.selector == L.E.selector); | ||
|
||
assert(L.E.selector != S.E.selector); | ||
assert(T.E.selector != S.E.selector); | ||
assert(I.E.selector != S.E.selector); | ||
|
||
return (L.E.selector, S.E.selector, I.E.selector); | ||
} | ||
|
||
bytes32 s1 = L.E.selector; | ||
bytes32 s2 = S.E.selector; | ||
bytes32 s3 = T.E.selector; | ||
bytes32 s4 = I.E.selector; | ||
|
||
function test2() view external returns (bytes32, bytes32, bytes32, bytes32) { | ||
return (s1, s2, s3, s4); | ||
} | ||
|
||
function test3() pure external returns (bytes32) { | ||
return (F.selector); | ||
} | ||
} | ||
// ---- |