48a2fd7a3d
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.
(cherry picked from commit
|
||
---|---|---|
.. | ||
doc_classes | ||
editor | ||
icons | ||
language_server | ||
config.py | ||
gdscript.cpp | ||
gdscript.h | ||
gdscript_compiler.cpp | ||
gdscript_compiler.h | ||
gdscript_editor.cpp | ||
gdscript_function.cpp | ||
gdscript_function.h | ||
gdscript_functions.cpp | ||
gdscript_functions.h | ||
gdscript_parser.cpp | ||
gdscript_parser.h | ||
gdscript_tokenizer.cpp | ||
gdscript_tokenizer.h | ||
register_types.cpp | ||
register_types.h | ||
SCsub |