Fix false positive "Unreachable code" warning for loops
Created by: yamgent
- The first commit is to fix #35775. It will fix erroneous reports in these two cases:
func a():
var arr = []
for i in arr:
return i
# can be reached, but buggy analysis says cannot
return -1
func b():
var should_loop = false
while should_loop:
return 1
# can be reached, but buggy analysis says cannot
return 0
- The second commit exist, because I notice that the intention of the
has_return
variable has clearly evolved as new fixes are pushed (see previous problems with erroneous "unreachable code" such as #25955 (closed) and #30458 (closed)). I feel that the namehas_return
is now less appropriate as a result. I propose the new name to behas_unconditional_return
, for blocks that has an "unavoidable" return statement. Name feels a bit long though, so I am open to any suggestions to improve the name.