ballerina-spec
ballerina-spec copied to clipboard
Evaluation order of module-level initializers
Spec should define the order in which module-level initializer expressions are evaluated. This makes a difference since they may have side-effects. The goal should be to move things around as little as necessary to ensure that the variables that an initializer depends on are initialized before the initializer is evaluated.
Relates to #101
See this use case: https://github.com/ballerina-platform/ballerina-lang/issues/30042
Evaluation order must satisfy the constraint that variables (or more module-level identifiers) cannot be referenced before they are initialized. If there's no possible ordering satisfying the constraint, then there's a cycle and that's a compile-time error.