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

methods(foo) line numbers are off by 1 #4971

Closed
stevengj opened this issue Nov 28, 2013 · 4 comments
Closed

methods(foo) line numbers are off by 1 #4971

stevengj opened this issue Nov 28, 2013 · 4 comments

Comments

@stevengj
Copy link
Member

The line numbers in m.func.code.line for m::Method, which are e.g. the line numbers printed by methods(foo), seem to be off by 1 for functions defined with function foo(...) ... end. (The line number is the number of the first line in the body, rather than the function line.)

I noticed this in implementing #4952.

@JeffBezanson
Copy link
Member

This is a bit subjective. I did it this way since for debugging you want the numbers of the lines corresponding to executing code. To fix this, every function would need two starting line numbers; one for the signature and one for the first executing line. This isn't needed to disambiguate which function is referred to, so I picked the economical option.

@JeffBezanson
Copy link
Member

also dup of #1419.

@StefanKarpinski
Copy link
Member

I dunno, this seems pretty annoying to me. Linking to the first line of a method definition instead of its signature seems pretty broken, and so does making people actually parse the file that's being linked to to figure out where the function actually begins. Especially if we're going to be doing the linking from a web browser, where that's just basically not going to happen. It would be even nicer if methods gave the full range of lines on which the method is defined. That way we could use GitHub's ability to link to a range of lines in a file to link to exactly the right thing.

@lucasb-eyer
Copy link
Contributor

My 2¢: I've wanted to open an issue about this behaviour since quite some time, and now stumbled upon this. I've always thought it was a bug.

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

4 participants