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

Yet more misparsing: invalid parentheses in call statements and assignments #24

Closed
fstirlitz opened this issue May 11, 2014 · 4 comments
Assignees
Labels
incorrect parsing Valid Lua code fails to parse, is parsed incorrectly, or invalid Lua code is accepted
Milestone

Comments

@fstirlitz
Copy link
Owner

Each of the lines that follow is a syntax error, yet luaparse does not recognise these as such:

(a.b) = 0
(a) = 0
a:b() = 0
a() = 0
a.b:c() = 0
a[b]() = 0
(0) = 0
a, b() = 0, 0

Note, however, that the following are not (syntactical, at least) errors:

a().b = 1
({})[b] = 1
a""[b] = 1
a{}[b] = 1
({{}})[a][b] = 1
(a).b = 1
(1).a = 2 -- runtime error, unless you use debug.setmetatable

Relevant portions of the Lua 5.2 manual (essentially identical in Lua 5.0 and 5.1, and to 5.3-work2): §3.2 "Variables", §3.3.3 "Assignment", §9 "The Complete Syntax of Lua"

@oxyc
Copy link
Collaborator

oxyc commented May 22, 2014

Thanks again felix!

Unfortunately I won't have time to look into this for quite some time. I'm leaving for a 6 month trip around the middle east and won't have access to a development machine during this time.

If you however have the time and can figure out a fix feel free to commit it. I've added you as a collaborator to the project as you are more than capable of managing it :) I trust your judgment so feel free to commit whatever else you think could help the project.

fstirlitz pushed a commit that referenced this issue Aug 13, 2014
unfortunately it's necessary to peek the outputted AST to accomplish this, which may be unreliable. the same kludge is already used in isCallExpression()

the "caller can supply their own AST construction methods" feature probably needs to go. either that or some parsing functions need to return two values: one for the constructed AST and some for internal use - that would be rather wasteful.

benchmarks	docs	      luaparse.js   SciTE.properties  testem.yml
bin		examples      Makefile	    scripts
bower.json	Gruntfile.js  node_modules  static_test
component.json	index.js      package.json  static_test.lua
dist		LICENSE       README.md     test
fstirlitz pushed a commit that referenced this issue Aug 13, 2014
unfortunately it's necessary to peek the outputted AST to accomplish this, which may be unreliable. the same kludge is already used in isCallExpression()

the "caller can supply their own AST construction methods" feature probably needs to go. either that or some parsing functions need to return two values: one for the constructed AST and some for internal use - that would be rather wasteful.
@fstirlitz fstirlitz mentioned this issue Jul 27, 2016
Closed
@fstirlitz fstirlitz added the incorrect parsing Valid Lua code fails to parse, is parsed incorrectly, or invalid Lua code is accepted label Aug 2, 2019
@fstirlitz fstirlitz added this to the 0.3 milestone Oct 5, 2019
@fstirlitz
Copy link
Owner Author

Should also add:

(a());
(a"");
(a{});

I've got some WIP code which should fix this once and for all.

@fstirlitz fstirlitz self-assigned this Oct 20, 2019
@fstirlitz fstirlitz changed the title Yet more misparsing Yet more misparsing: invalid parentheses in call statements and assignments Oct 24, 2019
Repository owner deleted a comment from berbun Oct 30, 2019
Repository owner deleted a comment from berbun Oct 30, 2019
Repository owner deleted a comment from berbun Oct 30, 2019
@fstirlitz
Copy link
Owner Author

Finally definitively fixed in 6c00a3a. The particular parsing mechanics (and the resulting error messages) may still change in the future, but at least all test cases fail as expected now.

@arnoson

This comment has been minimized.

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

3 participants