Skip Menu |

This queue is for tickets about the Method-Signatures CPAN distribution.

Report information
The Basics
Id: 81368
Status: open
Priority: 0/
Queue: Method-Signatures

People
Owner: Nobody in particular
Requestors: MAUKE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 20120523
Fixed in: (no value)



Subject: miscellaneous parsing bugs
$ cat parse1 #!perl use Method::Signatures; my $f = func () {} 1; __END__ $ perl -MO=Deparse parse1 Too many arguments for main::func at parse1 line 4, near "1;" parse1 had compilation errors. use Method::Signatures; BEGIN { $^H{'Devel::Pragma'} = '1'; $^H{'METHOD_SIGNATURES_compile_at_BEGIN'} = '1'; } my $f = &func(sub { 'Method::Signatures'->too_many_args_error(0) if @_ > 0; } , 1); __DATA__ This should be a syntax error. $ cat parse2 #!perl use Method::Signatures; my $f = func () {} ? 'ok' : 'not ok'; __END__ $ perl -MO=Deparse parse2 Use of ?PATTERN? without explicit operator is deprecated at parse2 line 4. Search pattern not terminated or ternary operator parsed as search pattern at parse2 line 4. use Method::Signatures; This should not be a syntax error. Bonus problem: $ perl parse2 Use of ?PATTERN? without explicit operator is deprecated at parse2 line 4. Search pattern not terminated or ternary operator parsed as search pattern at parse2 line 4. *** glibc detected *** perl: double free or corruption (fasttop): 0x08fc6268 *** ======= Backtrace: ========= /lib/i686/cmov/libc.so.6(+0x6af71)[0xb763df71] /lib/i686/cmov/libc.so.6(+0x6c7c8)[0xb763f7c8] /lib/i686/cmov/libc.so.6(cfree+0x6d)[0xb76428ad] perl(Perl_op_free+0xa3)[0x8063513] ======= Memory map: ======== 08048000-0818c000 r-xp 00000000 08:01 9979965 /home/mauke/usr/bin/perl 0818c000-0818f000 rw-p 00144000 08:01 9979965 /home/mauke/usr/bin/perl 08fab000-09193000 rw-p 00000000 00:00 0 [heap] b7100000-b7121000 rw-p 00000000 00:00 0 b7121000-b7200000 ---p 00000000 00:00 0 b723a000-b7253000 r-xp 00000000 08:01 9978052 /home/mauke/usr/lib/libgcc_s.so.1 b7253000-b7254000 rw-p 00019000 08:01 9978052 /home/mauke/usr/lib/libgcc_s.so.1 b7254000-b7257000 r-xp 00000000 08:01 11288579 /home/mauke/usr/lib/perl5/site_perl/5.16.2/i686-linux/auto/Devel/Pragma/Pragma.so b7257000-b7258000 rw-p 00002000 08:01 11288579 /home/mauke/usr/lib/perl5/site_perl/5.16.2/i686-linux/auto/Devel/Pragma/Pragma.so b7258000-b725a000 r-xp 00000000 08:01 11272210 /home/mauke/usr/lib/perl5/site_perl/5.16.2/i686-linux/auto/B/Hooks/OP/Annotation/Annotation.so b725a000-b725b000 rw-p 00001000 08:01 11272210 /home/mauke/usr/lib/perl5/site_perl/5.16.2/i686-linux/auto/B/Hooks/OP/Annotation/Annotation.so b725b000-b7265000 r-xp 00000000 08:01 11264610 /home/mauke/usr/lib/perl5/site_perl/5.16.2/i686-linux/auto/Data/Alias/Alias.so b7265000-b7266000 rw-p 00009000 08:01 11264610 /home/mauke/usr/lib/perl5/site_perl/5.16.2/i686-linux/auto/Data/Alias/Alias.so b7266000-b7268000 r-xp 00000000 08:01 10527226 /home/mauke/usr/lib/perl5/site_perl/5.16.1/i686-linux/auto/Sub/Name/Name.so b7268000-b7269000 rw-p 00001000 08:01 10527226 /home/mauke/usr/lib/perl5/site_perl/5.16.1/i686-linux/auto/Sub/Name/Name.so b7269000-b726c000 r-xp 00000000 08:01 10520143 /home/mauke/usr/lib/perl5/site_perl/5.16.1/i686-linux/auto/Params/Util/Util.so b726c000-b726d000 rw-p 00002000 08:01 10520143 /home/mauke/usr/lib/perl5/site_perl/5.16.1/i686-linux/auto/Params/Util/Util.so b726d000-b7273000 r-xp 00000000 08:01 11102281 /home/mauke/usr/lib/perl5/site_perl/5.16.1/i686-linux/auto/Variable/Magic/Magic.so b7273000-b7274000 rw-p 00005000 08:01 11102281 /home/mauke/usr/lib/perl5/site_perl/5.16.1/i686-linux/auto/Variable/Magic/Magic.so b7274000-b73d1000 r--p 001ec000 08:01 6710223 /usr/lib/locale/locale-archive b73d1000-b75d1000 r--p 00000000 08:01 6710223 /usr/lib/locale/locale-archive b75d1000-b75d3000 rw-p 00000000 00:00 0 b75d3000-b7713000 r-xp 00000000 08:01 4923415 /lib/i686/cmov/libc-2.11.3.so b7713000-b7714000 ---p 00140000 08:01 4923415 /lib/i686/cmov/libc-2.11.3.so b7714000-b7716000 r--p 00140000 08:01 4923415 /lib/i686/cmov/libc-2.11.3.so b7716000-b7717000 rw-p 00142000 08:01 4923415 /lib/i686/cmov/libc-2.11.3.so b7717000-b771a000 rw-p 00000000 00:00 0 b771a000-b771c000 r-xp 00000000 08:01 4923406 /lib/i686/cmov/libutil-2.11.3.so b771c000-b771d000 r--p 00001000 08:01 4923406 /lib/i686/cmov/libutil-2.11.3.so b771d000-b771e000 rw-p 00002000 08:01 4923406 /lib/i686/cmov/libutil-2.11.3.so b771e000-b7727000 r-xp 00000000 08:01 4923400 /lib/i686/cmov/libcrypt-2.11.3.so b7727000-b7728000 r--p 00008000 08:01 4923400 /lib/i686/cmov/libcrypt-2.11.3.so b7728000-b7729000 rw-p 00009000 08:01 4923400 /lib/i686/cmov/libcrypt-2.11.3.so b7729000-b7750000 rw-p 00000000 00:00 0 b7750000-b7774000 r-xp 00000000 08:01 4923397 /lib/i686/cmov/libm-2.11.3.so b7774000-b7775000 r--p 00023000 08:01 4923397 /lib/i686/cmov/libm-2.11.3.so b7775000-b7776000 rw-p 00024000 08:01 4923397 /lib/i686/cmov/libm-2.11.3.so b7776000-b7777000 rw-p 00000000 00:00 0 b7777000-b7779000 r-xp 00000000 08:01 4923396 /lib/i686/cmov/libdl-2.11.3.so b7779000-b777a000 r--p 00001000 08:01 4923396 /lib/i686/cmov/libdl-2.11.3.so b777a000-b777b000 rw-p 00002000 08:01 4923396 /lib/i686/cmov/libdl-2.11.3.so b777b000-b778e000 r-xp 00000000 08:01 4923399 /lib/i686/cmov/libnsl-2.11.3.so b778e000-b778f000 r--p 00012000 08:01 4923399 /lib/i686/cmov/libnsl-2.11.3.so b778f000-b7790000 rw-p 00013000 08:01 4923399 /lib/i686/cmov/libnsl-2.11.3.so b7790000-b7792000 rw-p 00000000 00:00 0 b7794000-b779b000 r-xp 00000000 08:01 11109083 /home/mauke/usr/lib/perl5/site_perl/5.16.1/i686-linux/auto/Devel/Declare/Declare.so b779b000-b779c000 rw-p 00006000 08:01 11109083 /home/mauke/usr/lib/perl5/site_perl/5.16.1/i686-linux/auto/Devel/Declare/Declare.so b779c000-b779d000 r-xp 00000000 08:01 10453002 /home/mauke/usr/lib/perl5/site_perl/5.16.1/i686-linux/auto/B/Hooks/OP/Check/Check.so b779d000-b779e000 rw-p 00001000 08:01 10453002 /home/mauke/usr/lib/perl5/site_perl/5.16.1/i686-linux/auto/B/Hooks/OP/Check/Check.so b779e000-b77a3000 r-xp 00000000 08:01 11223554 /home/mauke/usr/lib/perl5/5.16.2/i686-linux/auto/List/Util/Util.so b77a3000-b77a4000 rw-p 00004000 08:01 11223554 /home/mauke/usr/lib/perl5/5.16.2/i686-linux/auto/List/Util/Util.so b77a4000-b77a6000 rw-p 00000000 00:00 0 b77a6000-b77a7000 r-xp 00000000 00:00 0 [vdso] b77a7000-b77c2000 r-xp 00000000 08:01 4907447 /lib/ld-2.11.3.so b77c2000-b77c3000 r--p 0001b000 08:01 4907447 /lib/ld-2.11.3.so b77c3000-b77c4000 rw-p 0001c000 08:01 4907447 /lib/ld-2.11.3.so bfa05000-bfa1a000 rw-p 00000000 00:00 0 [stack] Aborted
Subject: Re: [rt.cpan.org #81368] miscellaneous parsing bugs
Date: Fri, 23 Nov 2012 16:44:16 -0800
To: bug-Method-Signatures [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
On 2012.11.23 1:13 AM, Lukas Mai via RT wrote: Show quoted text
> $ cat parse1 > #!perl > use Method::Signatures; > > my $f = func () {} 1; > __END__ > $ perl -MO=Deparse parse1 > Too many arguments for main::func at parse1 line 4, near "1;" > parse1 had compilation errors. > use Method::Signatures; > BEGIN { > $^H{'Devel::Pragma'} = '1'; > $^H{'METHOD_SIGNATURES_compile_at_BEGIN'} = '1'; > } > my $f = &func(sub { > 'Method::Signatures'->too_many_args_error(0) if @_ > 0; > } > , 1); > __DATA__ > > This should be a syntax error.
That's a tough one and it has to do with the limits of our ability to rewrite the code. We can't get rid of the "func" part which means it compiles to this: sub func (&) { return $_[0] } my $f = func {Method::Signatures->too_many_args_error(0) if @_ > 0; } 1; We could compile it to this: sub func (&) { return $_[0] } my $f = func sub {Method::Signatures->too_many_args_error(0) if @_ > 0; } 1; But unfortunately that breaks Perl's parsing of things like this. my $a = [ func () {}, 1 ]; $ perl -wle 'sub func(&) { return $_[0] } $a = [ func {}, 1 ]; print $a->[0]' CODE(0x10082e440) $ perl -wle 'sub func(&) { return $_[0] } $a = [ func sub {}, 1 ]; print $a->[0]' Too many arguments for main::func at -e line 1, near "1 ]" Execution of -e aborted due to compilation errors. See t/larna.t for the relevant tests. So we're kinda stuck. The important thing is its a compile time error. Show quoted text
> $ cat parse2 > #!perl > use Method::Signatures; > > my $f = func () {} ? 'ok' : 'not ok'; > __END__ > $ perl -MO=Deparse parse2 > Use of ?PATTERN? without explicit operator is deprecated at parse2 line 4. > Search pattern not terminated or ternary operator parsed as search > pattern at parse2 line 4. > use Method::Signatures; > > This should not be a syntax error. Bonus problem:
Yeah, that's related to how perl is parsing sub func (&) { return $_[0] } my $f = func {} ? 'ok' : 'not ok'; The only thing which works is this: sub func (&) { return $_[0] } my $f = func( sub {} ) ? 'ok' : 'not ok'; Which would probably work, and not trip the larna.t tests, but it requires more coordination. inject_if_block() would add "( sub" before and Devel::Declare::Context::Simple->inject_scope would be overridden to add ")" at the end but only for anonymous routines. Show quoted text
> $ perl parse2 > Use of ?PATTERN? without explicit operator is deprecated at parse2 line 4. > Search pattern not terminated or ternary operator parsed as search > pattern at parse2 line 4. > *** glibc detected *** perl: double free or corruption (fasttop): > 0x08fc6268 ***
Not even touching it. -- 164. There is no such thing as a were-virgin. -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army http://skippyslist.com/list/