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

Pattern DUCase _ matches DUCase #10204

Closed
TysonMN opened this issue Sep 30, 2020 · 9 comments
Closed

Pattern DUCase _ matches DUCase #10204

TysonMN opened this issue Sep 30, 2020 · 9 comments

Comments

@TysonMN
Copy link

TysonMN commented Sep 30, 2020

The following code compiles, but it expected that it would not compile.

type MyDU = DUCase
let asdf = function
  | DUCase _ -> ()

I thought the last line would have to omit the discard pattern, which would look like | DUCase -> ().

This behavior is the opposite of bug #9520.

I am using

  • version 16.7.5 of Visual Studio Enterprise 2019 and
  • version 3.1.402 (x64) of the .NET Core SDK.
@cartermp
Copy link
Contributor

This appears to have been the case for at least F# 4.5, so I don't think it's a bug

@TysonMN
Copy link
Author

TysonMN commented Sep 30, 2020

Is this possibility mentioned in the Wildcard Pattern section of the Pattern Matching documentation? I don't get the impression that it is mentioned there.

@abelbraaksma
Copy link
Contributor

abelbraaksma commented Sep 30, 2020

@cartermp is quite right (at least since F# 4.0). I raised this back in 2016, @dsyme considered it kinda by design but was open to changing this behavior (I doubt it's worth its while). See #1592

@cartermp
Copy link
Contributor

Thanks for the clarification @abelbraaksma - I will close as a duplicate of #10204

@abelbraaksma
Copy link
Contributor

I think you meant duplicate of #1592 ;).

@cartermp
Copy link
Contributor

Indeed! The 'ole copy paste 'a 'roo

@TysonMN
Copy link
Author

TysonMN commented Oct 1, 2020

Thanks everyone for all the comments and the pointer to the previous issue. I created dotnet/docs#20858 to suggest that the documentation be changed to mention this feature.

@abelbraaksma
Copy link
Contributor

May be fixed by: #14055

@abelbraaksma
Copy link
Contributor

Yep, fixed indeed! In #14055.

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

No branches or pull requests

3 participants