Skip to content

JDoStatement.unconditionalControlBreak() isn't correct #10371

Description

@niloc132

For, for-each, and while loop constructs only conditionally run their contents, so JStatement.unconditionalControlBreak() correctly returns false. However, do-while loops always are guaranteed to run their block at least once. This means that the following do-while loop should return true for unconditionalControlBreak

do {
  return;
while (true);
}

This probably won't have any impact on compiled code, but is technically wrong today.

JTryStatement is also wrong in the same way, though all blocks need to have unconditional control break to return true. GIven try-with-resources, it is possible for that to be only one though, such as

try (var value = doSomething()) {
  return value.getAllData();
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions