Repository navigation
Backlog
Labels
architectureStructural/system-level shape and runtime behaviourbindingsABI, FFI, WASM, and cross-language interop surfacesbugSomething is broken or behaves incorrectlydecisionA ruling is required before work can proceedmigrationPorting between languages or toolchains (e.g. -> AffineScript)priority:p2Normal - queue itscope:repoConfined to this repository
Description
Needs an owner decision. This changes language semantics.
Evidence (main ee211d3, probed 2026-12-01)
| Probe | interp (eval) |
core wasm | Bun-ESM |
|---|---|---|---|
len("é") |
2 | 2 | 1 |
len("🦜") |
4 | 4 | 2 |
string_char_code_at("🦜", 0) |
240 | 240 | 55358 (a lone surrogate) |
Cause: lib/codegen_deno.ml:1240 lowers len to JS .length, which counts UTF-16 code units. string_get and string_sub (:1244-1245) use JS indices in the same way. The interpreter and wasm count UTF-8 octets.
Classification
This is a silent backend divergence (#560 class), not a type-soundness hole. The same well-typed program prints different values on different backends, and nothing fails.
Options
Ranked by elegance and correctness first, then by dependability.
- (Recommended: most elegant and correct) Use octet offsets everywhere, with boundary checks.
lencounts UTF-8 octets on every backend.string_getandstring_subfail loudly when an offset is not on a character boundary. Bun lowers these through a UTF-8 view of the string. Programs that need characters move to the feat(strings): backend-independent UTF-8 octet count and code-point view #829 API (code_points,code_point_slice). This is the Rust model. - (Most dependable, type-led) Index strings through an opaque offset type instead of
Int. Offsets would be a newtype such asUtf8Offset, produced only byfind, by iteration, or byutf8_byte_length. Mixing units would then be a type error rather than a runtime value. Pairs with option 1. - (Outside the box) Represent
Stringon Bun as aUint8Arrayof UTF-8. All backends would then share one representation. The cost is JS interop: every host boundary has to transcode. - (Stop-gap) Refuse
len,string_getandstring_subon Bun-ESM at compile time and point to the feat(strings): backend-independent UTF-8 octet count and code-point view #829 API. This is a loud failure, but it breaks existing Bun code.
Scope
This is wider than this repo. Estate code compiled to Bun-ESM, such as the DEED printer thread, counts in UTF-16 units today.
The audit is in docs/reports/AUDIT-2026-12-01-backend-divergences.adoc (PR for #830).
Generated by Claude Code
Reacted by coderabbitai
Metadata
Metadata
Assignees
Labels
architectureStructural/system-level shape and runtime behaviourbindingsABI, FFI, WASM, and cross-language interop surfacesbugSomething is broken or behaves incorrectlydecisionA ruling is required before work can proceedmigrationPorting between languages or toolchains (e.g. -> AffineScript)priority:p2Normal - queue itscope:repoConfined to this repository
Activity
whatproblem-ai commentedon Dec 1, 2026
Problem: On
mainee211d3,len,string_getandstring_subcount UTF-8 octets on interp and core wasm but UTF-16 code units on Bun-ESM. The cause islib/codegen_deno.ml:1240-1245, which lowers them to JS.lengthand JS indices. The same well-typed program silently prints different values per backend; for example,len("🦜")is 4 vs 2, andstring_char_code_atreturns a lone surrogate on Bun.Expected: Identical string-index semantics on every backend.
Missing: owner's choice among options 1–4, migration policy for estate Bun-ESM code (e.g. DEED printer)
Clarity: 93%. Clear enough to work on.
⌨️ Commands · 💬 Have feedback? Tell us · 🎯 New here? Add WhatProblem to your repo · 🔒 Privacy
coderabbitai commentedon Dec 1, 2026
🔗 Related PRs
#829 - feat(strings): backend-independent UTF-8 octet count and code-point view [open]
📝 Issue Planner
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
fix(js-backend): refuse an unprovided builtin at compile time, by name (
fix(codegen): start the wasm heap after the last data segment (#830) (#…
hyperpolymath commentedon Dec 1, 2026
Reopened: this issue was closed by accident, not by a decision.
PR #844 merged a draft decision record and was meant to reference this issue without closing it. Its description contained the phrase "does not close #831", and GitHub read the words "close #831" in the squash commit message as a closing keyword. The issue was closed two seconds after the merge.
The owner decision on string index units is still open. The draft record with the usage numbers, the Bun benchmark, the options and a recommendation is
docs/decisions/0028-string-index-units.adoconmain.If the closure was in fact intended, please close it again.
Generated by Claude Code
whatproblem-ai commentedon Dec 1, 2026
The reopen fits what was already understood: the closure came from GitHub reading "close #831" inside "does not close #831" in PR #844's squash commit, not from an owner decision. The draft record
docs/decisions/0028-string-index-units.adoconmainnow holds the usage numbers, the Bun benchmark and a recommendation, but the choice among options 1–4 is still open.Clarity: 90%. Nothing further needed.
⌨️ Commands · 💬 Have feedback? Tell us · 🎯 New here? Add WhatProblem to your repo · 🔒 Privacy
docs(adr): renumber the string-index-units record to ADR-0029 (#859)