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.
Summary:
This bug came up because of an old change that we made in generate.ml
It removed the return statement from the footer of the main body, however there are some cases where it is needed.
Specifically when the last line of a module is some kind of loop.
Here's what we would need to do to add it back.
However, we can't just add it back right now, because our JS modules and Hack modules are structured differently in separate compilation mode.
In Hack, that would result in two return statements.
In JS, that would result in a return statement outside of a function body.
That return statement could end up being in a loop, or floating in the outermost part of the module.
We should probably create a new Rehp node called "ExitModule".
However, it's not clear when to turn that into a return vs. something else (and
what would we even use for JS module bodies)?
One possibility for module bodies in JS:
Because it would work if you are in a loop, or not. For PHP we are always in a
function so we can use Return, but need to work out the problem where we end up
with multiple returns. For PHP we could turn the return into the return of the
module exports.
CC: