From ba5c8189cda68b8a064d44bd707c4e59a92c5152 Mon Sep 17 00:00:00 2001 From: seven-phases-max Date: Thu, 5 Dec 2013 10:56:20 +0400 Subject: [PATCH] Fixed line/column numbers in math expr/ops error messages. Updated tests. --- lib/less/tree/rule.js | 6 ++++++ test/less/errors/add-mixed-units.txt | 6 ++++-- test/less/errors/add-mixed-units2.txt | 6 ++++-- test/less/errors/color-operation-error.txt | 6 ++++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/less/tree/rule.js b/lib/less/tree/rule.js index 20562094..029befb3 100644 --- a/lib/less/tree/rule.js +++ b/lib/less/tree/rule.js @@ -42,6 +42,12 @@ tree.Rule.prototype = { this.merge, this.index, this.currentFileInfo, this.inline); } + catch(e) { + if (e.index === undefined) { + e.index = this.index; + } + throw e; + } finally { if (strictMathBypass) { env.strictMath = false; diff --git a/test/less/errors/add-mixed-units.txt b/test/less/errors/add-mixed-units.txt index b5553618..9ea45438 100644 --- a/test/less/errors/add-mixed-units.txt +++ b/test/less/errors/add-mixed-units.txt @@ -1,2 +1,4 @@ -SyntaxError: Incompatible units. Change the units or use the unit function. Bad units: 'px' and 'em'. in {path}add-mixed-units.less on line null, column 0: -1 error: (1px + 3em); +SyntaxError: Incompatible units. Change the units or use the unit function. Bad units: 'px' and 'em'. in {path}add-mixed-units.less on line 2, column 3: +1 .a { +2 error: (1px + 3em); +3 } diff --git a/test/less/errors/add-mixed-units2.txt b/test/less/errors/add-mixed-units2.txt index cc65a760..ca34304f 100644 --- a/test/less/errors/add-mixed-units2.txt +++ b/test/less/errors/add-mixed-units2.txt @@ -1,2 +1,4 @@ -SyntaxError: Incompatible units. Change the units or use the unit function. Bad units: 'px*px' and 'em*px'. in {path}add-mixed-units2.less on line null, column 0: -1 error: ((1px * 2px) + (3em * 3px)); +SyntaxError: Incompatible units. Change the units or use the unit function. Bad units: 'px*px' and 'em*px'. in {path}add-mixed-units2.less on line 2, column 3: +1 .a { +2 error: ((1px * 2px) + (3em * 3px)); +3 } diff --git a/test/less/errors/color-operation-error.txt b/test/less/errors/color-operation-error.txt index 1b3f889f..ae47728a 100644 --- a/test/less/errors/color-operation-error.txt +++ b/test/less/errors/color-operation-error.txt @@ -1,2 +1,4 @@ -OperationError: Can't substract or divide a color from a number in {path}color-operation-error.less on line null, column 0: -1 prop: (3 / #fff); +OperationError: Can't substract or divide a color from a number in {path}color-operation-error.less on line 2, column 3: +1 .a { +2 prop: (3 / #fff); +3 }