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

Fix 9068 newlines emcc error #9088

Merged

Conversation

yeputons
Copy link
Contributor

This fixes a patch applied to acorn.js for quoting error-causing text in parse errors (acornjs/acorn#793). Previously it splitted binary data on \n to get lines, which was inconsistent with the rest of the parser and caused excess \r in the error message on Windows, which caused #9057. Now it uses the same regex as the rest of acorn.js (e.g. getLineInfo used by error reporting).

It also fixes #9057 automatically, hence I enabled corresponding test and removed unnecessary change from #9052.

Tests ran on Windows:

python2 runner.py other.test_js_optimizer_parse_error

yeputons added 2 commits July 26, 2019 12:16
…s on Windows

This fixes a patch applied to acorn.js for quoting error-causing text
in parse errors (acornjs/acorn#793).
Previously it splitted binary data on \n to get lines, which was
inconsistent with the rest of the parser and caused excess \r in
the error message on Windows. Now it uses the same regex as the rest
of acorn.js (e.g. getLineInfo used by error reporting).
@@ -2769,7 +2769,7 @@ pp$4.raise = function(pos, message) {
message += " (" + loc.line + ":" + loc.column + ")";
// XXX EMSCRIPTEN: add a quote of the error text, point to where
// https://github.com/acornjs/acorn/pull/793
var lines = this.input.split('\n');
var lines = this.input.split(lineBreak);
message = message + '\n' + lines[loc.line - 1] + '\n';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this \n goes to the error message string, which is later displayed by Node exception handler. Hence, it's a usual string, not bytes, newlines are transformed automatically.

Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that was remarkably simple! Thanks! @kripken do you have any worries about modifying acorn.js like this?

@kripken
Copy link
Member

kripken commented Jul 26, 2019

Great find @yeputons!

This is totally my fault - this is the local patch we have for acorn. I should have noticed they have a lineBreak...

@kripken kripken merged commit f335b0e into emscripten-core:incoming Jul 26, 2019
@yeputons yeputons deleted the fix-9068-newlines-emcc-error branch July 29, 2019 10:47
yeputons added a commit to yeputons/emscripten that referenced this pull request Aug 7, 2019
yeputons added a commit to yeputons/emscripten that referenced this pull request Aug 7, 2019
belraquib pushed a commit to belraquib/emscripten that referenced this pull request Dec 23, 2020
* Fix emscripten-core#9068: get rid of malformed newlines in emcc errors on Windows

This fixes a patch applied to acorn.js for quoting error-causing text
in parse errors (acornjs/acorn#793).
Previously it splitted binary data on \n to get lines, which was
inconsistent with the rest of the parser and caused excess \r in
the error message on Windows. Now it uses the same regex as the rest
of acorn.js (e.g. getLineInfo used by error reporting).

* Fix emscripten-core#9057 by fixing by emscripten-core#9068
belraquib pushed a commit to belraquib/emscripten that referenced this pull request Dec 23, 2020
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.

test_js_optimizer_parse_error fails on windows
3 participants