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 _ #9520

Closed
charlesroddie opened this issue Jun 21, 2020 · 3 comments
Closed

Pattern DUCase matches DUCase _ #9520

charlesroddie opened this issue Jun 21, 2020 · 3 comments

Comments

@charlesroddie
Copy link
Contributor

charlesroddie commented Jun 21, 2020

type DU = | DUCase of int
let y =
    function
    | DUCase -> () // This should fail with FS0019: This constructor is applied to 0 argument(s) but expects 1

This type-checks in VS tooling and works in F# interactive. Behaviour is as if the user had written the correct | DUCase _ -> ()

This doesn't apply to active patterns, which fail without arguments as expected.

Tested on VS 2019 16.6.0 and "F# Interactive version 10.9.1.0 for F# 4.7".

SharpLab doesn't have the problem and gives expected error.

@charlesroddie charlesroddie changed the title When pattern matching DUs, DUCase matches DUCase _ When pattern matching DUCase matches DUCase _ Jun 21, 2020
@charlesroddie charlesroddie changed the title When pattern matching DUCase matches DUCase _ Pattern DUCase matches DUCase _ Jun 21, 2020
@abelbraaksma
Copy link
Contributor

abelbraaksma commented Jun 21, 2020

This must be a recent regression. When I try it in FSI in VS 2019 16.5.4 (yep, still had a copy that wasn't updated), I can see:

> type DU = | DUCase of int
let y =
    function
    | DUCase -> ();;

      | DUCase -> ();;
  ------^^^^^^

C:\[...]\stdin(6,7): error FS0019: This constructor is applied to 0 argument(s) but expects 1

And the same code in 16.7.0 Preview 1.0, it succeeds without error. Which suggests somewhere between 16.5.4 and 16.6.0 it was introduced, and not yet fixed in new previews.

EDIT: just updated to Preview 2.0, same there, the error is not shown, but should be.

@KevinRansom
Copy link
Member

This is fixed by this recent PR: #9426

@cartermp
Copy link
Contributor

Closing as duplicate of #9420

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

4 participants