Closed Pshy0 closed 5 months ago
One solution could be to get rid of the "if true" completely. If the block define variables with the same name than the block above, this is already supposed to generate a warning.
One solution could be to get rid of the "if true" completely.
This is how this plugin was originally implemented. Getting rid of if true
is not possible, since variables can be declared inside the block, the following code will stop working:
func test():
if OS.is_debug_build():
var a = 1
print(a)
var a = 2
print(a)
A possible solution is to analyze return
s and keep the else
branch with a fake return
even if the else
branch should be removed.
Fixed in 461016c29c418713028e797822ab04b83d51fa50. Thanks for testing! Please let me know if you find any new issues.
Currently, only the current block is analyzed, a fake return
is always inserted at the end of function (if it did not already exist). This may be improved in the future.
This is not valid GDScript:![image](https://github.com/dalexeev/gdscript-preprocessor/assets/44928041/42fc1656-e4ee-4d92-bd1c-62acf200b8ed)
Once run, it will result in errors:![image](https://github.com/dalexeev/gdscript-preprocessor/assets/44928041/96538351-ac59-4368-9106-52b00e01c2db)