[Pkg-javascript-commits] [less.js] 30/38: Fix parse error effectinge pseudo classes with guards. Fixes #2352

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:27:28 UTC 2015


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

js pushed a commit to annotated tag v2.2.0
in repository less.js.

commit 49955d3a354615b98543ca34e2f884e41f59ca29
Author: Luke Page <luke.a.page at gmail.com>
Date:   Sat Jan 3 17:07:06 2015 +0000

    Fix parse error effectinge pseudo classes with guards. Fixes #2352
---
 lib/less/parser/parser-input.js         |  3 ++-
 lib/less/parser/parser.js               | 12 ++++++++----
 test/less/css-guards.less               |  3 ++-
 test/less/errors/detached-ruleset-2.txt |  2 +-
 test/less/errors/parens-error-1.txt     |  2 +-
 test/less/errors/parens-error-2.txt     |  2 +-
 test/less/errors/parens-error-3.txt     |  2 +-
 7 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lib/less/parser/parser-input.js b/lib/less/parser/parser-input.js
index a7407b7..267ef8e 100644
--- a/lib/less/parser/parser-input.js
+++ b/lib/less/parser/parser-input.js
@@ -16,7 +16,8 @@ module.exports = function() {
         saveStack.push( { current: current, i: parserInput.i, j: j });
     };
     parserInput.restore = function(possibleErrorMessage) {
-        if (parserInput.i > furthest) {
+
+        if (parserInput.i > furthest || (parserInput.i === furthest && possibleErrorMessage && !furthestPossibleErrorMessage)) {
             furthest = parserInput.i;
             furthestPossibleErrorMessage = possibleErrorMessage;
         }
diff --git a/lib/less/parser/parser.js b/lib/less/parser/parser.js
index fe08b9d..f1cf119 100644
--- a/lib/less/parser/parser.js
+++ b/lib/less/parser/parser.js
@@ -1383,15 +1383,19 @@ var Parser = function Parser(context, imports, fileInfo) {
             sub: function () {
                 var a, e;
 
+	            parserInput.save();
                 if (parserInput.$char('(')) {
                     a = this.addition();
-                    if (a) {
-                        e = new(tree.Expression)([a]);
-                        expectChar(')');
-                        e.parens = true;
+                    if (a && parserInput.$char(')')) {
+	                    parserInput.forget();
+	                    e = new(tree.Expression)([a]);
+	                    e.parens = true;
                         return e;
                     }
+	                parserInput.restore("Expected ')'");
+	                return;
                 }
+	            parserInput.restore();
             },
             multiplication: function () {
                 var m, a, op, operation, isSpaced;
diff --git a/test/less/css-guards.less b/test/less/css-guards.less
index 85ec8d2..cabd52a 100644
--- a/test/less/css-guards.less
+++ b/test/less/css-guards.less
@@ -99,4 +99,5 @@
 }
 .errors-if-called when (@c = never) {
   .mixin-doesnt-exist();
-}
\ No newline at end of file
+}
+a:hover when (2 = true) {5:-}
\ No newline at end of file
diff --git a/test/less/errors/detached-ruleset-2.txt b/test/less/errors/detached-ruleset-2.txt
index 32344a8..43b9925 100644
--- a/test/less/errors/detached-ruleset-2.txt
+++ b/test/less/errors/detached-ruleset-2.txt
@@ -1,4 +1,4 @@
-ParseError: Unrecognised input. Possibly missing opening '(' in {path}detached-ruleset-2.less on line 5, column 9:
+ParseError: Expected ')' in {path}detached-ruleset-2.less on line 5, column 9:
 4 .a {
 5   a: @a();
 6 }
diff --git a/test/less/errors/parens-error-1.txt b/test/less/errors/parens-error-1.txt
index 6fc40ac..35be175 100644
--- a/test/less/errors/parens-error-1.txt
+++ b/test/less/errors/parens-error-1.txt
@@ -1,4 +1,4 @@
-SyntaxError: expected ')' got '(' in {path}parens-error-1.less on line 2, column 18:
+ParseError: Expected ')' in {path}parens-error-1.less on line 2, column 18:
 1 .a {
 2   something: (12 (13 + 5 -23) + 5);
 3 }
diff --git a/test/less/errors/parens-error-2.txt b/test/less/errors/parens-error-2.txt
index cee5c52..b40e4c2 100644
--- a/test/less/errors/parens-error-2.txt
+++ b/test/less/errors/parens-error-2.txt
@@ -1,4 +1,4 @@
-SyntaxError: expected ')' got '-' in {path}parens-error-2.less on line 2, column 28:
+ParseError: Expected ')' in {path}parens-error-2.less on line 2, column 28:
 1 .a {
 2   something: (12 * (13 + 5 -23));
 3 }
diff --git a/test/less/errors/parens-error-3.txt b/test/less/errors/parens-error-3.txt
index 3280ef0..c6c8434 100644
--- a/test/less/errors/parens-error-3.txt
+++ b/test/less/errors/parens-error-3.txt
@@ -1,4 +1,4 @@
-SyntaxError: expected ')' got '-' in {path}parens-error-3.less on line 2, column 29:
+ParseError: Expected ')' in {path}parens-error-3.less on line 2, column 29:
 1 .a {
 2   something: (12 + (13 + 10 -23));
 3 }

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



More information about the Pkg-javascript-commits mailing list