drforr / perl6-Perl6-Tidy

Tidier for Perl 6 code
16 stars 7 forks source link

feature request: warn of for loop no-ops #2

Closed tbrowder closed 7 years ago

tbrowder commented 7 years ago

I found a trap recently where rakudo gave no warning:

for 5..2 {
    say $_
}

The loop is not entered because the range returns zero somehow. The proper way to get the desired reverse iteration is to use the sequence operator (three dots):

for 5...2 {
    say $_
}

It would be great if someday Perl6::Tidy could catch such an apparent error.

Thanks for creating this project.

tbrowder commented 7 years ago

According to @drforr, this is more properly a feature of his planned module Perl6::Lint. Closing this until Perl6::Lint is unveiled.

drforr commented 7 years ago

Eventually :)