Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser should accept Lua paren-less function calls with a single string or table literal #86

Open
dansanderson opened this issue Sep 10, 2021 · 3 comments

Comments

@dansanderson
Copy link
Owner

Lua allows parentheses to be omitted from a function call if there is exactly one argument and the argument is a string or table literal. picotool does not yet support this case. PICO-8 supports it and offers a one-token discount compared to a similar call with parentheses.

function foo(arg) ... end

foo"single string argument"
foo{a=1, b=2, c=3}

I'm not sure how important this is to support, but I'm creating an issue for it just so we can track it. Upvotes and feedback welcome.

@Liquidream
Copy link

Alas, I do rely on this trick quite a lot in my luamin-ified code quite a lot (every token counts!)
So, I would definitely be keen on this being supported.

FWIW, I thought it already did (as it seems I'm only using the string param method so far, and the minified output seems to preserve it... so far!)

@dansanderson dansanderson changed the title Accept Lua paren-less function calls with a single string or table literal Parser should accept Lua paren-less function calls with a single string or table literal Sep 11, 2021
@dansanderson
Copy link
Owner Author

@Liquidream It works fine with luamin! This bug is specific to the Lua parser. luamin operates directly on the token stream and doesn't use the parser.

blurble end do blah{x=1} blurble sspr

isn't valid Lua but luamin is happy to minify that to

a end do b{c=1} a sspr

@Liquidream
Copy link

Ah... my bad (explains why I never thought it was an issue 🤦‍♂️)
*HidesInShame* 🙈

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

No branches or pull requests

2 participants