[ 
https://issues.apache.org/jira/browse/GROOVY-12397?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18113834#comment-18113834
 ] 

ASF GitHub Bot commented on GROOVY-12397:
-----------------------------------------

paulk-asert opened a new pull request, #2920:
URL: https://github.com/apache/groovy/pull/2920

   …/ || operand; break and continue end an if arm
   
   A pattern variable declared in the right operand of && or || had its slot 
allocated (and null-initialised) at its instanceof site only. That operand is 
skipped when the left one decides the result, so at the join a later read of 
the slot (a following conjunct, the then branch) failed verification:
   
       if (p instanceof String s && s.length() > 0 && s.trim() instanceof 
String t)
   
   threw VerifyError. BinaryExpressionHelper now pre-declares the pattern 
variables of the right operand before the left operand runs, and the instanceof 
site reuses the pre-declared slot (CompileStack keeps the set).
   
   VariableScopeVisitor and the if-statement writer also treated an arm ending 
in break or continue as completing normally, so that
   
       if (!(o instanceof String s)) continue
   
   did not introduce `s` after the if as JLS §6.3.2.2-200-C / §14.22 require. 
Both now use mayCompleteNormally.




> VerifyError for a pattern variable bound in a later &&/|| operand (JEP 394 
> flow scoping)
> ----------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12397
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12397
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 6.0.0-RC-1
>            Reporter: Paul King
>            Priority: Major
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to