Repository navigation
Commit 35b1e48
Box Some of a constant case represented by undefined (#9008)
Why:
`Some(U)` with `@as(undefined) U` compiled to plain `undefined` when `U`
was a constant, so it was `None`, while `Some(v)` with `v = U` passed at
run time stayed distinct (#8954).
A constant constructor whose literal is `undefined` is now a none for
`const_some_none_depth`, so `Some` of it is boxed like `Some(None)`. This
holds for untagged and tagged variants alike. The spec's known bug is gone,
and rule 12 states the case.
JS modified:
Example:
@unboxed type u = | @as(undefined) U | V(string)
let x: option<u> = Some(U)
Before (js): let x = undefined;
After (js): let x = Primitive_option.some(undefined);
Fixes: #8954
Claude-Session: https://claude.ai/code/session_01CMkrYaktctdKc4M41WF36t
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent e6b89eb commit 35b1e48
5 files changed
Lines changed: 95 additions & 99 deletions
File tree
- changes
- compiler/ml
- tests/tests/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
| 294 | + | |
| 295 | + | |
295 | 296 | | |
296 | 297 | | |
297 | 298 | | |
| |||
313 | 314 | | |
314 | 315 | | |
315 | 316 | | |
316 | | - | |
| 317 | + | |
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
| |||
356 | 357 | | |
357 | 358 | | |
358 | 359 | | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | 360 | | |
375 | 361 | | |
376 | 362 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
586 | 586 | | |
587 | 587 | | |
588 | 588 | | |
589 | | - | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
590 | 593 | | |
591 | 594 | | |
592 | 595 | | |
| |||
0 commit comments