mapbox / carto

fast CSS-like map stylesheets
https://cartocss.readthedocs.io/
Apache License 2.0
652 stars 129 forks source link

Errors are multiplied and assigned to wrong file #426

Closed florianf closed 7 years ago

florianf commented 8 years ago

Hi, carto.Renderer reports wrong file (Stylesheet id) and repeats error 9 times with attached bogus .mml (slightly changed Tilemill road-trip project) file. Note the invalid "invalidFunction" call and the wrong parameter call of lighting in the attached project file.

The ouput is:

labels.mss:7:1 unknown function invalidFunction(), did you mean invert(0)
labels.mss:7:1 unknown function invalidFunction(), did you mean invert(0)
labels.mss:7:1 unknown function invalidFunction(), did you mean invert(0)
labels.mss:7:1 unknown function invalidFunction(), did you mean invert(0)
labels.mss:7:1 unknown function invalidFunction(), did you mean invert(0)
labels.mss:7:1 unknown function invalidFunction(), did you mean invert(0)
labels.mss:7:1 unknown function invalidFunction(), did you mean invert(0)
labels.mss:7:1 unknown function invalidFunction(), did you mean invert(0)
labels.mss:31:-1 incorrect number of arguments for lighten(). 2 expected.
labels.mss:7:1 unknown function invalidFunction(), did you mean invert(0)

Expected:

style.mss:7:1 unknown function invalidFunction(), did you mean invert(0)
style.mss:31:-1 incorrect number of arguments for lighten(). 2 expected.

Code used to load and render the file:

#!/usr/bin/env node

var fs = require('fs');
var carto = require('carto');

var mms = JSON.parse(fs.readFileSync("project.txt"));
var env = {
    returnErrors: true,
    effects: []
};

var xml = new carto.Renderer(env, { mapnik_version: "3.0.7" })

try {
    xml.render(mms);
}
catch (error) {
    console.log(error.message);    
}

Projectfile: project.txt

nebulon42 commented 7 years ago

Partial fix in https://github.com/mapbox/carto/commit/c88ff3459531c4e5c4e4b1acac16273fbccad9ab. The file name is now correct. Not sure why the error occurs that often. I would expect an error each time the variable @water is evaluated, but that should happen only twice.

nebulon42 commented 7 years ago

I succeeded in suppressing additional error messages. However, as I suspected you still get one error for each evaluation of the variable. Two in this case:

style.mss:12:32 unknown function invalidFunction(), did you mean invert(0)
style.mss:45:26 incorrect number of arguments for lighten(). 2 expected.
style.mss:12:32 unknown function invalidFunction(), did you mean invert(0)
florianf commented 7 years ago

Just upgraded TileOven to the latest version, error display is much better now, thanks for the fix!