Skip to content

(Diagnostics) consider label parameters as global variables #372

Open
@Gouvernathor

Description

@Gouvernathor

This is most likely a long-term improvement, and the boundaries of what should and should not be flagged are relatively blurred.
image
Here, you can see that the variable is flagged as not defaulted. But if it's a label parameter (see just above), then the variable exists (as long as you come from that label being called and did not return from it yet, and that's a more difficult if not impossible thing to check).
That variable cannot be unbound (whether the label parameter is defaulted or required), at least while we are in the label block and have not passed another label.
Even a use of highlight_properties in another file may be correct too, because if I jump or call a label of the other file from game_loop, the variable will still be bound.

So, I don't think we can realistically narrow down the issue more than this : every parameter of every label should be marked as correct regarding being defaulted.
The only exception would be a label which doesn't call or jump anywhere, doesn't contain any python (which could jump), screens or custom statements (same) and just returns. In that case we can be sure its parameters are only bound within that label. But asserting that would require pretty heavy reachability analysis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogSomething that is not a priority and will be addressed in a future releasebugSomething isn't workingtopic:diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions