Commit 4c40c09
fix(codegen/deno-esm): add endsWith / stripSuffix / numToFixed2 lowering (closes #470)
Three `pub extern fn` decls in stdlib/Deno.affine had no matching entry in
codegen_deno.ml's `deno_builtins` table. The codegen emitted bare calls to
undefined JS symbols at runtime (ReferenceError).
Adds direct lowerings (per the option-1 path in the issue):
endsWith(s, x) -> String(s).endsWith(x)
stripSuffix(s, x) -> ((__s,__x) => __s.endsWith(__x) ? __s.slice(0,-__x.length) : __s)(s, x)
numToFixed2(n) -> Number(n).toFixed(2)
Adds `tests/codegen-deno/deno_string_fmt.{affine,harness.mjs}` covering the
three names plus stripSuffix passthrough on suffix-miss. The general
extern->stdlib-body linkage question (option-2 in #470) stays open as
follow-up — option-1 is the small, ship-now fix.
374/374 dune tests + all codegen-deno harnesses green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: hyperpolymath <6759885+hyperpolymath@users.noreply.github.com>1 parent 3ee4a21 commit 4c40c09
3 files changed
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
648 | 648 | | |
649 | 649 | | |
650 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
651 | 657 | | |
652 | 658 | | |
653 | 659 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
0 commit comments