Skip to content

Assignment binding patterns#677

Merged
Perryvw merged 14 commits intoTypeScriptToLua:masterfrom
hazzard993:assignment-binding-patterns
Jul 27, 2019
Merged

Assignment binding patterns#677
Perryvw merged 14 commits intoTypeScriptToLua:masterfrom
hazzard993:assignment-binding-patterns

Conversation

@hazzard993
Copy link
Copy Markdown
Contributor

@hazzard993 hazzard993 commented Jul 21, 2019

Closes #574

Closes #599

Before destructures were only made with a Lua statement.

a, b, c = 1, 2, 3

This still happens as an optimisation but if the left hand side contains initializers, special assignments or nested destructuring patterns it reverts to an alternate method similar to how binding patterns currently work but separated into more methods.

local ____ = ...
x = ____[1][1]
...

@ark120202
Copy link
Copy Markdown
Contributor

This PR doesn't appear to do anything with variables declarations and transformBindingPattern, Is it impossible to share some logic with it?

@hazzard993
Copy link
Copy Markdown
Contributor Author

The destructuring assignment AST shares no kinds of nodes with binding patterns.

I tried it initially but I kept it out of scope as I ended up overhauling all binding and destructuring behaviour which wasn't my intention.

}

public transformExpressionStatement(statement: ts.ExpressionStatement | ts.Expression): StatementVisitResult {
const expression = ts.isExpressionStatement(statement) ? statement.expression : statement;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change this line.

@Perryvw Perryvw requested a review from tomblind July 27, 2019 10:13
@Perryvw Perryvw merged commit d7f76fb into TypeScriptToLua:master Jul 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Destructuring pattern assignments don't use special assignment behaviour Binding Pattern Assignment Statements

4 participants