Skip to content

ensuring statement expressions are transpiled to valid lua#506

Merged
tomblind merged 3 commits intomasterfrom
expression-statements-fix
Apr 4, 2019
Merged

ensuring statement expressions are transpiled to valid lua#506
tomblind merged 3 commits intomasterfrom
expression-statements-fix

Conversation

@tomblind
Copy link
Copy Markdown
Collaborator

@tomblind tomblind commented Apr 4, 2019

fixes #503

This will conflict with #505, so I guess I'll see which gets approved first and fix the other 😄

@lolleko
Copy link
Copy Markdown
Member

lolleko commented Apr 4, 2019

Wouldnt it be better to just ommit those? they dont have any effect right? (except calls and increment/decrement)

not sure if we should waste resources assigning those statements to local ____

@ark120202
Copy link
Copy Markdown
Contributor

@lolleko Expressions may have side effects (e.g. calls) deeply nested inside them, for example a quite common pattern: a ? foo() : bar(). Of course it's possible to traverse it and only emit when there are possible side effects, but IMO it might not worth it.

@lolleko
Copy link
Copy Markdown
Member

lolleko commented Apr 4, 2019

Okay! People probably don't add useless statements like "hello"; !myBool;... to their code anyway.

@Perryvw Perryvw closed this Apr 4, 2019
@Perryvw Perryvw reopened this Apr 4, 2019
@tomblind
Copy link
Copy Markdown
Collaborator Author

tomblind commented Apr 4, 2019

Simple literals are pretty much the only thing guaranteed to not have side effects. Even something like

-a;

could invoke metamethods. Since having simple literals as statements isn't something people are likely to do, it doesn't really seem worth the extra logic.

@tomblind tomblind merged commit dccea87 into master Apr 4, 2019
@tomblind tomblind deleted the expression-statements-fix branch April 4, 2019 21:04
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.

Expression as statements produce invalid lua

4 participants