Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
steal match widening from rakudo-debugger
now "23 + 4" in sink context reports the whole expression, not just the operator
  • Loading branch information
moritz committed Feb 17, 2013
1 parent f6a731c commit a5a3718
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Perl6/Optimizer.pm
Expand Up @@ -323,9 +323,18 @@ class Perl6::Optimizer {
$survived := 0;
}
}
sub widen($m) {
my int $from := $m.from;
my int $to := $m.to;
for $m.list {
$from := $_.from if $_.from < $from;
$to := $_.to if $_.to > $to;
}
nqp::substr($m.orig, $from, $to - $from);
}
if $survived {
if $op.node && $*VOID_CONTEXT && !$*IN_DECLARATION {
my str $text := nqp::escape($op.node.Str);
my str $text := nqp::escape(widen($op.node));
self.add_worry($op, qq[Useless use of constant expression "$text" in sink context]);
return $NULL;

Expand Down

0 comments on commit a5a3718

Please sign in to comment.