Skip to content

Commit

Permalink
Merge pull request #2 from djerius/empty-signature
Browse files Browse the repository at this point in the history
optimize away empty signature; prevents syntax error on 5.10.1
  • Loading branch information
zmughal committed Sep 2, 2022
2 parents e4bae73 + 73b2054 commit 93728e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Babble/Plugin/CoreSignatures.pm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ sub transform_to_plain {
push @sig_text, $part;
}

my $sig_text = 'my ('.(join ', ', @sig_text).') = @_;';
my $sig_text =
@sig_text
? 'my ('.(join ', ', @sig_text).') = @_;'
: '';
my $code = join ' ', $sig_text, @defaults;
$s->{body}->transform_text(sub { s/^{/{ ${code}/ });
if ($proto) {
Expand Down
6 changes: 6 additions & 0 deletions t/plugin-coresignatures.t
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,16 @@ my @cand = (
'sub foo ($) { my ($sig) = @_; }', ],
[ 'sub foo :Foo :prototype($) ($sig) { }',
'sub foo ($) :Foo { my ($sig) = @_; }', ],

[ 'sub foo : Foo prototype($) ($sig) { }',
'sub foo ($) : Foo { my ($sig) = @_; }', ],
[ 'sub foo :prototype($) Foo ($sig) { }',
'sub foo ($) :Foo { my ($sig) = @_; }', ],

[ 'sub foo : Foo prototype($) () { }',
'sub foo ($) : Foo { }', ],
[ 'sub foo :prototype($) Foo () { }',
'sub foo ($) :Foo { }', ],
[ 'use Mojo::Base -base, -signatures;',
'use Mojo::Base qw(-base);' ],
[ 'use Mojo::Base -signatures;',
Expand Down

0 comments on commit 93728e9

Please sign in to comment.