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

Indexing string literals #48

Open
Erutuon opened this issue Oct 20, 2017 · 4 comments · May be fixed by #89
Open

Indexing string literals #48

Erutuon opened this issue Oct 20, 2017 · 4 comments · May be fixed by #89

Comments

@Erutuon
Copy link

Erutuon commented Oct 20, 2017

Currently luamin converts ('abc'):match('a') to 'abc':match('a'). This results in a syntax error ("')' expected near ':'"): a string has to be enclosed in parentheses for it to be indexed. (Actually, the expression could be reduced to ('abc'):match'a', but perhaps that's best avoided.)

@Erutuon Erutuon changed the title Methods called on string literals Indexing string literals Oct 20, 2017
@xLarry
Copy link

xLarry commented Aug 28, 2019

Should be fixed by #63

$ npm i git+https://github.com/Ayplow/luamin.git
+ luamin@1.0.4
$ npx luamin -c "('abc'):match('a')"
('abc'):match('a')

@Erutuon
Copy link
Author

Erutuon commented Aug 28, 2019

Now I realize there was another problem related to indexing of string literals that I failed to mention: the minifier throws a syntax error for ('abc')['match'] and ('abc').match. Perhaps that should be put in a separate issue because it originates from a different part of the minifier.

@berbun
Copy link

berbun commented Oct 26, 2019

Now I realize there was another problem related to indexing of string literals that I failed to mention: the minifier throws a syntax error for ('abc')['match'] and ('abc').match. Perhaps that should be put in a separate issue because it originates from a different part of the minifier.

This is an issue with luaparse#24.

@Erutuon
Copy link
Author

Erutuon commented Oct 26, 2019

This is getting farther from the original topic, but the string literal indexing is part of a larger issue. For all except table and function literals, Luamin doesn't recognize that any literal must be enclosed with parentheses in order to be indexed or have a method called on it:

(true):method()
(false):method()
(nil):method()
(1):method()
('abc'):method()
(function() end):method()
({}):method()
(true)[1]
(false)[1]
(nil)[1]
(1)[1]
('abc')[1]
(function() end)[1]
({})[1]

If each of these lines is supplied separately to Luamin, there is a syntax error or the parentheses around the literal are removed, except with method calls on table and function literals.

@9382 9382 linked a pull request Aug 9, 2024 that will close this issue
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 a pull request may close this issue.

3 participants