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

Change parse error type from SyntaxError to something else #67

Open
fstirlitz opened this issue Aug 17, 2019 · 2 comments
Open

Change parse error type from SyntaxError to something else #67

fstirlitz opened this issue Aug 17, 2019 · 2 comments
Labels
compat hazard Resolving this issue may create backwards compatibility problems
Milestone

Comments

@fstirlitz
Copy link
Owner

The SyntaxError type is reserved for errors raised by the host runtime (i.e. JavaScript), not errors raised by user code. Using SyntaxError to signal errors in inputs to the Lua parser causes problems in some engines, like the one worked around in 8536fdf.

Fixing this will be a breaking change, given that some downstream users already rely on the error to be an instance of SyntaxError, e.g. the ACE editor.

Related PR: #33.

@fstirlitz fstirlitz added the compat hazard Resolving this issue may create backwards compatibility problems label Aug 17, 2019
@fstirlitz fstirlitz added this to the 0.3 milestone Aug 17, 2019
@fstirlitz fstirlitz modified the milestones: 0.3, 0.4 Oct 5, 2019
@fstirlitz
Copy link
Owner Author

I think I am going to solve this and #9 in one go. In other words, I will create a callback that shall receive diagnostics from the parser as a structured object; if the callback is absent, the parser will fall back to throwing a SyntaxError as before.

@fstirlitz
Copy link
Owner Author

As of 6f8a7ea, the error type thrown by the parser is exported as a SyntaxError export. Users are encouraged to use that export instead of directly referring to the engine’s SyntaxError to detect errors thrown by luaparse, to minimise future breakage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compat hazard Resolving this issue may create backwards compatibility problems
Projects
None yet
Development

No branches or pull requests

1 participant