Commit 000ee80
committed
fix(codegen-deno): don't re-declare preamble Option/Result constructors
The Deno-ESM runtime preamble already declares Some/None/Ok/Err. gen_type_decl
re-emitted them for any program that DECLARES `type Option`/`type Result`
(e.g. stdlib/prelude.affine), so the emitted module crashed under node with
`SyntaxError: Identifier 'Some' has already been declared`. The #136 AOT smoke
never caught it — it only checks the emitted module is non-empty, never runs it.
Skip the variants the preamble already provides (Some/None/Ok/Err) when
lowering a TyEnum; user-defined enums are unaffected. Add a regression test
asserting `const Some` is declared exactly once.
This is the locally-declared sibling of the imported-constructor duplication
fixed in #604; together they close the duplicate-constructor class on the
Deno-ESM backend.
Verified: stdlib/prelude.affine now runs under node; dune test 459 green;
tools/run_codegen_deno_tests.sh all harnesses pass under node. The JS and C
backends share the same latent preamble/declaration duplication (not executed
in CI); tracked separately.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lz7pRcec2Z3tVtaAhvB3M81 parent c7922cf commit 000ee80
2 files changed
Lines changed: 55 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1685 | 1685 | | |
1686 | 1686 | | |
1687 | 1687 | | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
1688 | 1697 | | |
| 1698 | + | |
| 1699 | + | |
1689 | 1700 | | |
1690 | 1701 | | |
1691 | 1702 | | |
| |||
1703 | 1714 | | |
1704 | 1715 | | |
1705 | 1716 | | |
| 1717 | + | |
1706 | 1718 | | |
1707 | 1719 | | |
1708 | 1720 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
228 | 269 | | |
229 | 270 | | |
230 | 271 | | |
231 | | - | |
| 272 | + | |
| 273 | + | |
0 commit comments