godot/modules/gdscript
Tan Wang Leng 48a2fd7a3d 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.

(cherry picked from commit 7b1423a61e)
2020-05-25 16:31:07 +02:00
..
doc_classes DocData: Skip unexposed classes 2020-04-21 14:15:34 +02:00
editor Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
icons Add support for creating editor icons per module 2019-06-28 23:42:26 +03:00
language_server Fix incorrect capabilities notification in LSP 2020-05-15 16:43:48 -04:00
config.py DocData: Skip unexposed classes 2020-04-21 14:15:34 +02:00
gdscript.cpp fixed: saving gdscript with cyclic inheritance crash the editor 2020-05-11 10:50:45 +02:00
gdscript.h fixed: saving gdscript with cyclic inheritance crash the editor 2020-05-11 10:50:45 +02:00
gdscript_compiler.cpp Keep a weak reference to orphan subclasses to reuse on class reload 2020-01-15 22:54:01 +02:00
gdscript_compiler.h GDScript: Don't re-evaluate index on assigment with operation 2020-01-09 10:43:29 -03:00
gdscript_editor.cpp regression: dictionary key no autocomplete fix 2020-05-25 15:58:25 +02:00
gdscript_function.cpp Fix too eager GDScriptFunctionState stack cleanup 2020-05-20 11:40:45 +02:00
gdscript_function.h Fix object leaks caused by unfulfilled yields 2020-05-05 17:53:47 +02:00
gdscript_functions.cpp fix: dict2inst crash when constructor has arguments 2020-05-11 11:01:12 +02:00
gdscript_functions.h Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
gdscript_parser.cpp gdscript_parser: Fix "unreachable code" false positive for loops 2020-05-25 16:31:07 +02:00
gdscript_parser.h break, continue outside of a loop, match statement handled 2020-05-16 00:08:37 +02:00
gdscript_tokenizer.cpp Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
gdscript_tokenizer.h Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
register_types.cpp Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
register_types.h Adding missing include guards to header files identified by LGTM. 2020-03-25 11:38:54 +01:00
SCsub GDScript: Disable LSP if either jsonrpc or websocket are disabled 2019-08-28 13:29:37 +02:00