Skip to content

Wrong line number reported on runtime error #953

Description

@pavel

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

Activity

  1. changed the title [-]Wrong line number reported on error[/-] [+]Wrong line number reported on runtime error[/+] on Mar 7, 2017
  2. rhendric commented on Mar 7, 2017

    @rhendric
    Collaborator

    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.

  3. added a commit that references this issue on Mar 8, 2017
    9d32954
  4. added a commit that references this issue on Mar 8, 2017
    3902c23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions