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

Fix: Wrong unreachable warning after returning from match's wildcard pattern #25955 #26097

Conversation

Projects
None yet
5 participants
@danielspaniol
Copy link

danielspaniol commented Feb 20, 2019

Fixes #25955

Problem

The parser only checked if the catch-all branch has a return in order to determine if the entire match block has a return.

This code block was assumed to always return.

match value:
    "test":
        print("test")
    _:
        return

This in turn means that every code following was regarded unreachable.

Solution

Every match is assumed to have a return, unless we find one branch to not return.

@danielspaniol danielspaniol requested review from bojidar-bg, reduz and vnen as code owners Feb 20, 2019

Daniel Spaniol
Require `return` in all match branches
Before the parser only checked if the catch-all branch has a return in
order to determine if the entire match block has a return.

This code block was assumed to always return.

    match value:
        "test":
            print("test")
        _:
            return

Now as soon as one of the branches has no return, the entire match block
is marked to not have a return.

@danielspaniol danielspaniol force-pushed the danielspaniol:25955-wrong-unreachable-warning-after-returning-from-matchs-wildcard-pattern branch from 5a1d823 to 79176de Feb 20, 2019

@akien-mga akien-mga added this to the 3.2 milestone Feb 20, 2019

@bojidar-bg
Copy link
Member

bojidar-bg left a comment

LGTM

@vnen

This comment has been minimized.

Copy link
Member

vnen commented Mar 17, 2019

Looks good to me.

I noticed that the email you used to commit is not attached to your GitHub account. It does not prevent merging, but the contribution won't be associated with your GH account, so you won't be labeled as contributor in the GH interface. If you want to fix that you can either add the email of the commit to your account or change the email in the commit by amending it.

@akien-mga akien-mga merged commit 4ec384f into godotengine:master Apr 1, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@akien-mga

This comment has been minimized.

Copy link
Member

akien-mga commented Apr 1, 2019

Thanks!

@akien-mga

This comment has been minimized.

Copy link
Member

akien-mga commented Apr 3, 2019

Cherry-picked for 3.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.