From:  richard.schneeman@gmail.com
Date:  12 Dec 2015 04:27:18 Hong Kong Time
Newsgroup:  news.mozilla.org/mozilla.dev.js-sourcemap
Subject:  

Starting index of line numbers differs from the spec?

NNTP-Posting-Host:  63.245.214.181

Hello,

I'm trying to polish up the source map implementation for Sprockets 4 (https://rubygems.org/gems/sprockets). I was reading through the version 3 proposal and using the  mozilla library source-map when I found something slightly contradictory.

In https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1 it sounds like line numbers and column numbers should be zero indexed however in all the implementations i've been able to find such as `source-map` i'm seeing that lines are 1 indexed and columns are zero indexed.

For example:

```
$ cat foo.js
var foo = "foo";
var bar = "bar";

$ uglifyjs foo.js --source-map foo.js.map
var foo="foo";var bar="bar";
//# sourceMappingURL=foo.js.map

$ cat foo.js.map
{"version":3,"sources":["foo.js"],"names":["foo","bar"],"mappings":"AAAA,GAAIA,KAAM,KACV,IAAIC,KAAM"}
```

I can parse this source map with mozilla's module using this code:

```
var sourceMap = require('source-map');
var fs        = require('fs');

fs.readFile('./foo.js.map', 'utf8', function (err, data) {
  if (err) {
    return console.log(err);
  }
  var smc = new sourceMap.SourceMapConsumer(data);

  smc.eachMapping(function(m) {
    console.log(m);
  });
});
```

For the `foo` variable I get this result:

```
{ source: 'foo.js',
  generatedLine: 1,
  generatedColumn: 3,
  originalLine: 1,
  originalColumn: 4,
  name: 'foo' }
```

I would have expected based on the google doc that `generatedLine` should be 0 and not 1, while the `generatedColumn` matches my expectations. From the doc

> If present, the zero-based starting line in the original source represented. This field is a base 64 VLQ relative to the previous occurrence of this field, unless this is the first occurrence of this field, in which case the whole value is represented. Always present if there is a source field.

All the implementations I've found start line numbers at 1. Am I reading the doc incorrectly or did I miss something?