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

Improve parsing error messages #405

Merged
merged 1 commit into from
May 14, 2024
Merged

Conversation

chqrlie
Copy link
Collaborator

@chqrlie chqrlie commented May 14, 2024

  • output more informative error messages in js_parse_expect.

The previous code was bogus:

    return js_parse_error(s, "expecting '%c'", tok);

this was causing a bug on eval("do;") where tok is TOK_WHILE (-70, 0xBA) creating an invalid UTF-8 encoding (lone trailing byte). This would ultimately have caused a failure in JS_ThrowError2 if JS_NewString failed when converting an error to a string if the conversion detects invalid UTF-8 encoding and throws an error (it currently does not, but should).

  • test for JS_NewString failure in JS_ThrowError2
  • test for JS_FreeCString failure in run-test262.c
  • add more test cases

- output more informative error messages in `js_parse_expect`.

The previous code was bogus:
```
    return js_parse_error(s, "expecting '%c'", tok);
```
this was causing a bug on `eval("do;")` where `tok` is `TOK_WHILE` (-70, 0xBA)
creating an invalid UTF-8 encoding (lone trailing byte).
This would ultimately have caused a failure in `JS_ThrowError2` if `JS_NewString`
failed when converting an error to a string if the conversion detects invalid
UTF-8 encoding and throws an error (it currently does not, but should).

- test for `JS_NewString` failure in `JS_ThrowError2`
- test for `JS_FreeCString` failure in run-test262.c
- add more test cases
@chqrlie chqrlie merged commit 5a7e578 into quickjs-ng:master May 14, 2024
47 checks passed
@chqrlie chqrlie deleted the fix-parse-expect branch May 14, 2024 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants