On Thu, Jun 24, 2004 at 12:45:26PM -0400, Vsevolod (Simon) Ilyushchenko wrote:
> Hi, Hello, > I've run into "Can't call method "add_statement" on an undefined value" > running Devel::Cover. Apologies if this was reported before, but the > list archive is not searchable. I am using perl 5.8.4 and Devel::Cover 0.46. I think the list is archived in a number of places. I suppose the official archive is at http://www.nntp.perl.org/group/perl.qa/ And this is the first time that I've come across this bug, so thanks for reporting it. > To reproduce the bug, run > > /opt/perl/bin/perl -MDevel::Cover -MFooBar -e "FooBar->new->test_foo" > > The files FooBar.pm and CodeRef.pm are attached. > > The bug occurs while calling $sub in CodeRef::to_string. It is probably > related to using B::Deparse, but I was not able to minimize the code > further and still reproduce the error. Absolutely correct. I was able to reduce the code to: require B::Deparse; B::Deparse->new->coderef2text(sub {}) The problem occurs because Devel::Cover overrides some of B::Deparse's subs, but when you go calling them in a program it gets upset. The solution is to only override the subs for as long as is necessary. The change is in my development copy and will be in the next release. Thanks again for reporting the problem and producing a small test case. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net