New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong line number reported on runtime error #953

Closed
pavel opened this Issue Mar 7, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@pavel

pavel commented Mar 7, 2017

Having a following index.ls file:

for i from 0 to 2
	console.log 'Hello', ind

When running it with:

lsc index.ls

I get the following error:

Failed at: index.ls
ReferenceError: ind is not defined
    at Object.<anonymous> (/tmp/livescript-test/index.ls:5:24)
1| // Generated by LiveScript 1.5.0
2| var i$, i;
3| for (i$ = 0; i$ <= 2; ++i$) {
4|   i = i$;
5+   console.log('Hello', ind);
6| }
7| 
8| 
9| 
    at Module._compile (module.js:571:32)
    at Object.LiveScript.run (/tmp/livescript-test/node_modules/livescript/lib/node.js:31:19)
    at compileScript (/tmp/livescript-test/node_modules/livescript/lib/command.js:222:31)
    at /tmp/livescript-test/node_modules/livescript/lib/command.js:152:11
    at /tmp/livescript-test/node_modules/livescript/lib/command.js:142:7
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:416:3)

The problem is that line number 5 reported in error log for index.ls is incorrect in scope of index.ls file. In this example I get a full compiled version as (probably) the demo is short. But when working with bigger files, I do not get a full compiled version, so it becomes difficult to track errors.

I tried to use sourcemaps by running:

lsc -m embedded index.ls

the result is still the same.

Is there a way to make errors show on correct lines in scope of ls files?


OS: Linux
Node.js: 7.5.0
LiveScript: 1.5.0

@pavel pavel changed the title from Wrong line number reported on error to Wrong line number reported on runtime error Mar 7, 2017

@rhendric

This comment has been minimized.

Collaborator

rhendric commented Mar 7, 2017

One thing you could do right now is compile index.ls (with -m embedded, as you discovered) instead of running it directly from lsc, and when you run it, run it with node -r source-map-support/register index.js (after pulling down source-map-support from npm).

I don't have the time right this second to try integrating this functionality into the lsc command when running scripts directly, but it shouldn't be that hard if someone else wanted to try it.

@gkz gkz closed this in 9d32954 Mar 8, 2017

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