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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]