Feature request: Debug: improve error message when entering label with parameters due to missing return in previous label #5166
Labels
enhancement
A proposed or requested enhancement or improvement to renpy's features.
Context
I often write utility "functions" as labels with parameters. Due to Python-style indentation I often forget to add a final
return
clause, as it looks obvious to me that the label ends with the indent.This makes the script execution leak after the end of the label to the next label, which generally has at least one parameter, causing a runtime error:
Example
In this example,
say_hello_and_wait
will leak tosay_goodbye
whereduration
will not be defined, andsay_goodbye
will leak to_say_text_and_wait
wheretext
(andduration
) is not defined.Proposal
It would be nice if Renpy detected that we entered a parametered label directly from above (without a proper jump/call with parameters), so it can warn us about illegal parameter label "default" entrance. This seems the easiest way to warn the user against this case.
Alternatives
If this could be detected earlier via parsing before game start it would be even better, but I understand how difficult it can be to verify (because runtime code could enter branching differently depending on the context, therefore making it not obvious that all branches return, making the parser complain that a final
return
is missing even if reaching the end of the block was impossible at runtime).Finally, Lint could be a more lightweight way to check such issues and only warning us if some code is suspicious (missing return statement) without causing a strict error. But in my case I hadn't even thought about linting before I fixed the issue manually, so YMMV - and again, parsing branches is not obvious.
The text was updated successfully, but these errors were encountered: