Commit a3e0661
fix(js-codegen): don't re-declare preamble Option/Result constructors
Mirror of the Deno-ESM fix (#606) for the JS backend, which shares the same
Some/None/Ok/Err runtime preamble. A program that declares `type Option` /
`type Result` (e.g. stdlib/prelude.affine) re-emitted those consts from the
TyEnum lowering, redeclaring them (SyntaxError under node). Skip the
preamble-provided constructors; user-defined enums are unaffected.
The C backend does NOT share this bug — it emits a tag-enum plus distinct
constructor functions (TAG_Some / Some()), with no Some/None preamble — so
#607's "JS/C" item is JS-only.
Adds a JS-path regression guard alongside the existing Deno one. Verified:
stdlib/prelude.affine -> JS has a single `const Some` and loads under node;
dune test 460 green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lz7pRcec2Z3tVtaAhvB3M81 parent eae71fd commit a3e0661
2 files changed
Lines changed: 51 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
538 | 544 | | |
| 545 | + | |
| 546 | + | |
539 | 547 | | |
540 | 548 | | |
541 | 549 | | |
| |||
550 | 558 | | |
551 | 559 | | |
552 | 560 | | |
| 561 | + | |
553 | 562 | | |
554 | 563 | | |
555 | 564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
64 | 89 | | |
65 | 90 | | |
66 | 91 | | |
| |||
262 | 287 | | |
263 | 288 | | |
264 | 289 | | |
265 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
266 | 303 | | |
267 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
268 | 307 | | |
269 | 308 | | |
270 | 309 | | |
271 | 310 | | |
272 | 311 | | |
273 | | - | |
| 312 | + | |
0 commit comments