-
Notifications
You must be signed in to change notification settings - Fork 193
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: Line maps / tracebacks incorrect for this moonscript code #127
Comments
Just an aside, you can use You can see the problematic remapping:
|
Thanks leafo, I was unaware of that. Is this is a difficult problem to fix? |
Hi leafo, do you have an idea what the problem might be? |
Sorry, didn't get a chance to look into it yet. |
The bug seems to be in compile.moon, line 46. 41 flatten_posmap: (line_no=0, out={}) =>
42 posmap = @posmap
43 for i, l in ipairs @
44 switch mtype l
45 when "string", DelayedLine
46 line_no += 1 --> not always correct
47 out[line_no] = posmap[i]
48 when Lines
49 _, line_no = l\flatten_posmap line_no, out
50 else
51 error "Unknown item in Lines: #{l}"
52
53 out, line_no
|
I managed to create a somewhat minimal repro, but the behavior is extremely odd and fragile to changes. The rewritten traceback line numbers for moon code are wrong sometimes. Here's the code. Delete one of the lines containing numbers and the line numbers are suddenly accurate. Add more and the line numbers change strangely.
I get the following, which should be 23, not 3. If I add one more line with the number 10 it changes to 5 (should be 24). Add numbers up to 25 and the line number changes to the call to bar (41). For 24 it's still 5.
moon: repro_spec.moon:3: (19) attempt to index global 'opts' (a nil value)
stack traceback:
repro_spec.moon:3: (19) in function '__init'
repro_spec.moon:25: (37) in function 'bar'
repro_spec.moon:25: (44) in main chunk
The text was updated successfully, but these errors were encountered: