diff options
author | Tan Wang Leng <tanwangleng@outlook.com> | 2020-02-04 15:58:27 +0800 |
---|---|---|
committer | Tan Wang Leng <tanwangleng@outlook.com> | 2020-05-16 20:02:55 +0800 |
commit | 7b1423a61ea6a5249d29ddbb3866ce815f16497c (patch) | |
tree | 13e86ec6041d981610f00d15d77085340ad4f6ae /core/io/logger.cpp | |
parent | ac58372db824b74b8c4feb948434b924c573b847 (diff) |
gdscript_parser: Fix "unreachable code" false positive for loops
Depending on the conditional statements of the 'for' and 'while' loops,
their body may not even execute once. For example:
func a():
var arr = []
for i in arr:
return i
# can be reached, but analysis says cannot
return -1
func b():
var should_loop = false
while should_loop:
return 1
# can be reached, but analysis says cannot
return 0
The parser will complain that the statements after the comment cannot
be reached, but it is clearly possible for our scenario. This is
because the parser falsely assumes that the loop body will always
execute at least once.
Fix the code to remove this assumption for both of those loops.
Diffstat (limited to 'core/io/logger.cpp')
0 files changed, 0 insertions, 0 deletions