Filing a set of futures relating to module init order / main modules #5076
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These tests threw me for a loop for awhile this evening (along the line
of "Why is my code not running?!?!"
The challenges relate to which modules are candidates for the main
module and which modules' init functions (top-level code) are run.
What we have today is rationalizable, but here I propose that some
warnings might help avoid confusion in cases like this.
I think what we have today is:
for main modules; if a module is not in this group, it is not
a candidate for the main module and its main() will not be run.
main(), it is the main module
by walking the tree of 'use's starting from the 'main' module
tree, its initialization (top-level code) will not be run.
As I say in the .future, I think this is rationalizable, but it can be confusing
in some cases. To that end, I propose putting a warning when modules
fall into bullet 4's case to avoid surprises.