fix(flow): separate dynamic loop divergence from infinite loops - #1039
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the return flow analysis for Lua functions by introducing a more granular distinction between proven infinite loops (is_infinite) and runtime-dependent divergence (may_diverge). It renames several fields and functions to better reflect their purpose in the diagnostic pipeline, specifically for the MissingReturn check. The review feedback highlights that loops with constant conditions (e.g., while true) should not be marked as strictly infinite if they contain a break statement, as this could lead to false positives in reachability analysis.
bcc92ca to
b889c09
Compare
Track runtime-dependent loop divergence separately from proven infinite loop bodies in return-flow analysis. Keep MissingReturn fallthrough-friendly when a later explicit return is still reachable, including constant-condition loops whose bodies can break at runtime. Preserve the stronger infinite-loop signal for loops that truly cannot exit, and rename the helper used by the diagnostic to reflect that narrower contract.
b889c09 to
fef8322
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the return flow analysis in the Lua code analyzer to better distinguish between code that falls through, proven infinite loops, and runtime-dependent divergence. Key changes include renaming can_continue to can_fall_through and can_stall to is_infinite, as well as introducing a may_diverge flag. The MissingReturn diagnostic was updated to utilize these more granular flags, allowing for more accurate detection of missing return statements in functions containing loops. Additionally, several unit tests were added to verify the improved analysis logic. I have no feedback to provide as there were no review comments to evaluate.
Summary
MissingReturnfallthrough-friendly for dynamicwhileandrepeatloops when a laterreturnis still reachabledoes_func_body_satisfy_missing_returnso the API matches the softer diagnostic contractTesting