Skip Menu |

This queue is for tickets about the XS-Parse-Sublike CPAN distribution.

Report information
The Basics
Id: 132284
Status: resolved
Priority: 0/
Queue: XS-Parse-Sublike

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

Bug Information
Severity: (no value)
Broken in: 0.06
Fixed in: 0.07



Subject: Fails with perl 5.31.3 and later
There are compilation errors which happen for bleadperl since 5.31.3: ... # Failed test 'use Tickit::Widget::FloatBox;' # at t/00use.t line 8. # Tried to use 'Tickit::Widget::FloatBox'. # Error: syntax error at /home/cpansand/.cpan/build/2020040123/Tickit-Widget-FloatBox-0.05-5/blib/lib/Tickit/Widget/FloatBox.pm line 79, near "method children ()" # Global symbol "$self" requires explicit package name (did you forget to declare "my $self"?) at /home/cpansand/.cpan/build/2020040123/Tickit-Widget-FloatBox-0.05-5/blib/lib/Tickit/Widget/FloatBox.pm line 83. # Global symbol "$self" requires explicit package name (did you forget to declare "my $self"?) at /home/cpansand/.cpan/build/2020040123/Tickit-Widget-FloatBox-0.05-5/blib/lib/Tickit/Widget/FloatBox.pm line 83. # Global symbol "@_floats" requires explicit package name (did you forget to declare "my @_floats"?) at /home/cpansand/.cpan/build/2020040123/Tickit-Widget-FloatBox-0.05-5/blib/lib/Tickit/Widget/FloatBox.pm line 84. # syntax error at /home/cpansand/.cpan/build/2020040123/Tickit-Widget-FloatBox-0.05-5/blib/lib/Tickit/Widget/FloatBox.pm line 89, near "method lines ()" # Global symbol "$self" requires explicit package name (did you forget to declare "my $self"?) at /home/cpansand/.cpan/build/2020040123/Tickit-Widget-FloatBox-0.05-5/blib/lib/Tickit/Widget/FloatBox.pm line 91. # Global symbol "$self" requires explicit package name (did you forget to declare "my $self"?) at /home/cpansand/.cpan/build/2020040123/Tickit-Widget-FloatBox-0.05-5/blib/lib/Tickit/Widget/FloatBox.pm line 91. ... (etc) ... Same failures happen also with PEVANS/Tickit-Widget-ScrollBox-0.08.tar.gz
On 2020-04-02 01:59:44, SREZIC wrote: Show quoted text
> There are compilation errors which happen for bleadperl since 5.31.3: > > ... > # Failed test 'use Tickit::Widget::FloatBox;' > # at t/00use.t line 8. > # Tried to use 'Tickit::Widget::FloatBox'. > # Error: syntax error at > /home/cpansand/.cpan/build/2020040123/Tickit-Widget-FloatBox-0.05- > 5/blib/lib/Tickit/Widget/FloatBox.pm line 79, near "method children > ()" > # Global symbol "$self" requires explicit package name (did you forget > to declare "my $self"?) at > /home/cpansand/.cpan/build/2020040123/Tickit-Widget-FloatBox-0.05- > 5/blib/lib/Tickit/Widget/FloatBox.pm line 83. > # Global symbol "$self" requires explicit package name (did you forget > to declare "my $self"?) at > /home/cpansand/.cpan/build/2020040123/Tickit-Widget-FloatBox-0.05- > 5/blib/lib/Tickit/Widget/FloatBox.pm line 83. > # Global symbol "@_floats" requires explicit package name (did you > forget to declare "my @_floats"?) at > /home/cpansand/.cpan/build/2020040123/Tickit-Widget-FloatBox-0.05- > 5/blib/lib/Tickit/Widget/FloatBox.pm line 84. > # syntax error at /home/cpansand/.cpan/build/2020040123/Tickit-Widget- > FloatBox-0.05-5/blib/lib/Tickit/Widget/FloatBox.pm line 89, near > "method lines ()" > # Global symbol "$self" requires explicit package name (did you forget > to declare "my $self"?) at > /home/cpansand/.cpan/build/2020040123/Tickit-Widget-FloatBox-0.05- > 5/blib/lib/Tickit/Widget/FloatBox.pm line 91. > # Global symbol "$self" requires explicit package name (did you forget > to declare "my $self"?) at > /home/cpansand/.cpan/build/2020040123/Tickit-Widget-FloatBox-0.05- > 5/blib/lib/Tickit/Widget/FloatBox.pm line 91. > ... (etc) ... > > Same failures happen also with PEVANS/Tickit-Widget-ScrollBox- > 0.08.tar.gz
Sample full reports: * http://www.cpantesters.org/cpan/report/babefaee-74a5-11ea-959b-072e1f24ea8f * http://www.cpantesters.org/cpan/report/bc24e434-74a5-11ea-959b-072e1f24ea8f
This appears to be a failure of core's parse_subsignature() to correctly handle empty parens. On earlier perls we don't have access to core's function so the embedded emulation is used, which handles this situation correctly. This *might* be a core bug, or might just be me using the core function incorrectly. Initial test case attached. -- Paul Evans
Subject: rt132284-test.patch
=== modified file 't/02func-signatures.t' --- old/t/02func-signatures.t 2020-03-26 23:07:51 +0000 +++ new/t/02func-signatures.t 2020-04-02 12:47:32 +0000 @@ -50,6 +50,11 @@ } is( has_whitespace( "value" ), "value", 'func with whitespace in signature' ); + + # RT132284 + func noparams() { return "constant" } + + is( noparams, "constant", 'func with no params' ); } # RT131571
Further investigation going on upstream at: https://github.com/Perl/perl5/issues/17689 -- Paul Evans
On Thu Apr 02 10:15:56 2020, PEVANS wrote: Show quoted text
> Further investigation going on upstream at: > > https://github.com/Perl/perl5/issues/17689
The core issue remains, but at least here is a workaround + test for it. -- Paul Evans
Subject: rt132284.patch
=== modified file 'Build.PL' --- old/Build.PL 2020-03-18 14:12:04 +0000 +++ new/Build.PL 2020-04-02 15:53:23 +0000 @@ -11,6 +11,7 @@ # Not actually needed but used by hax/lexer-additions.c.inc }, test_requires => { + 'Test::Fatal' => 0, 'Test::More' => '0.88', # done_testing }, configure_requires => { === modified file 'hax/parse_subsignature.c.inc' --- old/hax/parse_subsignature.c.inc 2020-03-26 23:07:51 +0000 +++ new/hax/parse_subsignature.c.inc 2020-04-02 15:53:23 +0000 @@ -192,11 +192,6 @@ } endofelems: - if(!elems) { - LEAVE; - return NULL; - } - if (!FEATURE_SIGNATURES_IS_ENABLED) croak("Experimental subroutine signatures not enabled"); === modified file 'lib/XS/Parse/Sublike.xs' --- old/lib/XS/Parse/Sublike.xs 2020-03-27 22:05:27 +0000 +++ new/lib/XS/Parse/Sublike.xs 2020-04-02 15:53:23 +0000 @@ -71,13 +71,33 @@ OP *sigop = NULL; if(lex_peek_unichar(0) == '(') { lex_read_unichar(0); - - sigop = parse_subsignature(0); lex_read_space(0); - if(PL_parser->error_count) { - LEAVE_with_name("parse_block"); - return 0; +#if HAVE_PERL_VERSION(5, 31, 3) + /* core's parse_subsignature doesn't seem able to handle empty sigs + * RT132284 + * https://github.com/Perl/perl5/issues/17689 + */ + if(lex_peek_unichar(0) == ')') { + /* Inject an empty OP_ARGCHECK much as core would do if it encountered + * an empty signature */ + UNOP_AUX_item *aux = (UNOP_AUX_item *)PerlMemShared_malloc(sizeof(UNOP_AUX_item) * 3); + aux[0].iv = 0; + aux[1].iv = 0; + aux[2].iv = 0; + + sigop = op_prepend_elem(OP_LINESEQ, newSTATEOP(0, NULL, NULL), + newUNOP_AUX(OP_ARGCHECK, 0, NULL, aux)); + } + else +#endif + { + sigop = parse_subsignature(0); + + if(PL_parser->error_count) { + LEAVE_with_name("parse_block"); + return 0; + } } if(lex_peek_unichar(0) != ')') === modified file 't/02func-signatures.t' --- old/t/02func-signatures.t 2020-03-26 23:07:51 +0000 +++ new/t/02func-signatures.t 2020-04-02 15:53:23 +0000 @@ -7,6 +7,7 @@ BEGIN { $] >= 5.026000 or plan skip_all => "No parse_subsignature()"; } +use Test::Fatal; use feature 'signatures'; no warnings 'experimental'; @@ -50,6 +51,14 @@ } is( has_whitespace( "value" ), "value", 'func with whitespace in signature' ); + + # RT132284 + func noparams() { return "constant" } + + is( noparams, "constant", 'func with no params' ); + like( exception { noparams( 1, 2, 3 ) }, + qr/^Too many arguments for subroutine 'main::noparams' at /, + 'Exception thrown from empty signature validation failure' ); } # RT131571
Object::Pad 0.07 has a workaround for this issue. The underlying core issue remains - tracked in https://github.com/Perl/perl5/issues/17689 - but the workaround here should at least avoid it for now. -- Paul Evans