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

Bug return statement #10

Closed
epatrizio opened this issue Nov 6, 2023 · 3 comments
Closed

Bug return statement #10

epatrizio opened this issue Nov 6, 2023 · 3 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@epatrizio
Copy link
Owner

3.3.4 – Control Structures (official documentation)
https://www.lua.org/manual/5.4/manual.html#3.3.4

The return statement can only be written as the last statement of a block. If it is necessary to return in the middle of a block, then an explicit inner block can be used, as in the idiom do return end, because now return is the last statement in its (inner) block.

--
Actually, when return isn't at the end of the block, the stop is still made at this point.

@epatrizio epatrizio added bug Something isn't working enhancement New feature or request labels Nov 6, 2023
@epatrizio
Copy link
Owner Author

Check block definition in parser
https://github.com/epatrizio/ola/blob/main/src/parser.mly
In PR mentioned above (parser full refactoring), return can only be written as the last block statement.
Otherwise it causes a syntax error.
Check line 76 https://github.com/epatrizio/ola/blob/main/test/blocks.lua

@epatrizio
Copy link
Owner Author

96f0806

@epatrizio
Copy link
Owner Author

related issue #7

@epatrizio epatrizio self-assigned this Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant