You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because types can contain constants (uint256[MY_CONST + 1]), constant folding is run before typing, this causes issues:
We check that the arguments to built-ins are correctly typed after we have already folded them. This means we must manually check the arguments in the folding logic, see for example fix[lang]: fix pow_mod256 raising raw python exception #5180
user-defined types like structs are analyzed after constant folding (since they have members with types), this means they are not available during constant folding, making it for example impossible to constant-fold empty(MyStruct) (empty does not constant fold #5153)
Note that this inter-dependency is inherent in the semantics
The one way I see of addressing this is to proceed in steps:
Extract a dependency graph, which identifiers refer to which other identifiers, and make sure there are no loops
Type-check all symbols with no dependencies (aka leaves)
Constant-fold them
Type-check all symbols with only type-checked/folded dependencies
Consant-fold them
Go to step 4 until there are no more symbols (guaranteed to terminate by 1.)
Because types can contain constants (
uint256[MY_CONST + 1]), constant folding is run before typing, this causes issues:pow_mod256raising raw python exception #5180empty(MyStruct)(emptydoes not constant fold #5153)Note that this inter-dependency is inherent in the semantics
The one way I see of addressing this is to proceed in steps: