question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pattern discard allowed for union case that takes no data

See original GitHub issue

Match discards aren’t type checked against case

    type X = X 

    let test() =
        match X with
        | X _ -> () // No error X doesn't have arguments

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
dsymecommented, Sep 7, 2022

Things have changed a bit since 2016, and we now are more inclined to emit new informationals and warnings, protected by a /langversion switch.

So I’d definitely be ok with emitting at least an informational, and possibly a warning for this case.

1reaction
vzarytovskiicommented, Oct 10, 2022

I agree that warning + language switch is better in making this more visible. Info-warnings are use very sparsely, typically only when deprecating language features…

Agree, I think it should be a warning behind language version. It should also be easy to add a quick fix to VS (and other IDEs) which will be removing unnecessary discards.

Read more comments on GitHub >

github_iconTop Results From Across the Web

See it, Say it, Sort it! - - DevConflicts
I got a lot of feedback and suggestions, and I ended up with Pattern discard is not allowed for union case that takes...
Read more >
Pattern Matching - F# | Microsoft Learn
Discriminated union patterns can be simple named cases or they can have a value, or a tuple containing multiple values. If there is...
Read more >
rust - Why does pattern matching on a union have an ...
1 Answer. The entire point of a union is that the compiler doesn't store any information in the union about what type it...
Read more >
Typed Union Cases · Issue #606 · fsharp/fslang-suggestions
As it stands today, Union Cases have corresponding Types generated by the compiler if at lease one Case of the Union contains data,...
Read more >
OCaml for the Skeptical: Pattern Matching
Pattern matching comes up in several places in OCaml: as a powerful control structure combining a multi-armed conditional, unification, data destructuring ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found