Skip to content

Bug: Line maps / tracebacks incorrect for this moonscript code #127

Open
@eloff

Description

@eloff

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.

class bar
    new: (opts={}) =>
        @qux or= opts.qux

        @umm!

    huh: =>
        {
            bar: [[
                1
                2
                3
                4
                5
                6
                7
                8
                9
            ]]
        }

    umm: =>
        @foo = opts.foo

bar!

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

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