[lua] Replace IIFE discard with local _ assignment#12741
Open
jdonaldson wants to merge 1 commit intoHaxeFoundation:developmentfrom
Open
[lua] Replace IIFE discard with local _ assignment#12741jdonaldson wants to merge 1 commit intoHaxeFoundation:developmentfrom
jdonaldson wants to merge 1 commit intoHaxeFoundation:developmentfrom
Conversation
Replace `(function() return expr end)()` with `local _ = expr` for discarded expression-statements (non-assign TBinop and TField at statement level). This eliminates the most common source of `(`-starting statements that trigger Lua's parsing ambiguity. Also adds deferred semicolon mechanism for remaining cases where generated output starts with `(` (chained calls, anonymous IIFEs).
Member
Author
|
I'm trying to chip away at a few of the points where genlua creates a mess of expressions. One easy one is avoiding iifes for simple expressions that don't save return values. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
(function() return expr end)()withlocal _ = exprfor discarded expression-statements ingen_iife_assignTBinop(op != Assign)andTFieldat statement level ingen_block_element(-at-statement-start parsing ambiguityRelates to #7350
Test plan
(function() returnpatterns remain fromgen_iife_assignlocal _ =replacements in test output