]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix issue c382 20240511.08
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 1 Aug 2024 14:18:26 +0000 (07:18 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 1 Aug 2024 14:18:26 +0000 (07:18 -0700)
'sort mycmp @array' triggered an incorrect warning if mycmp had prototype ()

lib/Perl/Tidy/Formatter.pm
lib/Perl/Tidy/Tokenizer.pm

index 85aaaa31fe46d02293d6bc5eb2b0c90f48e0b1d6..dc39982cf56683a712a5fabf9ae184baf741b0f2 100644 (file)
@@ -4646,11 +4646,11 @@ EOM
         $right_bond_strength{'&&'} = NOMINAL;
         $left_bond_strength{'&&'}  = $left_bond_strength{'||'} + 0.1;
 
-        # set strength of ^^ above && and ||. See git157. Note that:
+        # set strength of ^^ between && and ||. See git157.
         # "1 || 0 ^^ 0 || 1" = true, so ^^ is stronger than ||
-        # "1 && 0 ^^ 1 = true,       so ^^ is stronger than &&
+        # "1 ^^ 1 && 0" = true,      so && is stronger than ^^
         $right_bond_strength{'^^'} = NOMINAL;
-        $left_bond_strength{'^^'}  = $left_bond_strength{'||'} + 0.15;
+        $left_bond_strength{'^^'}  = $left_bond_strength{'||'} + 0.05;
 
         $left_bond_strength{';'}  = VERY_STRONG;
         $right_bond_strength{';'} = VERY_WEAK;
index 0ff5331beb497120523a480ca657273e4c53b7bd..e633b06fe34ef6a2887b7df94824ef46a05d4175 100644 (file)
@@ -7811,10 +7811,6 @@ sub scan_bare_identifier_do {
                 $self->report_v_string($tok);
             }
 
-            elsif ( $ris_constant->{$package}{$sub_name} ) {
-                $type = 'C';
-            }
-
             # bareword after sort has implied empty prototype; for example:
             # @sorted = sort numerically ( 53, 29, 11, 32, 7 );
             # This has priority over whatever the user has specified.
@@ -7824,6 +7820,12 @@ sub scan_bare_identifier_do {
                 $type = 'Z';
             }
 
+            # issue c382: this elsif statement moved from above because
+            # previous check for type 'Z' after sort has priority.
+            elsif ( $ris_constant->{$package}{$sub_name} ) {
+                $type = 'C';
+            }
+
             # Note: strangely, perl does not seem to really let you create
             # functions which act like eval and do, in the sense that eval
             # and do may have operators following the final }, but any operators