Skip to content

fix(compiler): key display descriptors by layout - #1166

Merged
nicolas-abril merged 2 commits into
bendlang:mainfrom
vicmcorrea:dev/fix-show-layout-cache
Sep 28, 2026
Merged

nicolas-abril merged 2 commits into
bendlang:mainfrom
vicmcorrea:dev/fix-show-layout-cache

Conversation

@vicmcorrea

Copy link
Copy Markdown
Contributor

Why

the pure main in #1129 prints garbage and can fault natively, while the interpreter and JS print the right value. Array elements and direct values can have different field layouts even when their type and top-level boxing match.

i'm evaluating Bend alongside our TypeScript monorepo and reproduced this while comparing native and JS output.

Fixes #1129.

Scope

Cache show_main's descriptors by the existing layout object and normalized type, using memo for each layout's entries. One net compiler line, no new helpers, and an update to the existing explanatory comment.

Two short regressions cover array-first and value-first traversal, with one-constructor and two-constructor types. Existing tests stay intact.

Blast radius

The display descriptors for pure-main results. The change separates layouts that need different field offsets and child descriptors. IO mains have no display descriptor.

Verification

On macOS arm64, Bun 1.3.11 and clang 23.1.2:

  • Both regressions fail natively on e41fa7b. With the fix, checking, interpreter, emitted JS and native execution pass.
  • Eleven existing tests pass, covering readback, arrays and wide records. Their generated C is byte-identical before and after the fix.
  • bun gates/repo.ts: 49/49. git diff --check passes. Compiler size is 63,981/64,000 tokens, 14 more than the base.

Cluster, GPU and benchmark gates were not run.

@nicolas-abril nicolas-abril self-assigned this Sep 28, 2026
…out object

The key already names the type; putting the layout's JSON beside it
replaces String(box) in one line and shares a node between equal layouts
reached by different paths. The emitted C and JS match the nested map
on every test. A parameterized sum type witnesses the bug beyond Sigma.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C lane: showing a pure main of an Array of ((U32, D), Unit) paired with one more such value prints garbage, then a memory fault

2 participants