From 42efadb6a15f82094fee6057393aada6aee4b04c Mon Sep 17 00:00:00 2001 From: nishant-sachdeva Date: Wed, 22 Jun 2022 21:29:39 +0530 Subject: [PATCH] event and error selectors are now allowed to compile time constants --- .../syntaxTests/errors/error_selector_as_constant.sol | 7 +++++++ .../syntaxTests/events/event_selector_as_constant.sol | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 test/libsolidity/syntaxTests/errors/error_selector_as_constant.sol create mode 100644 test/libsolidity/syntaxTests/events/event_selector_as_constant.sol diff --git a/test/libsolidity/syntaxTests/errors/error_selector_as_constant.sol b/test/libsolidity/syntaxTests/errors/error_selector_as_constant.sol new file mode 100644 index 000000000..c7c7735c5 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_selector_as_constant.sol @@ -0,0 +1,7 @@ +contract C { + error Er(); + function f() external {} + bytes4 constant errorSelector = Er.selector; +} +// ---- +// TypeError 8349: (95-106): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/events/event_selector_as_constant.sol b/test/libsolidity/syntaxTests/events/event_selector_as_constant.sol new file mode 100644 index 000000000..6d16ac897 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_selector_as_constant.sol @@ -0,0 +1,8 @@ +contract C { + event Ev(); + function f() external {} + + bytes32 constant eventSelector = Ev.selector; +} +// ---- +// TypeError 8349: (96-107): Initial value for constant variable has to be compile-time constant.