Signature error for a bad signature doesn't show the file/line
Closed this issue · 3 comments
When a function has a syntactically incorrect signature, the error message fails to show the method, file and line.
use Method::Signatures;
func hello ($a, @b, $c) {
warn $a; warn join(",",@b); warn $c;
}
Use of uninitialized value $method in pattern match (m//) at lib/Method/Signatures/Parser.pm line 220.
Use of uninitialized value $method in pattern match (m//) at lib/Method/Signatures/Parser.pm line 220.
Use of uninitialized value $pack in pattern match (m//) at lib/Method/Signatures/Parser.pm line 220.
Use of uninitialized value $method in concatenation (.) or string at lib/Method/Signatures.pm line 1127.
Use of uninitialized value $file in concatenation (.) or string at lib/Method/Signatures.pm line 1127.
Use of uninitialized value $line in concatenation (.) or string at lib/Method/Signatures.pm line 1127.
In call to (), slurpy parameter @b must come at the end at line .
This is inside carp_location_for
which looks up the stack but at that point Perl is still compiling so the stack doesn't look like it does for a runtime error.
@ = Method::Signatures::Parser::carp_location_for('Method::Signatures') called from file `lib/Method/Signatures.pm' line 1126
. = Method::Signatures::signature_error(ref(Method::Signatures), 'slurpy parameter @b must come at the end') called from file `lib/Method/Signatures.pm' line 927
. = Method::Signatures::_check_signature(ref(Method::Signatures)) called from file `lib/Method/Signatures.pm' line 857
@ = Method::Signatures::parse_func(ref(Method::Signatures), 'proto', ref(ARRAY), 'signature', ref(HASH)) called from file `lib/Method/Signatures.pm' line 782
@ = Method::Signatures::parse_signature(ref(Method::Signatures), 'proto', '$a, @b, $c', 'invocant', undef, 'pre_invocant', undef) called from file `lib/Method/Signatures.pm' line 755
@ = Method::Signatures::parse_proto(ref(Method::Signatures), '$a, @b, $c') called from file `/Users/schwern/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-thread-multi-2level/Devel/Declare/MethodInstaller/Simple.pm' line 65
. = Devel::Declare::MethodInstaller::Simple::parser(ref(Method::Signatures), 'func', 0, 1) called from file `/Users/schwern/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-thread-multi-2level/Devel/Declare/MethodInstaller/Simple.pm' line 24
. = Devel::Declare::MethodInstaller::Simple::__ANON__[/Users/schwern/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-thread-multi-2level/Devel/Declare/MethodInstaller/Simple.pm:24]('func', 0) called from file `/Users/schwern/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-thread-multi-2level/Devel/Declare.pm' line 281
. = Devel::Declare::linestr_callback('const', 'func', 0) called from file `/Users/schwern/tmp/test.plx' line 4
The important bit is that the stack never gets out of Method::Signatures or Devel::Declare, all of which are correct to skip for a runtime error but not a compile time one. That last Devel::Declare::linestr_callback
has the file and line we want. It's up to us to put the proper package and method name in.
I think carp_location_for
needs to be split into runtime and compile time versions.
Do we already have a test for compile time signature errors?
That should fix that exact error. I'm going to see if there are any more compile-time errors that need to be switched over to the new function.
Okay, that should do it. Available in dev release 20121219.0033_001. I'll close this out once I promote to full release.
This is fixed in version 20130222.