gkz / LiveScript

LiveScript is a language which compiles to JavaScript. It has a straightforward mapping to JavaScript and allows you to write expressive code devoid of repetitive boilerplate. While LiveScript adds many features to assist in functional style programming, it also has many improvements for object oriented and imperative programming.
http://livescript.net
MIT License
2.31k stars 156 forks source link

Stack trace wrong line number in REPL mode #1095

Open anhnhoktvn opened 4 years ago

anhnhoktvn commented 4 years ago

Hello, I found this bug:

With simple file like this: File: test.ls

throw Error \line_1

Normally I get this error:

$ lsc test.ls 
Failed at: test.ls
Error: line_1
    at Object.<anonymous> (/home/anhnhoktvn/test.ls:1:7)

In REPL mode it would return wrong line number:

ls> require \./test
/home/anhnhoktvn/.nvm/versions/node/v13.11.0/pnpm-global/3/node_modules/.pnpm/registry.npmjs.org/livescript/1.6.0/node_modules/livescript/lib/node.js:57
      throw hackTrace(e, js, filename);
      ^

Error: line_1
    at Object.<anonymous> (/home/anhnhoktvn/test.ls:2:7)
1| // Generated by LiveScript 1.6.0
2+ throw Error('line_1');
3| //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QubHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQU0sS0FBTixDQUFZLFFBQUEsQ0FBWiIsInNvdXJjZXNDb250ZW50IjpbbnVsbF19
4| 

I expect it shows error at line 1 but in this case it shows line 2. The source map seems not work in repl mode.