ballerina-spec icon indicating copy to clipboard operation
ballerina-spec copied to clipboard

Evaluation order of module-level initializers

Open jclark opened this issue 5 years ago • 3 comments

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.

jclark avatar Mar 26 '19 09:03 jclark

Relates to #101

sameerajayasoma avatar May 09 '19 01:05 sameerajayasoma

See this use case: https://github.com/ballerina-platform/ballerina-lang/issues/30042

jclark avatar Apr 18 '21 04:04 jclark

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.

jclark avatar Apr 18 '23 02:04 jclark