-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Open
Labels
bug 🐛language design
Any changes to the language, e.g. new featuresAny changes to the language, e.g. new featureslow effortThere is not much implementation work to be done. The task is very easy or tiny.There is not much implementation work to be done. The task is very easy or tiny.medium difficultymedium impactDefault level of impactDefault level of impactmust haveSomething we consider an essential part of Solidity 1.0.Something we consider an essential part of Solidity 1.0.
Description
Description
Function selectors can be used to initialize constants while error and event selectors (recently introduced in #12921) are rejected as non-constant. I think that all of them should work the same way in that regard.
Steps to Reproduce
contract C {
event Ev();
error Er();
function f() external {}
bytes4 constant functionSelector = this.f.selector; // OK
bytes4 constant errorSelector = Er.selector; // Error: Initial value for constant variable has to be compile-time constant.
bytes32 constant eventSelector = Ev.selector; // Error: Initial value for constant variable has to be compile-time constant.
}Error: Initial value for constant variable has to be compile-time constant.
--> test.sol:7:37:
|
7 | bytes4 constant errorSelector = Er.selector; // Error: Initial value for constant variable has to be compile-time constant.
| ^^^^^^^^^^^
Error: Initial value for constant variable has to be compile-time constant.
--> test.sol:8:38:
|
8 | bytes32 constant eventSelector = Ev.selector; // Error: Initial value for constant variable has to be compile-time constant.
| ^^^^^^^^^^^
The test passes without errors if you remove constant from the state variables.
Environment
- Compiler version: 0.8.15 (
develop)
Metadata
Metadata
Assignees
Labels
bug 🐛language design
Any changes to the language, e.g. new featuresAny changes to the language, e.g. new featureslow effortThere is not much implementation work to be done. The task is very easy or tiny.There is not much implementation work to be done. The task is very easy or tiny.medium difficultymedium impactDefault level of impactDefault level of impactmust haveSomething we consider an essential part of Solidity 1.0.Something we consider an essential part of Solidity 1.0.
Type
Projects
Status
Consider to Promote