-
Notifications
You must be signed in to change notification settings - Fork 594
Open
Labels
Description
Tested by running
perl -MB::Deparse -E 'say B::Deparse->new->coderef2text( sub ($x, $y) { return $x + $y } )
across various Perl versions. Up until 5.34, it yields the expected result, having a signature in the rendered output:
--- perl5.16.3 ---
($x,$y) {
use feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval';
return $x + $y;
}
--- perl5.18.4 ---
($x,$y) {
use feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval';
return $x + $y;
}
...
--- perl5.34.3 ---
($x, $y) {
use feature 'current_sub', 'bitwise', 'evalbytes', 'fc', 'postderef_qq', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval';
return $x + $y;
}
Thereafter, since 5.36, it no longer renders signature output, instead unpacking the code into equivalent(ish) prior behaviour:
--- perl5.36.3 ---
{
do {
use feature 'current_sub', 'bitwise', 'evalbytes', 'fc', 'isa', 'postderef_qq', 'say', 'signatures', 'state', 'unicode_strings', 'unicode_eval';
die sprintf("Too many arguments for subroutine at %s line %d.\n", (caller)[1, 2]) unless @_ <= 2;
die sprintf("Too few arguments for subroutine at %s line %d.\n", (caller)[1, 2]) unless @_ >= 2;
my $x = $_[0];
my $y = $_[1]
};
return $x + $y;
}
--- perl5.38.3 ---
{
do {
use feature 'current_sub', 'bitwise', 'evalbytes', 'fc', 'isa', 'module_true', 'postderef_qq', 'say', 'signatures', 'state', 'unicode_strings', 'unicode_eval';
die sprintf("Too many arguments for subroutine at %s line %d.\n", (caller)[1, 2]) unless @_ <= 2;
die sprintf("Too few arguments for subroutine at %s line %d.\n", (caller)[1, 2]) unless @_ >= 2;
my $x = $_[0];
my $y = $_[1]
};
return $x + $y;
}
...
--- perl5.42.0 ---
{
do {
use feature 'current_sub', 'bitwise', 'evalbytes', 'fc', 'isa', 'module_true', 'postderef_qq', 'say', 'signatures', 'state', 'try', 'unicode_strings', 'unicode_eval';
die sprintf("Too many arguments for subroutine at %s line %d.\n", (caller)[1, 2]) unless @_ <= 2;
die sprintf("Too few arguments for subroutine at %s line %d.\n", (caller)[1, 2]) unless @_ >= 2;
my $x = $_[0];
my $y = $_[1]
};
return $x + $y;
}