Skip to content
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

Bug: stack trace line numbers are incorrect #5129

Closed
thisredone opened this issue Oct 31, 2018 · 7 comments
Closed

Bug: stack trace line numbers are incorrect #5129

thisredone opened this issue Oct 31, 2018 · 7 comments

Comments

@thisredone
Copy link

Expected Behavior

When running code with coffee line numbers in stack traces should be correct

Current Behavior

They're not

Context

This goes pretty far in history of CoffeeScript. I don't think they were ever correct in 2+

  • CoffeeScript version: 2.3.2
  • Same situation in Windows and Linux
  • Node.js version: 8.11.2 but others as well
@GeoffreyBooth
Copy link
Collaborator

Please provide a reproducible example.

@thisredone
Copy link
Author

I'm sorry, I thought this is a known problem. I write a ton of projects in coffeescript and it's the same story every time.
Currently I'm trying trivial examples but the stack traces are fine there.
After using the cson library and requiring empty config.cson file the line numbers get wrong

config = (require 'cson').requireFile('./config.cson')

class Foo
  error: ->
    throw new Error('bad thing')

(new Foo).error()
Error: bad thing
    at Foo.error \tmp\coffee-stack-trace-example\index.coffee:8:13)
    at Object.<anonymous> \tmp\coffee-stack-trace-example\index.coffee:13:13)
    at Object.<anonymous> \tmp\coffee-stack-trace-example\index.coffee:15:4)
    at Module._compile (module.js:652:30)
    at Object.CoffeeScript.run \tmp\coffee-stack-trace-example\node_modules\coffeescript\lib\coffeescript\index.js:67:23)
    at compileScript \tmp\coffee-stack-trace-example\node_modules\coffeescript\lib\coffeescript\command.js:265:29)
    at compilePath \tmp\coffee-stack-trace-example\node_modules\coffeescript\lib\coffeescript\command.js:220:14)
    at compilePath \tmp\coffee-stack-trace-example\node_modules\coffeescript\lib\coffeescript\command.js:181:9)
    at Object.exports.run \tmp\coffee-stack-trace-example\node_modules\coffeescript\lib\coffeescript\command.js:141:20)
    at Object.<anonymous> (\AppData\Local\Yarn\Data\global\node_modules\coffeescript\bin\coffee:22:45)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

@GeoffreyBooth
Copy link
Collaborator

Can you find an example that doesn’t involve another library?

@thisredone
Copy link
Author

I'm honestly not sure. Pretty much all code involves some libraries so is this really necessary? I might keep looking but it might take some time, Maybe tomorrow I'll find some

@GeoffreyBooth
Copy link
Collaborator

If I change the first line of your example to config = require './package.json' (where that file exists) I get a correct stack trace:

coffee ./test.coffee
Error: bad thing
    at Foo.error (~/Sites/coffeescript/test.coffee:5:11)
    at Object.<anonymous> (~/Sites/coffeescript/test.coffee:7:11)
    at Object.<anonymous> (~/Sites/coffeescript/test.coffee:1:1)

So clearly not every import causes this.

If you can produce a minimal test case, with either no library involved or a very minimal (like “hello world”) library that doesn’t have any complexity, I’ll reopen the ticket.

@Inve1951
Copy link
Contributor

Inve1951 commented Nov 5, 2018

I've too seen wrong locations in stack traces but can't come up with a concrete example at the moment.
Only thing I got in a quick attempt to reproduce was line numbers being off by 1 line #try on subsequent runs of the code, first run they appear to be correct.

@thisredone
Copy link
Author

thisredone commented Nov 5, 2018

Maybe having this issue closed isn't such a good idea after all? Either I'm living in a bubble; I am the only coffeescript coder in the world; or everyone else is affected by this as well so keeping this issue open could lead to some external help.
The burden of finding the exact conditions in which this problem shows up shouldn't lay on me alone, considering we know nothing about it and it's non-obvious and potentially time-consuming to figure out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants