Skip to content

Commit bc1706f

Browse files
committed
Expand Assignment to include ConditionalExpression on LHS/RHS
1 parent 66c0471 commit bc1706f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/Babble/Plugin/DefinedOr.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ sub transform_to_plain {
3939
[ after => '(?>(?&PerlPrefixPostfixTerm))' ],
4040
] => $tf);
4141
$top->each_match_within(Assignment => [
42-
[ before => '(?>(?&PerlPrefixPostfixTerm))' ],
42+
[ before => '(?>(?&PerlConditionalExpression))' ],
4343
[ op => '(?>(?&PerlOWS) //=)' ], '(?>(?&PerlOWS))',
44-
[ after => '(?>(?&PerlPrefixPostfixTerm))' ],
44+
[ after => '(?>(?&PerlConditionalExpression))' ],
4545
] => $tf);
4646
}
4747

t/plugin-definedor.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ my @cand = (
1616
'my $x; my $y = 3; do { defined($_) or $_ = $y for $x } if $z; say $x;', ],
1717
[ 'sub foo { return $x // 3 }',
1818
'sub foo { return (map +(defined($_) ? $_ : 3), $x)[0] }', ],
19+
[ '$lhs ? $i : $j //= $rhs ? $x : $y',
20+
'(map +(defined($_) ? $_ : ($_ = $rhs ? $x : $y)), $lhs ? $i : $j)[0]', ],
1921
);
2022

2123
foreach my $cand (@cand) {

0 commit comments

Comments
 (0)