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

Source file info is scarce in AST line numbers #1636

Closed
toivoh opened this issue Nov 29, 2012 · 3 comments
Closed

Source file info is scarce in AST line numbers #1636

toivoh opened this issue Nov 29, 2012 · 3 comments

Comments

@toivoh
Copy link
Contributor

toivoh commented Nov 29, 2012

When I quote an AST in julia, almost no line numbers give the source file. Example:

julia> quote
           f(x) = x^2
               for x=1:3
                   println(x)
               end
           end
quote   #  line 2:
    f(x) = begin    #  none, line 2:
            ^(x, 2)
        end #  line 3:
    for x = 1:3 #  line 4:
        println(x)
    end
end

The only place I've found where the source file is given is for the first line inside a function body.
While that is easier on the eyes when looking at a quoted AST, it does complicate things for my debugger. I've tried to propagate source file info from a block into its nodes, but still

  • expressions outside any function don't get any source file info.
  • macro expansions paste code from quote blocks into other places, usually without any source file info, which will be very confusing.

Would it be possible to have this info present in more lines?
Most convenient for my purposes would be if every line included a source file along with the line number. I guess it would go a long way for me if source file info was included at the top line nodes of AST:s produced by quote blocks and used as macro arguments.

@JeffBezanson
Copy link
Member

I can do this, but it actually gets tricky since this does not map neatly to native debug info, which doesn't expect the source file to change on every line.

@toivoh
Copy link
Contributor Author

toivoh commented Nov 29, 2012

I see. But source files that change from function to function are ok, of course.
Is this data currently being passed to any native debugger?

Perhaps one option could be to include the source file everywhere to start with, and filter out unrepresentable changes when using the data to create native debug info? I realize that would mean some extra work on your part, but I'm not sure how I would avoid confusing people who step into macro expansions without this kind of thing.

@toivoh
Copy link
Contributor Author

toivoh commented Nov 30, 2012

Does this seem like a reasonable approach? If you point me in the right direction, I might be able to write the patch myself.

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

2 participants