Pin current object-field mutability behavior ahead of representation cleanup - #8585
Pin current object-field mutability behavior ahead of representation cleanup#8585cristianoc wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0c48d537b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| See docs/object_representation_cleanup.md. */ | ||
| type wide = {"a": int, "b": int} | ||
| type narrow = {"a": int} | ||
| let p = (v: {@set "x": wide}) => (v :> {@set "x": narrow}) |
There was a problem hiding this comment.
Register the new fixtures in the error catalog
The new object fixtures exercise the Not_subtype and Undefined_method variants, but tests/ERROR_VARIANTS.md is unchanged, so the repository’s primary coverage catalog no longer reflects all fixtures that cover those variants. Add these fixtures to the corresponding catalog rows as required by the repository guidance.
AGENTS.md reference: AGENTS.md:L197-L200
Useful? React with 👍 / 👎.
| in the field type — with unequal types it is rejected (today the setter | ||
| member demands contravariance while the getter demands covariance). Must | ||
| stay an error under the new model (Mutable A <: Mutable B iff A = B). | ||
| See docs/object_representation_cleanup.md. */ |
There was a problem hiding this comment.
Replace the missing object-cleanup document reference
These pinning fixtures repeatedly direct maintainers to docs/object_representation_cleanup.md, but a repo-wide file search finds no such document or generated artifact. This leaves the rationale for the deliberately temporary expectations behind a dead reference; include the design document or replace the reference with a durable link to the documented #8584 design.
Useful? React with 👍 / 👎.
…cleanup Add behavior-pinning tests for the structural-object mutability semantics (currently encoded via phantom "x#=" setter members), ahead of the staged representation cleanup proposed in #8584. tests/tests/src/object_mutability_pin.res pins the compiling cases: closed mutable-to-immutable covariance, open-source and open-target coercions, assignment- and coercion-driven strengthening of open rows, and a generalized getter used at both mutabilities. Two cases are marked EXPECTED TO FLIP with the rationale in place: the unequal-type coercion and the unrelated-type assignment (getter int acquiring setter string), which today produces a value of declared type int that is the string "hello" at runtime - the type-preservation failure the cleanup closes. Seven super_errors fixtures pin the rejecting directions: closed-row writes, both-open invariance, readonly-to-mutable coercions, mutable-to-mutable invariance with unequal types, read-only callers against strengthened rows, and writes after a closed-source-to-open-target coercion. Part of #8584. Signed-Off-By: Cristiano Calcagno <ccrisccris@gmail.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PCtQiaDijUqA2fujQXvKUw
d0c48d5 to
ac9c310
Compare
First PR of the object-representation cleanup series designed in #8584: behavior-pinning tests only, no compiler changes.
tests/tests/src/object_mutability_pin.respins the compiling mutability cases (closed mutable→immutable covariance, open-source/open-target coercions, assignment- and coercion-driven strengthening of open rows, a generalized getter used at both mutabilities). Two cases are commented EXPECTED TO FLIP with their rationale: the unequal-type coercion({.."x": wide} :> {@set "x": narrow})and the unrelated-type assignment where getterintacquires setterstring— today this compiles and returns"hello"at declared typeint(the type-preservation failure documented in RFC: Objects from first principles — end-to-end representation cleanup #8584 §2.7). The cleanup's Stage D turns both into compile errors.super_errorsfixtures pin the rejecting directions: closed-row writes, both-open invariance, readonly→mutable coercions, mutable-to-mutable invariance at unequal types, read-only callers against strengthened rows, and writes after a closed-source→open-target coercion (whose result row is closed — what makes that covariant coercion sound).Every pinned behavior was verified against the current compiler by probe; the fixtures' expected outputs are generated by the standard
super_errorsrunner.Stacked on #8582 (base:
ffi-dynamic-import) so the whole series shares one base, per the plan in #8584.Part of #8584.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PCtQiaDijUqA2fujQXvKUw