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

if let semantically equivalence to if is wrong w.r.t. scope #47

Closed
Havvy opened this issue Apr 25, 2017 · 2 comments
Closed

if let semantically equivalence to if is wrong w.r.t. scope #47

Havvy opened this issue Apr 25, 2017 · 2 comments
Labels
Bug Incorrect statements, terminology, or rendering issues

Comments

@Havvy
Copy link
Contributor

Havvy commented Apr 25, 2017

The equivalence is wrong because the scope of the expression in the predicate has to live as long as the consequent because of the ability to ref in the pattern.

Or something like that.

@eddyb
Copy link
Member

eddyb commented Apr 25, 2017

For the record:

if let a = b { c } /* optional else */ d

Desugars to:

match b {
    a => c,
    _ => d
}

So b is in scope, not only for c but also for d (except for what a moves out).

@Havvy Havvy added the Bug Incorrect statements, terminology, or rendering issues label Sep 24, 2017
@alercah
Copy link
Contributor

alercah commented Jan 2, 2018

There doesn't seem to be text in the current version which describes this equivalence, unless I'm looking in the wrong place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Incorrect statements, terminology, or rendering issues
Projects
None yet
Development

No branches or pull requests

3 participants