New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
defined operator not constant folded #16266
Labels
Comments
From @bulk88The defined operator on a constant should be folded, it isn't. The 9 is folded, but it stops at the defined operator. use strict;
use B::Concise;
use constant (PARENT_STATION => 9);
my %stop_id_translate;
sub import_stop_times {
my $record = shift;
return defined(PARENT_STATION) && exists
$stop_id_translate{$record->[3]}
? $stop_id_translate{$record->[3]}
: $record->[3];
}
my $walker = B::Concise::compile('-exec','import_stop_times',
\&import_stop_times); # 1
$walker->();
If I do a different expression use strict;
use B::Concise;
use constant (PARENT_STATION => 9);
my %stop_id_translate;
sub import_stop_times {
my $record = shift;
return PARENT_STATION == 0 && exists $stop_id_translate{$record->[3]}
? $stop_id_translate{$record->[3]}
: $record->[3];
}
my $walker = B::Concise::compile('-exec','import_stop_times',
\&import_stop_times); # 1
$walker->();
The correct branch is correctly removed. Another example use strict;
use B::Concise;
use constant (PARENT_STATION => 9);
my %stop_id_translate;
sub import_stop_times {
my $record = shift;
return PARENT_STATION == 9 && exists $stop_id_translate{$record->[3]}
? $stop_id_translate{$record->[3]}
: $record->[3];
}
my $walker = B::Concise::compile('-exec','import_stop_times',
\&import_stop_times); # 1
$walker->();
Perl Info
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Migrated from rt.perl.org#132480 (status was 'new')
Searchable as RT132480$
The text was updated successfully, but these errors were encountered: