First off, sorry I didn't get to this sooner--I had some job-related drama to deal with.
Show quoted text> method foo($bar = ')') {} doesn't work.
>
> I don't have a perl handy now where I can load and test this to give
> more information, sorry.
Okay, I see the problem. This is, it turns out, the same problem that (unbalanced) close parends in comments have, but unfortunately I don't see a good way to fix it.
Once we get the prototype, we parse it with PPI, which would properly handle this. But that close parend is fooling the thing that hands us the prototype in the first place. That thing is several layers below us, specifically in Devel::Declare. It uses XS, and specifically `scan_str`, to find the matching close parend for the prototype's open parend. So while properly nested parends pose it no issues, parends inside quotes really freak it out. Unless they're balanced, of course.
Being not that familiar with the Perl internals, I'm not sure why `scan_str` doesn't have a way to skip embedded quoted strings. From some quick Googling, it looks like its only options are to retain the escape char on embedded-but-escaped parends, and to retain the outer delimiters. Nothing about looking out for quoted strings.
On the upside, this actually works:
func foo ($bar = '\)')
{
say $bar;
}
So it's not entirely impossible to achieve the desired effect.
I think the best we can hope for here is to document the undesireable behavior and hope people read it. I'll work up a doco patch.