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

Reject newlines between an expression and opening parenthesis #55

Closed
fstirlitz opened this issue Sep 5, 2017 · 2 comments
Closed

Reject newlines between an expression and opening parenthesis #55

fstirlitz opened this issue Sep 5, 2017 · 2 comments
Labels
incorrect parsing Valid Lua code fails to parse, is parsed incorrectly, or invalid Lua code is accepted

Comments

@fstirlitz
Copy link
Owner

PUC Lua 5.1 (and LuaJIT without the LUAJIT_ENABLE_LUA52COMPAT option) rejects code in which an expression is followed by a newline and an opening parenthesis. This is to avoid a parsing ambiguity discussed in the Lua 5.2 manual, §3.3.1, which Lua 5.2 and later instead resolve by introducing an optional explicit statement terminator, ;. (One can also use do...end, which also works in Lua 5.1.)

Currently, luaparse accepts such code with Lua 5.2 semantics (that is, interprets it as a function call); in Lua 5.1 mode, which is the default, it should probably be rejected instead.

@ghost
Copy link

ghost commented May 19, 2018

Okay, monthly-old issue; but I guess luaparse just needs to do something like this after encountering (...

if (options.version !== '5.1')
{
	if ( base_expr_loc_independent_end_lineNumber !== paren_token_loc_independent_start_lineNumber) /* report error */
}

Can't clone the repo right now bcuz it's over 30MB, but I think this evolves extending the Marker class.

@fstirlitz
Copy link
Owner Author

Fixed in fa257d0.

@fstirlitz fstirlitz added the incorrect parsing Valid Lua code fails to parse, is parsed incorrectly, or invalid Lua code is accepted label Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incorrect parsing Valid Lua code fails to parse, is parsed incorrectly, or invalid Lua code is accepted
Projects
None yet
Development

No branches or pull requests

1 participant