Repository navigation
Start a recursive array record as an empty array - #9232
Conversation
Changelog🐛 Bug fix
Semantic Diff1 commit · Full page Start a recursive array record as an empty array628013a · cknitt + Claude · Nov 05, 2026, 05:55 UTC Fable review: a recursive value starts as an empty placeholder that is filled in afterwards, and the placeholder of every record was JS modified (recursive array record) type rec cell = {@as("0") value: int, @as("1") next: cell}
let rec cell = {value: 1, next: cell}
-let cell = {};
+let cell = [];
cell[0] = 1;
cell[1] = cell; |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9232 +/- ##
=======================================
Coverage 81.74% 81.74%
=======================================
Files 457 457
Lines 65564 65566 +2
=======================================
+ Hits 53595 53597 +2
Misses 11969 11969
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
cristianoc
left a comment
There was a problem hiding this comment.
Just make sure this is sound.
There are ways of treating empty array unsoundly.
Though this looks like back-end code so you just need to check that the generated code is OK.
Fable review: a recursive value starts as an empty placeholder that is
filled in afterwards, and the placeholder of every record was `{}`, so a
`let rec` of an array record stayed an object. It is now `[]` for an
array record. An array record in an arrow body also no longer gets the
parentheses an object literal needs.
JS modified (recursive array record):
Example:
type rec cell = {@as("0") value: int, @as("1") next: cell}
let rec cell = {value: 1, next: cell}
Before (js):
let cell = {};
cell[0] = 1;
cell[1] = cell;
After (js):
let cell = [];
cell[0] = 1;
cell[1] = cell;
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gLWSz9kGHhX9sue9WB
Signed-off-by: Christoph Knittel <ck@cca.io>
e3841b9 to
628013a
Compare
|
@cristianoc I checked the generated code and ran it in Node. The empty
Untagged dispatch on a recursive value ( The placeholder is the same |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9232 |
Follow-up to #9224 from a review that finished after it merged.
A recursive value starts as an empty placeholder, which is filled in afterwards: by index for constant fields, otherwise by
Object.assign.dummy_objmade that placeholder{}for every record, so alet recof an array record (fields with the runtime names"0","1", …) stayed an object. This was already the case before #9224, but it is the last place that broke the invariant that a value of aRecord_arraytype is a JavaScript array. The placeholder is now[]for an array record, andObject.assignkeeps an array target an array.Also: an array record in an arrow body no longer gets the parentheses an object literal needs (
a => ([a, b])becomesa => [a, b]).New tests in
array_record_test.rescheckArray.isArrayfor a recursive array record built at top level (constant fields) and inside a function (a variable field, the other placeholder path).🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gLWSz9kGHhX9sue9WB