Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/untagged-variants-spec.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Document the rules of untagged variants in `compiler/ml/UntaggedVariants.md`, with tests pinning them.
4 changes: 4 additions & 0 deletions compiler/ml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ For module inclusion and signature compatibility, start with
[`includecore.mli`](includecore.mli), [`includemod.mli`](includemod.mli), and
[`mtype.mli`](mtype.mli).

[`UntaggedVariants.md`](UntaggedVariants.md) states the rules of untagged
(`@unboxed`) variants: payload kinds, run-time recognition, well-formedness,
and the interaction with `option`.

## Main data and operations

[`types.mli`](types.mli)
Expand Down
452 changes: 452 additions & 0 deletions compiler/ml/UntaggedVariants.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

We've found a bug for you!
/.../fixtures/TaggedDuplicateLiteral.res:1:23-34

1 │ type t = | @as("x") A | @as("x") B
2 │

This untagged variant definition is invalid: Duplicate literal x.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

We've found a bug for you!
/.../fixtures/UntaggedAtMostOneString.res:2:20-30

1 │ @unboxed
2 │ type t = A(string) | B(string)
3 │

This untagged variant definition is invalid: At most one case can be a string type.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type t = | @as("x") A | @as("x") B
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@unboxed
type t = A(string) | B(string)
Loading
Loading