moonscript icon indicating copy to clipboard operation
moonscript copied to clipboard

Feature: keep line number when compiling

Open buckle2000 opened this issue 8 years ago • 10 comments
trafficstars

Since lua is whitespace-insentitive, why not just squeeze code together? Probably working fork

Will close #311.

buckle2000 avatar Dec 09 '16 13:12 buckle2000

What we can do further is to trimmer unnecessary spaces. There is also a bug about multi-line strings, please refer to BUG in the code.

buckle2000 avatar Dec 09 '16 13:12 buckle2000

I think people prefer to have readable code than compressed code. If we were going to compress the code, then we might as well compress it as much as possible.

What's the use case for trying to keep the line numbers? Having stack trace errors that work without rewriting?

leafo avatar Dec 09 '16 18:12 leafo

Exactly. Current version cannot rewrite traceback in luajit correctly, in my case, love2d.

buckle2000 avatar Dec 10 '16 00:12 buckle2000

Usually it's not hard to work out the trace from the Lua back to MoonScript.. that said, it would be nice if error messages were more traceable.. but I also like having fairly readable output.

Perhaps a command-line switch to compile in a mode that preserves line numbers? @buckle2000 This might not do what you want though. Sometimes errors in the output Lua aren't so easily traced, and doing things this way would actually make it more difficult to trace because of the loss in readability...

TangentFoxy avatar Dec 11 '16 20:12 TangentFoxy

You are right. It is not hard to find corresponding moonscript from Lua but it's annoying since most bugs are caused by writing mistakes, not logical mistakes, missing comma for example. Given the line number, these bugs can be easily fixed.

buckle2000 avatar Dec 11 '16 23:12 buckle2000

As an FYI, I have been using buckle's branch and having the correct lines in development so far has been really helpful!

ThaisRobba avatar Sep 28 '17 02:09 ThaisRobba

@OttoRobba Thanks for your proof of concept!

buckle2000 avatar Sep 28 '17 12:09 buckle2000

@leafo Is it possible to display correct error messages when using moonscript and love2d? Having to read compiled lua code to debug is not fun at all.

sherjilozair avatar Jun 17 '18 21:06 sherjilozair

@sherjilozair Have a look how it is done there: https://github.com/fendrin/wesnoth-love/blob/master/shared/run_moon.moon

fendrin avatar Jun 19 '18 13:06 fendrin

Is there any chance of this ever being merged? It'd make debugging errors far easier as often I find myself with an error on a line that doesn't even exist in the source.

ChildishGiant avatar Aug 30 '21 23:08 ChildishGiant