Skip to content

Commit 981edbc

Browse files
committed
Perlito5 - parser - more constant folding
1 parent 43d512a commit 981edbc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src5/lib/Perlito5/FoldConstant.pm

+9
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ sub fold_constant {
5454
return Perlito5::AST::Num->new(num => $v);
5555
}
5656
}
57+
if ($code eq 'infix:</>') {
58+
if (is_constant($arg0) && is_constant($arg1)) {
59+
my $v = $arg0->value / $arg1->value;
60+
if ($v == int($v)) {
61+
return Perlito5::AST::Int->new(int => $v);
62+
}
63+
return Perlito5::AST::Num->new(num => $v);
64+
}
65+
}
5766
if ($code eq 'infix:<**>') {
5867
if (is_constant($arg0) && is_constant($arg1)) {
5968
my $v = $arg0->value ** $arg1->value;

0 commit comments

Comments
 (0)