Compile-time evaluation of constants of member constants #16055
Labels
low effort
There is not much implementation work to be done. The task is very easy or tiny.
low impact
Changes are not very noticeable or potential benefits are limited.
must have eventually
Something we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.
Abstract
In contexts where a compile-time constant expression is expected, we currently allow constants initialized with literal expressions, but only when the constant is referenced via a standalone identifier (e.g.
X
). It does not work when it's via a member access expression (e.g.C.X
). Both should work.Motivation
This limitation is unintuitive and the error message does not make it clear what the problem is.
The problem is also likely to become more common once we allow using constants in layout specifiers (#15944).
Specification
In contexts where we use
ConstantEvaluator
to evaluate expressions at compilation time (array sizes or layout specifiers, etc), it should be possible to reference constants even if they are accessed via member access on contracts, modules or any other objects.It should also be possible to use member access expressions inside constant initializers (e.g.
uint constant X = m.Y
).Backwards Compatibility
Full compatibility. It will affect only situations that currently produce an error.
The text was updated successfully, but these errors were encountered: