Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint : Check reachable labels with required parameters #5318

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Gouvernathor
Copy link
Member

No description provided.

This is weird since it's one rare kind of statement which should *not* be reachable
@mal
Copy link
Member

mal commented Jan 29, 2024

It may not be pretty, but this is entirely legal and functional:

label start:
    call a(1)
    call alternate_greeting(2)
    return

label a(foo=1):
    "Hello [foo]"

label reentry(foo=1):
    "I'm conversing with [foo]."
    return

label alternate_greeting(foo=1):
    "Bonjour [foo]!"
    call reentry(foo)
    return

@renpytom
Copy link
Member

I'd say even if it's legal, it's probably more likely to be an error than not.

@Gouvernathor
Copy link
Member Author

Gouvernathor commented Jan 29, 2024

None of the labels in that example emit a lint warning, even if they were all reachable (which they are not, only reentry is), since none of them have a required parameter.

@Gouvernathor
Copy link
Member Author

Gouvernathor commented Jan 29, 2024

My test code would be this :

label entry:
label fine:
label finetoo():
label also(e=5):
label problem(f):
    pass

the entry label is not reachable by other means than jumping to it (assuming it's the start of the file). fine, finetoo and also have no required parameter, so reaching them "from the top" is fine (even though weird in the case of also), and only problem is reported by lint.

@mal
Copy link
Member

mal commented Jan 29, 2024

Fair enough, I'm just always wary of lint accidentally becoming an opinionated "we don't think you want to do this" (weird label structuring) tool vs a "these are actual problems" (using attributes that don't exist) tool.

@Gouvernathor
Copy link
Member Author

I agree, I aimed for the second one.

Note that this is a prototype to illustrate how the base issue can be solved and help consideration of that issue, I don't strongly support adding that check or that particular implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants