dotnet / dotnet/csharplang

[Proposal]: Standard Unions

Open
#9,565 0 comments 0 reactions 0 assignees View on GitHub
Proposal champion
Dominant language
C#
Stars
12.7k
Forks
1.1k
Avg merge
11h 1m
Merged PRs (30d)
3

Description

# Standard Unions

* Specification: [Standard Unions](https://github.com/dotnet/csharplang/blob/main/proposals/standard-unions.md)
* Working group folder: [Discriminated Unions](https://github.com/dotnet/csharplang/tree/main/meetings/working-groups/discriminated-unions)
* Discussion: #9567

## Summary

A family of nominal type unions exist in the *TBD* namespace that can be used across assemblies as the standard way to specify a type union without needing to declare and name one.

```csharp
public union Union(T1, T2);
public union Union(T1, T2, T3);
public union Union(T1, T2, T3, T4);
...

Union x = 10;
...
var _ = x switch
{
int v => ...,
string v => ...
}
```
## Design meetings
https://github.com/dotnet/csharplang/discussions/9571

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with proposals/standard-unions.md, then read the Discriminated Unions working-group folder and discussion #9567. Review design meeting discussion #9571 to understand the unresolved choices; done means the standard-union design is agreed and the proposal is updated accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.