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

Unexpected Token Error When Creating AST with Lua Code Containing the "//" Operator #129

Closed
lynnlake opened this issue May 8, 2023 · 4 comments · Fixed by #147
Closed
Labels
bug Something isn't working extractor

Comments

@lynnlake
Copy link

lynnlake commented May 8, 2023

the error msg is:

error occurred while creating ast: unexpected token `/`

It is worth noting that the "//" operator was only introduced to Lua in version 5.3. In order to reproduce this error, you can use the following code snippet:

p = 3.0
p = p and p // 1

Please note that this error appears to be related to the parser, as it is unable to recognize the "//" operator.

@evaera
Copy link
Owner

evaera commented May 8, 2023

We currently only support Lua 5.1/Luau mode but the underlying parser we use (full_moon) does support Lua 5.2, 5.3, and 5.4.

We would need to add a flag/config option to Moonwave to allow selecting which version of Lua to use to support this.

@RuizuKun-Dev
Copy link

Hey, 👋🏻

I'm currently affected by this, I was wondering when will the update be released?

@YetAnotherClown
Copy link
Collaborator

Hello @RuizuKun-Dev, I gave a brief answer on Discord but I will also provide an answer here in case anyone else comes across this.

This issue would be fixed by updating full-moon to v0.19.0, which is the version I was originally going to update Moonwave to. Unfortunately, I was experiencing full-moon crashes on that version in large codebases during testing, such as Nevermore. These crashes are fixed in full-moon v1.0.0 which is not out just yet.

Since I do not want to break workflows for projects such as Nevermore, this is currently blocked until the release of full-moon v1.0.0 which, to my knowledge, has no ETA but is currently in pre-release phase and should hopefully be released soon.

In the meantime, you can instead do

-- This
math.floor(a / b)

-- Instead of
a // b

For future tracking, see #147.

@RuizuKun-Dev
Copy link

RuizuKun-Dev commented Aug 2, 2024

ahhh, okay thank you for the answer appreciate it! 🙏🏻 @YetAnotherClown

In the meantime, you can instead do

-- This
math.floor(a / b)

-- Instead of
a // b

yeah, I actually did that for bufferUtil

thanks, i sub to the issue and repo release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working extractor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants