Skip to content

Commit ccbdf61

Browse files
cknittclaude
andcommitted
Distinguish record payloads in the option table
The Codex review on #8952 found that the rule 12 table said no record holds `undefined`, while an `@unboxed` record and a one-field inline record take the answer from their field; the table and rule 12's tests now cover each record shape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q1w9Ff3BgRgQ9bKwBe9TAh Signed-off-by: Christoph Knittel <ck@cca.io>
1 parent eb22c7d commit ccbdf61

3 files changed

Lines changed: 128 additions & 78 deletions

File tree

‎compiler/ml/UntaggedVariants.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ as `Primitive_option.some(v)` otherwise. An untagged variant cannot hold
277277

278278
| Payload type | Holds `undefined` |
279279
| --- | --- |
280-
| `string`, `int`, `float`, `bool`, `bigint`, a function, a tuple, a record | no |
280+
| `string`, `int`, `float`, `bool`, `bigint`, a function, a tuple, a record without `@unboxed` | no |
281+
| an inline record with two or more fields | no |
282+
| an `@unboxed` record, an inline record with one field | as the type of its field |
281283
| an abstract type with `@notUndefined` (rule 13) | no |
282284
| an abstract type without it, a type variable, `option<_>` | yes |
283285
| a type whose declaration is not on the load path | yes |
@@ -291,6 +293,10 @@ An `@as(null)` case does not prevent unboxing; `Some(N)` is `null`.
291293
| `@as("n") ONone \| OPaque(opaque)` | `Primitive_option.some(v)` |
292294
| `BBlob(Blob.t) \| BString(string)` | `Primitive_option.some(v)` |
293295
| `DDate(Date.t) \| DString(string)` | `v` |
296+
| `RRecord(record) \| RString(string)` with `type record = {y: option<int>}` | `v` |
297+
| `INone \| IRecord({x: option<int>})` | `Primitive_option.some(v)` |
298+
| `@as("n") UONone \| UOption(unboxedOption)` with `@unboxed type unboxedOption = {x: option<int>}` | `Primitive_option.some(v)` |
299+
| `@as("n") USNone \| UString(unboxedString)` with `@unboxed type unboxedString = {s: string}` | `v` |
294300

295301
The stdlib marks `Date.t`, `RegExp.t`, `Map.t`, `Set.t`, `WeakMap.t`,
296302
`WeakSet.t`, `ArrayBuffer.t`, `DataView.t`, the typed arrays and other

0 commit comments

Comments
 (0)