Critical parsing issue causing LESS 1.3 to break #716

matthew-dean opened this Issue Mar 15, 2012 · 3 comments


None yet
2 participants

matthew-dean commented Mar 15, 2012

I set about updating the LESS parser to 1.3 in When trying to compile my LESS files to CSS, I got this error:

Result of expression 'input' [undefined] is not an object. (Line: 353)

I figured that surely I was to blame, so I downloaded the latest with 1.3 and tried again. This time, same file, I got this error: Cannot call method 'charAt' of undefined at getLocation (/mydrive/parser.js:212:34)

A quick check on Github told me that the function in question in parser.js is:

 function getLocation(index, input) {
        for (var n = index, column = -1;
                 n >= 0 && input.charAt(n) !== '\n';
                 n--) { column++ }

        return { line:   typeof(index) === 'number' ? (input.slice(0, index).match(/\n/g) || "").length : null,
                 column: column };

So, it looks like input isn't being set to a valid string, which would explain the same error in both places.

My set of LESS files worked previously in 1.2.

Here's the code that is failing, although not sure if it's not failing in one of the includes:

@import "normalize";
@import "mixins";
@import "ui/layout";
@import "ui/common";
@import "ui/nav";
@import "ui/gameplay";
@import "ui/widgets";
@import "ui/social";
@import "ui/panels";
@import "ui/tablet";
@import "ui/visuals";

matthew-dean commented Mar 19, 2012

I've narrowed down the issue: there's an error in LessError. The actual error being sent to LessError is:

"No matching definition was found for .bg-size(100%, 100%)"

As well, the filename is being sent, but when it runs getInput, it returns undefined. It looks up parser.imports.contents and cannot find the included filename, even though it parsed it the first time.

Could this be because the file that produced the error is in a subdirectory? (ui/gameplay.less appears to contain the error.)

I think this is also related to the breaking change where you can't just send unlimited arguments to a mixin without an explicit "..." declaration, correct? Rather than an extra argument being discarded, it appears to be throwing an error. And then, secondly, it appears that error handling in 1.3 is broken.


matthew-dean commented Mar 19, 2012

I was right.

I set up a test case at the point of failure.

This is what the code is trying to do in getInput:

parser.imports.contents["gameplay.less"]  --> returns "undefined"

This is what actually returns a value:


@ghost ghost assigned sashasklar Mar 29, 2012


matthew-dean commented Jul 20, 2012

Duplicate of #723. Closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment