-
Notifications
You must be signed in to change notification settings - Fork 35
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
Line numbers offset when signature has spaces in it #104
Comments
I'm going to fix this and then would like to make a release if the alpha is going ok. |
Checking back through the releases, this bug has always been there. I guess it's only now that signatures have gotten more complex that there's been a widespread need for multi-line signatures. |
I'm weighing two solutions to the problem.
I believe the first is necessary. Why? Consider the following associated bug.
In addition to throwing off all the line numbers after the signature, the call to Reproducing the newlines will also dodge the perpetual problem of overflowing Devel::Declare's line buffer. |
It turns out Not sure how to implement this on one line. This also means defaults which span more than one line don't work. |
This is essentially a duplicate of RT/87544. Although I seem not to have gone back and added a comment there with my results (bad barefootcoder), my recollection was that I traced the issue back to DD using But it's been a while since I looked at it. I definitely never got as far as trying to stick newlines into the generated code. But if you figured out a way around the above and know how many newlines you need to stick in, can't you just call |
I believe It's right in the DD documentation that newlines are no good.
The |
Stack Overflow figured it out!
The parser can be tricked into continuing past a newline if it's inside a function call argument list. |
Okay, so remember how, above, I said:
I still believe this is the case. The solution that you (@schwern) and @tobyink have come up with is freakin' brilliant, don't get me wrong. But it's limited. You're putting back all the newlines that you know about. Which equates to "all the newlines in the signature itself" (i.e., between the parends). This doesn't help if the extranneous newlines are between the new keyword and the open parend, or (my personal favorite) between the close parend and the open curly brace. I've cooked up a gist which you can use the see the problem more clearly. Out of those 7 examples, this pull request is only going to fix one of them (the first one). Which is still a huge improvement over what we had before. But not sufficient to call this issue closed, I don't think. We finally know what to do once we figure out how many newlines there are--I never even got this far, personally. So I'm pretty stoked at this progress. But we still don't konw how to figure out how many newlines there are. I think (I'm pretty sure) this would require a patch to DD itself. Which is not a bad thing, certainly: every module based on DD (e.g. MooseX::Declare, TryCatch) has this exact problem, and they would all benefit from such a patch, in combination with this very creative solution. I've just never had time to dig into the DD guts and figure out how/where to do that. And then there's the question of whether a patch would even get accepted; ether is extremely fond of telling me that mst has declared DD to be a "big bag of crack" and everyone should stop using it now. And ether, as you may or may not know, is the current maintainer of DD. But maybe I could talk her into it, if one of us can scrap up the tuits to actually figure out how to do it. My inclination is to add my proposed Meanwhile I'll go ahead and send this pull request (and the others recently merged) up to PAUSE as a new dev version. |
I would recommend closing this issue and opening ones for each of the I agree with Ether that DD is a big bag of crack, but it's the least |
When the signature is not all on one line, the line numbers will be offset.
Method::Signatures always acts like the signature is on one line.
The text was updated successfully, but these errors were encountered: