tokuhirom / Perl-MinimumVersion-Fast

Other
4 stars 6 forks source link

Chained comparison not yet detected #19

Open Tux opened 4 years ago

Tux commented 4 years ago
$ perlver-fast -ve'10 < $a < 40 and exit 0'
-e: 5.006 / 5.006

Stacked comparison was introduced in 5.31.10. If we exclude devel versions, it should report 5.32.0 instead of 5.006

$ perl5.30.3 -we '10 < $a < 42 and exit 0' (y|n|e|a)? yes
syntax error at -e line 1, near "$a <"
Execution of -e aborted due to compilation errors.
$ perl5.32.0 -we '10 < $a < 42 and exit 0'
Use of uninitialized value $a in numeric lt (<) at -e line 1.
briandfoy commented 2 months ago

This is going to quite a tough one to specify. First, you need this form:

A CMP_OP B COMP_OP C

You don't care about A. If you have CMP_OP B CMP_OP, you've found it. But, what is B? That could be almost anything.

10 < (1+2) < 40
10 < some_call() < 40
10 < time < 40
10 < grep( { defined } @list ) < 40

That can get pretty hairy, and I think the code needs a big refactoring to avoid the big if-else structure that is there now.