[Pkg-javascript-commits] [uglifyjs] 133/228: improve error marker placement (#1644)

Jonas Smedegaard dr at jones.dk
Sat Apr 15 14:25:24 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository uglifyjs.

commit 2e0dc970037b3a22fb367ab77c5fe506317ee40b
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Fri Mar 24 14:28:40 2017 +0800

    improve error marker placement (#1644)
    
    For AST_UnaryPrefix, points to the operator rather than end of expression.
---
 lib/parse.js      | 2 +-
 test/mocha/cli.js | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/parse.js b/lib/parse.js
index 99d7ce0..1ccde26 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -1457,7 +1457,7 @@ function parse($TEXT, options) {
 
     function make_unary(ctor, op, expr) {
         if ((op == "++" || op == "--") && !is_assignable(expr))
-            croak("Invalid use of " + op + " operator");
+            croak("Invalid use of " + op + " operator", null, ctor === AST_UnaryPrefix ? expr.start.col - 1 : null);
         return new ctor({ operator: op, expression: expr });
     };
 
diff --git a/test/mocha/cli.js b/test/mocha/cli.js
index 3374904..b956309 100644
--- a/test/mocha/cli.js
+++ b/test/mocha/cli.js
@@ -298,9 +298,9 @@ describe("bin/uglifyjs", function () {
            assert.ok(err);
            assert.strictEqual(stdout, "");
            assert.strictEqual(stderr.split(/\n/).slice(0, 4).join("\n"), [
-               "Parse error at test/input/invalid/assign_3.js:1,23",
+               "Parse error at test/input/invalid/assign_3.js:1,18",
                "console.log(3 || ++this);",
-               "                       ^",
+               "                  ^",
                "SyntaxError: Invalid use of ++ operator"
            ].join("\n"));
            done();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list