Skip to content

Checker rewrite R3: design of pattern mode, equations and instance_poly - #347

Merged
jfrolich merged 9 commits into
ocaml-to-rust-rewritefrom
checker-rewrite-r3-design
Nov 17, 2026
Merged

jfrolich merged 9 commits into
ocaml-to-rust-rewritefrom
checker-rewrite-r3-design

Conversation

@jfrolich

@jfrolich jfrolich commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Sixth skeleton (design) turn of slice R3 of the checker rewrite (compiler-rust/docs/CHECKER_REWRITE.md, section 8). It records the reviews of R3g and R3p, corrects three faults in built code, adds the harness for pattern mode, and designs pattern mode as two slices with acceptance tests and build prompts.

Not done: E5, the instance_poly slice (R3q). It has its row in 8.1 and no design. E0 to E4 are complete.

cargo test --lib tc::: 265 passed, 0 ignored on the starting trunk; 281 passed, 0 failed, 15 ignored at the end (ten for "R3h build", five for "R3r build"). That run was made on the tree before the default branch was merged in; the merge touches only compiler-rust/src/bir. cargo clippy --all-targets and cargo doc with warnings denied are clean.

Per deliverable

Result Ran
E0 Decisions 53 to 57 (what the reviews of R3g and R3p put on record); 8.1 has R3g and R3p merged and R3q as its own row doc only
E1 Decisions 58 to 60: three corrections with running tests, listed below all run and pass
E2 Decisions 61 and 62: plan bit PATTERN, Op::Gadt, both sides print the equations, Fault::ExpressionMode; nine running tests all run and pass
E3 Section 8.9 and decisions 63 to 71; skeleton signatures compiles; nothing to run
E4 15 ignored tests and two build prompts in 8.4 not run: no prototype was made. They compile and ignored_tests_name_the_slices_they_reach passes
E5 not done

E1(f): the explaining mode stays out of univar_plan_agrees_on_generated_cases; nothing changed there.

E1: corrections of built code

  • split_univars dropped a type OCaml keeps (decision 58). What two Reither fields gain is decided before the types that hold a universal variable are unified (compiler/ml/ctype.ml:2685-2706). The kept types are now written after the pair's record and read back by the second run of join_either. Tests: differential::tests::old_checker_gains_a_type_the_holders_made_a_duplicate, r3_tests::a_field_gains_what_it_lacked_before_the_holders_were_unified (2 types instead of 3 without the fix).
  • free_univar was exponential (decision 59). A polymorphic type without bound variables opened a context, so a chain of n took 2^(n+1) − 1 visits (observed 2047, 4095, 2097151 for n = 10, 11, 20). It now takes exactly 2n + 1, as OCaml (ctype.ml:1587-1589). Test: r3_tests::the_walks_for_universal_variables_at_ten_thousand.
  • The arguments of a stale row name were children (decision 60). iter_row reaches them only for the innermost row (compiler/ml/btype.ml:229-241). New Checker::drop_name_children, called by unify_row. Test: r3_tests::the_arguments_of_a_stale_row_name_are_not_children, one block per walk.
  • Also added: a row walked by free_univar, and split_univars with passive_variants set and holders on both sides.

Skeleton signatures, costs and tests changed

  • Checker::reify returns Result<(), Clash>: it can fail (ctype.ml:1837-1839).
  • Checker::unify_gadt now delegates to the new Checker::unify_pattern(newtype_level, generate, injective, left, right).
  • New on Checker: newtype_level, equations, locals, tries, compatible; cut_equations, recover, duplicate, non_recursive_abbrev, find_newtype_level, push_compatible, drop_name_children.
  • New types: rows::{Equation, DeclMatch, LocalDecls}, unify::Try, FrameKind::{Flags, Try}.
  • expand.rs: flag LOCAL (bit 7), TypeTable::{set_local, non_aliasable, instantiable, injective, injective_bits}. from_segment does not set LOCAL.
  • Cost: unify_row makes two more compares per pair of rows; free_univar went from exponential to linear on the chain above.
  • Harness: compare runs a PATTERN case only on the prefix the old checker is a judge of (old_judges).
  • ignored_tests_name_the_slices_they_reach knows R3q and R3r.

Old-checker differences from OCaml met

Difference Smallest case OCaml lines Source program
Ambiguity of GADT instances is not checked: a program OCaml refuses is accepted below ctype.ml:176-201, 1220-1227, 2289-2298 yes, below
Two structures unified in pattern mode become one node; OCaml records an assumed equality and links neither two instances of (int, int); [#A(n0) | #B] against [#A(int) | #B] ctype.ml:2327-2331 none found; three tried, both compilers accept all
The arm of unify for two locally abstract types (expand the newer one once) is missing none that changes a result ctype.ml:2258-2270 none
lower_scoped does not drop the name of a row whose path escapes (new kernel, not the old checker) a named row whose type has a scope ctype.ml:618-623 none
type rec t<_> = Int: t<int>
let f = (type a, x: t<a>, y: a) =>
  switch x {
  | Int => if true { y } else { 0 }
  }

OCaml: "This instance of int is ambiguous: it would escape the scope of its equation". The Rust compiler accepts it.

Not established: for decision 58's source program OCaml's diagnostic prints two types where an instrumented build showed three in the field; the cause was not found.

Arms no hand-built test reaches

The object-type arm of reify (not built: no kernel type has such a path); mcomp of two fields; a parameter past the 32nd of injective_bits; LocalDecls::compare answering Members for two open types; a reified variable with a name printing as $'a (the supplier is asked with the name, the spelling is the supplier's); objects and arrows with labels in pattern mode; the package fallback of decision 63.

Open questions, with a recommended answer

  1. Ambiguity of GADT instances. Recommended: a slice of its own after R3r, designed with R3q.
  2. The old checker links structures in pattern mode. Recommended: keep old_judges; the hand-built tests judge a structure pair that succeeds.
  3. free_univar revisits a node per context of a polymorphic type with bound variables, as OCaml. Recommended: accept.
  4. lower_scoped and the escaping row name. Recommended: a correction with a hand-built test in the turn that designs R3q.
  5. duplicate is generalize plus copy under a speculation, which holds only if generalize writes nothing but levels through the trail. Recommended: the builder of R3h reports; otherwise a copy-everything flag in Graph::copy_ref.

Decisions for review to confirm

  1. split_univars writes the kept types for the second join.
  2. A polymorphic type without bound variables opens no context.
  3. The arguments of a row's name are children only of the innermost row.
  4. The PATTERN harness.
  5. Where the old checker is a judge in pattern mode, and the old_judges cut.
  6. package_end is unchanged; pattern mode reifies where a completion is missing.
  7. What replaces the link per arm of unify3; pattern loaded once in unify_expanded; the two swap tests stay identity tests.
  8. The arm for two locally abstract types sits in unify_pair and costs one load for two nullary constructors of different types.
  9. LOCAL, injective_bits, and expands_to_datatype read as the DATATYPE flag of the head's row.
  10. An equation is a manifest whose body is a generic copy; equations are not on the graph's trail; the caller cuts.
  11. The two arms that try are frames with a Try record; a backtrack does not cut equations.
  12. No occurrence test for a structure pair in pattern mode.
  13. mcomp, its own table, and a clash for two data types without a supplier.
  14. What a unit that never types a pattern pays.

Also to confirm: the cut into R3h and R3r (a slice name has one letter because the check of ignored tests reads three characters).

Uncertain, and said in the prompts: whether unify_row and its frames read the left node as a link (they were built with it linked; rows_that_clash_are_reified_and_compared is the test), and where a callee's trace pair goes in Mode::Explain for reify's clash.

Started by Jaap Frolich in this Assistant session

open-session-submodule Bot and others added 8 commits November 17, 2026 22:00
…ns 53 to 57)

Section 8.6 gets what the reviews of the fifth skeleton turn and of the
two slices built from it put on record: the join that split_univars puts
off (53), the two gained ranges lowered each on its own (54), the
descriptor package_end reads (55), the contexts of free_univar (56) and
the bench record of R3g with the rule that no prompt prescribes a remedy
for a figure that moves (57). Section 8.1: R3g and R3p merged, and the
instance_poly slice as a row of its own (R3q).

Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-9da31a3c-0d3b-7546-bc8e-f1fd3a9270ee
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
…he reviews left owed (decisions 58 to 60)

What two Reither fields gain is decided before the types that hold a
universal variable are unified (compiler/ml/ctype.ml:2685-2706): the
kept types are written after the pair's record and the second run of
join_either reads them back. OCaml keeps a type those unifications made
a duplicate; the kernel dropped it.

free_univar opens no context for a polymorphic type without bound
variables (ctype.ml:1587-1589). With one, a type shared between the
inside and the outside of such a type was visited again at every level:
2^(n+1) - 1 visits on a chain of n, where OCaml and now the kernel make
2n + 1.

The arguments of a row's name are children only of the innermost row
(iter_row, compiler/ml/btype.ml:229-241): unify_row rewrites the home
node of a named row that gained a variant tail.

Tests, all running: the old checker's side of the first and the third,
one hand-built case per walk, a row walked by free_univar, the split
with passive variants, and the step relations of free_univar and
univars_escape at 1,000 and 10,000.

Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-9da31a3c-0d3b-7546-bc8e-f1fd3a9270ee
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
…ker does in it (decisions 61 and 62)

A plan bit PATTERN: programs with two locally abstract types of two
newtype levels, an abstract type with a parameter and a data type;
Op::Gadt for one pattern unification with the two flags of
set_mode_pattern; both sides print the equations in force.

The skeleton of R3h's entry: Checker::unify_pattern (unify_gadt calls
it), the equations log, the supplier of declarations LocalDecls, the
LOCAL flag with TypeTable::instantiable. Bodies are R3h's.

Running tests record what the old checker does: which pairs get an
equation and in which direction, what reify makes, what a failure
leaves, rows that clash and are compatible. It links two structures a
pattern unification unifies, where OCaml records an assumed equality:
old_judges cuts a case before such an operation.

Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-9da31a3c-0d3b-7546-bc8e-f1fd3a9270ee
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
…eir acceptance tests and build prompts (section 8.9, decisions 63 to 71)

Section 8.9: the state of pattern mode and what a unit that never
types a pattern pays; what replaces the link in each arm of unify3;
the arm of unify for two locally abstract types; an equation as a
manifest whose body is a generic copy, its log and its cut; reify;
the two arms that try and fall back as frames, not recursion; mcomp
with a supplier that compares declarations, and a clash without one.

Two slices: R3h (state, equations, reify, the arms without a
backtrack) and R3r (mcomp and the two arms that try). Skeleton:
FrameKind::{Flags, Try}, Try, Checker::{cut_equations, recover, tries,
compatible, duplicate, non_recursive_abbrev, find_newtype_level,
push_compatible}, TypeTable::{injective, injective_bits}; reify can
fail. Bodies are todo.

Fourteen ignored tests: eleven hand-built, two step tests at 1,000 and
10,000, and the generated cases of the pattern plan. No prototype was
made: they compile and the check of the ignored tests passes.

Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-9da31a3c-0d3b-7546-bc8e-f1fd3a9270ee
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-9da31a3c-0d3b-7546-bc8e-f1fd3a9270ee
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-9da31a3c-0d3b-7546-bc8e-f1fd3a9270ee
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
…esigned

Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-9da31a3c-0d3b-7546-bc8e-f1fd3a9270ee
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-9da31a3c-0d3b-7546-bc8e-f1fd3a9270ee
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
@jfrolich
jfrolich marked this pull request as ready for review November 17, 2026 23:22
@jfrolich

Copy link
Copy Markdown
Owner Author

First-pass checklist review at df56d4a (a checklist for the final reviewer, not an approval).

First-pass review (checklist, not an approval):

Setup: git fetch origin; D=origin/ocaml-to-rust-rewrite...origin/checker-rewrite-r3-design; git diff $D > pr.diff (4,049 lines). Files read with git show origin/checker-rewrite-r3-design:PATH. OCaml line numbers were checked on the branch and on trunk 61f7f41292, the trunk the document names; the function starts are the same in both. Nothing was built or run on the host. The branch is one trunk commit behind (109b2bd4cd, #348). git merge-base --is-ancestor origin/ocaml-to-rust-rewrite origin/checker-rewrite-r3-design exits 1. That commit does not touch src/tc.

1. Scope: PASS

  • E0: decisions 53–57 at CHECKER_REWRITE.md:4434-4490; 8.1 rows updated.
  • E1: decision 58: rows.rs split_univars writes the kept types (rows.rs:3186-3211 on the branch), and join_either reads them back (rows.rs:2213-2232). Decision 59: push_free_univar_children gets a Poly if arity == 1 arm (rows.rs, "Tpoly (ty, []) adds nothing" hunk). Decision 60: drop_name_children (rows.rs:1566), called from unify_row (rows.rs:1503-1514). Tests are in r3_tests.rs.
  • E2: PATTERN, Op::Gadt, Fault::ExpressionMode (differential.rs diff +42), old_judges (diff +221), and nine running tests.
  • E3: section 8.9 (doc.md:5081-5430), plus skeleton signatures in rows.rs, unify.rs and expand.rs.
  • E4: 15 #[ignore] tests (14 in r3_tests.rs, 1 in differential.rs), and the R3h/R3r prompts at doc.md:3030-3146.
  • Not done, as the body says: E5 (instance_poly, R3q). It has a row in 8.1 and no design.
  • Done beyond the task: none found. A refactor of differential.rs (type_name, run_old_until, Old made pub(crate)) serves E2.

2. Default path: PASS (not applicable: design PR)

No build calls the new kernel under compiler-rust/src/tc (the PR body says so and nothing outside src/tc and tests calls unify_pattern/reify, see 14f). Every changed function (unify_row, join_either, split_univars, free_univar, Checker::new, TypeTable field) runs only in tc:: tests. The body reports no measurement, and none is needed for code no build runs. Instruction count: −0.023% (section 22).

3. Engineering standard (added production lines of rows.rs, unify.rs, expand.rs)

  • (a) Cost in the doc comment: PASS. Every new function states one: drop_name_children "O(slots of the node)", injective/instantiable/non_aliasable O(1), set_local O(1), and each todo! function. unify_row's own "Cost:" paragraph (rows.rs ~1380) was not updated for the two compares of decision 60; they are stated only in drop_name_children's doc and in decision 60.
  • (b) Step test at 10,000 for each new loop: UNCLEAR. The fix of free_univar has the_walks_for_universal_variables_at_ten_thousand, which asserts shared(10_000) == 2*10_000+1. Three new loops have no step test: the loop of drop_name_children over slots, the kept-types loops of split_univars and join_either, and non_recursive_abbrev/duplicate/recover (see 14c).
  • (c) HashMap/HashSet/BTreeMap: Checker::compatible: PairSet (an AHashSet), with its reason in 8.9 decision 70 ("ORDERED pairs"; pairs have no dense index, doc.md:5106). old_structures uses std::collections::HashSet (differential.rs, test-only module). PASS.
  • (d) Allocation inside a walk: none of Vec::new/vec!/format!/Box::new/non-Copy .clone() in production lines. The arena growth sites are g.lists.extend_from_within in drop_name_children (one list per named row with arguments that gains a tail, not per node of a walk), saved.push in split_univars, and row_scratch.push in join_either. PASS.
  • (e) Lock/atomic/thread_local/RefCell: none in production. Rc<RefCell<Vec<..>>> appears only in tests (r3_tests Fresh, differential FreshNames). PASS.
  • (f) Second pass: duplicate is "three passes over ty" by design (decision 67, step 2), and it is recorded. PASS.
  • (g) size_of: FAIL. Equation ("20 bytes; one per equation", rows.rs) and unify::Try ("40 bytes; one per open attempt") have no size_of test. grep -rn "size_of::<" src/tc finds only TypeInfo 16 (expand.rs:2056), Frame 16 and FrameKind 4 (unify.rs:1753-1754). Those last two still hold with the two new kinds.
  • (h) Added: 13 todo!("R3h"|"R3r"), 15 #[ignore = "R3x build"]. No allow(, unsafe or unimplemented!. This is expected for a skeleton.

4. Tests and oracles: PASS

grep -n "^-" r3t.diff is empty: no line of r3_tests.rs is removed. In differential.rs the removed lines are a refactor: Old became pub(crate); the renamed vector was hoisted; the path-name printing moved to type_name; run_old now calls run_old_until; the before table grew from 10 to 12 entries. No assertion was removed, and no run_cases_except list changed. The ratchet files (backend_coverage.txt, printer_coverage.json, tc_coverage.txt) and .github are not in the diff: git diff $D -- … is 0 lines.

5. New scripts and fixtures: not applicable

None was added.

6. Privacy: PASS

grep -n -i -E "tella|submodule\.nl|rescript-bench-corpus|/Users/|opensession|jake" pr.diff gives 0 hits. The PR body's footer has a Session URL, which is allowed.

7. Changelog: PASS

changes/checker-rewrite-r3-skeleton-6.internal.md is one line starting "- ". CHANGELOG.md is untouched.

8. Numbers in the body: UNCLEAR

Figure Command and output shown?
265 passed at the start; 281 passed / 15 ignored at the end No output pasted. CI confirms 281 tc:: ok and 15 ignored (section 22).
2047, 4095, 2097151 visits for n = 10, 11, 20 "observed". No command shown, and the run predates the fix.
exactly 2n+1 Asserted by the_walks_for_universal_variables_at_ten_thousand.
"2 types instead of 3 without the fix" "observed". No output shown.
64 of 1,200 cut; 950/493; 130/3/183; 228/21/58 In test doc comments and println!. The asserts are lower bounds only. No output in the body.
"two more compares per pair of rows" Reading only.

9. Focused tests: not run (host review)

CI results are in section 22.

10. Where I would look hardest

  1. Decision 67 step 1 and a_recursive_equation_is_not_added, against local_non_recursive_abbrev (ctype.ml:1503-1536). OCaml calls it with strict = false. A non-Tconstr node is entered only if strict (1525-1529). So n0 against (n0, int) (a tuple at the top) raises no Occur, and OCaml adds the equation. The test expects c.equations.is_empty(), and the design's step 1 ("does not name source through its children") has neither the strict flag nor the is_contractive cut (1509). It also expands with try_expand_once, not _opt (1515). The design cites "1478-1535"; 1478-1502 are occur_full, occur and occur_in. This is the first-hand-built-test-disagrees case, and the R3h prompt tells the builder to stop on it. I would rule on it before R3h starts.
  2. The occurrence test of a variable in pattern mode. Decisions 64 and 69 say the variable arms run the occurrence test "as in expression mode". OCaml's occur in Pattern runs occur_full with allow_recursive = true (1468, and no occur_cannot_fail shortcut at 1489). occur_rec then neither enters a structure (1405) nor a contractive constructor (1390). So OCaml binds 'a := ('a, int) in pattern mode where expression mode clashes. grep -n "allow_recursive\|is_contractive" doc.md src/tc/*.rs finds nothing: the difference is not recorded.
  3. Decision 60's homes for row 1 in pattern mode. unify_row takes [_, t2x] and skips row 1 when last1 == NONE (rows.rs:1506). That is right only because unify3 has linked the left node to t2x in expression mode. In pattern mode the left node is not linked (decision 64), so its row's more becomes a variant node and its name's arguments stay children. That is the stale-name fault of decision 60 again. The body lists "whether unify_row reads the left node as a link" as uncertain, but no decision covers the name side.

11. Files: PASS

git diff --stat $D lists 7 files: changes/checker-rewrite-r3-skeleton-6.internal.md, compiler-rust/docs/CHECKER_REWRITE.md, and compiler-rust/src/tc/{differential,expand,r3_tests,rows,unify}.rs. Nothing is under src/types or elsewhere.

12. E1, the three corrections: PASS (one note on 60)

58: split_univars keeps what OCaml keeps.

  • Old code: missing(self, middle..end, base..middle); let gained1 = end..len; missing(self, base..middle, middle..end); let gained2 = … ran on both runs.
  • New code: if record.b & ROW_UNIVARS != 0 { let counts = self.saved[frame.extra + 1]; … push FieldRef{ty: Ty(self.saved[at].head)} … (end..end+counts.head, end+counts.head..len) } else { missing(...) … }. split_univars's (false,false) arm now pushes Node{head: kept1.len(), level: kept2.len(), ..}, then one Node{head: ty.0, ..} per kept type.
  • OCaml (ctype.ml:2684-2706): tl1' = remq tl1 tl2, then let tl1', tlu1 = split_univars tl1', then List.iter (unify env tu1) (tlu1 @ tlu2), then f1' = Reither (…, tl1', …). The lists are computed before the holders are unified. SAME: the kept ranges equal OCaml's post-split tl1'/tl2', and holders are gained by neither side.
  • Storage: written to saved directly after the pair's record. debug_assert_eq!(self.saved.len(), frame.extra + 1), which holds because the pair's RowFieldEnd frame is on top and row_field_end cuts to extra + 1 before a re-join (rows.rs:2297). Read back by join_either's second run from row_field_end's ROW_UNIVARS branch, which then calls saved.truncate(extra) (rows.rs:2310-2317).
  • Error paths: a clash while the holders are unified returns Err through run_frames, and unify_distinct calls self.saved.truncate(saved_base) (unify.rs:313-314). unify_row's own error path truncates to its entry length (rows.rs:1497-1498). Nothing is left behind. Bound: one entry plus one per kept type, 16 B each, per open pair.
  • Test: r3_tests::a_field_gains_what_it_lacked_before_the_holders_were_unified, with assert_eq!(tags[0].1.types, 3) and assert_eq!(types, [repr(holder1), x, x]). The 3 follows from OCaml: tl1 = [(u,x); x], kept tl1' = [x'], and row_field_repr concatenates the chain, so the field is [(u,x); x; x'] with x' ≡ x. The old-side witness is differential::tests::old_checker_gains_a_type_the_holders_made_a_duplicate.

59: free_univar and polymorphic types without bound variables.

  • New code: ExtraDescriptor::Poly if arity == 1 => { self.g.work.push(self.g.lists[node.b]) }, placed before the old Poly arm (new generation, open_polys.push(true)).
  • OCaml (1587-1589): Tpoly (ty, tyl) -> let bound = List.fold_right Type_set.add tyl bound in occur_rec bound ty. With tyl = [], bound is unchanged, and the visited test (1569-1581) skips a node already seen with the same bound. SAME.
  • The cost note "exactly 2n + 1" is true for the test's chain t(i+1) = (poly(t(i)), t(i)): 2 nodes per level plus u. It is asserted at 1,000 and 10,000.
  • A polymorphic type WITH bound variables still opens a context: it keeps the second arm. Decision 59 and open question 3 say OCaml also revisits there. See section 20 on decision 56 for a nuance.

60: the arguments of a stale row name.

  • New code: in unify_row, after both set_more calls: let homes = [(fixed1 || last1.0 == NONE, row1, last1), (fixed2, row2, if last2.0 == NONE { t2x } else { last2 })]; for … if !kept && row.name != NONE && row.name_arguments.len != 0 { self.drop_name_children(home, row) }.
  • drop_name_children (#[cold] #[inline(never)]): in Explain mode it pushes the node twice to saved plus a Fields frame. It copies the node's slots to a new list with extend_from_within, fills the name-argument slots with the more slot, and calls g.write(home, Node{b, ..node}).
  • OCaml btype.ml:229-241: match (repr row.row_more).desc with Tvariant row -> iter_row f row | Tvar _ | … -> Misc.may (fun (_, l) -> List.iter f l) row.row_name. The name's arguments are visited only for the innermost row. SAME in expression mode. See section 10.3 for the pattern-mode gap.
  • Test: r3_tests::the_arguments_of_a_stale_row_name_are_not_children, e.g. assert_eq!((level(named), level(y)), (1, 2), "lower"). The expectation follows from OCaml (update_level goes through iter_type_expr→iter_row).
  • Cost: "two compares per pair of rows" is stated in drop_name_children's doc ("a row without a name with arguments costs the two compares of the caller") and in decision 60. It is not in unify_row's Cost paragraph, and there is no step test (it is a constant per row pair; drop_name_children itself is O(slots), with no 10,000 test).

13. What a unit without the feature pays: PASS (with omissions noted)

Added production lines and their path class:

  • rows.rs unify_row homes plus loop: (a), variant rows only. 2 rows × (one fixed/NONE test, one name != NONE compare, one branch); row2 adds a select on last2.
  • drop_name_children: (a), named rows with arguments.
  • join_either: the record.b & ROW_UNIVARS branch and the read-back: (a), two Reither fields.
  • split_univars writes: (a), universal variables.
  • push_free_univar_children Poly if arity == 1: (a). free_univar is never called when extras.univars == 0.
  • expand.rs injective, set_local, non_aliasable, instantiable: called by no built code.
  • (b), ordinary unification: none in this diff. The two new FrameKind arms in run_frames cost nothing until pushed.
  • Once per checker or table, not per pair: Checker::new initialises newtype_level, equations, locals, tries, and compatible: PairSet::default(), which constructs an ahash RandomState. TypeTable gains injective_bits: Vec<u32>.

Decision 71 (doc.md:5371-5380) lists the future R3h reads: none in unify_expanded/unify3; one equations.len() load in unify_pair for nullary constructors of different types; one compare in subst; tries.len() on the failure path; and "three empty Vecs and two empty sets". It leaves out:

  • the RandomState construction in Checker::new;
  • the growth of size_of::<Checker>();
  • the variant-row cost of decision 60, which a unit with variants and no patterns pays (stated in 60, not in 71).

14. The skeleton

(a) todo! list on the branch. grep -n 'todo!("R3' src/tc/*.rs:

File:line Slice Function
rows.rs:3423 R3h reify
rows.rs:3434 R3h add_gadt_equation
rows.rs:3443 R3h non_recursive_abbrev
rows.rs:3453 R3h duplicate
rows.rs:3461 R3h find_newtype_level
rows.rs:3470 R3r mcomp
rows.rs:3477 R3r push_compatible
unify.rs:1006 R3h pattern branch in unify3
unify.rs:1316 R3h unify_pattern
unify.rs:1328 R3h cut_equations
unify.rs:1344 R3r recover
unify.rs:1568 R3h run_frames Flags arm
unify.rs:1573 R3r run_frames Try arm

There are also R3i/R3j todo!s in relate.rs (unchanged). PASS.

(b) #[ignore] tests. All say "Reaches:" with slices built before them (checked against the before table):

  • R3h (all Reaches: R3h): an_equation_goes_to_the_locally_abstract_type_and_links_nothing, of_two_instantiable_types_the_newer_gets_the_equation, the_body_of_an_equation_is_a_generic_copy, reify_makes_one_type_for_each_variable_in_visit_order, reify_links_a_variable_below_the_newtype_level_and_clashes, the_arguments_of_one_type_are_unified_by_the_flags, two_structures_are_assumed_equal_and_not_linked, the_newer_of_two_locally_abstract_types_is_expanded_once, a_recursive_equation_is_not_added, pattern_mode_at_ten_thousand.
  • R3r:
    • an_argument_that_is_not_injective_is_tried_and_then_reified (R3h, R3r)
    • rows_that_clash_are_reified_and_compared (R3f, R3h, R3r)
    • mcomp_answers_by_the_declarations (R3r)
    • mcomp_at_ten_thousand (R3r)
    • differential::tests::pattern_plan_agrees_on_generated_cases (R3m, R3e, R3f, R3n, R3h, R3r)
  • ignored_tests_name_the_slices_they_reach is present. The diff: [(&str, &[&str]); 10] became 12, adding ("R3q", &["R3m","R3e","R3f","R3n","R3g"]) and ("R3r", &[…,"R3h"]), and the needle list gained ("PATTERN", "R3h"). It pins no number of ignored tests: ignored is counted, never asserted, with the comment "The number itself is not pinned". PASS.

(c) Step tests for the cost of R3h/R3r functions. UNCLEAR.

  • unify_pattern: pattern_mode_at_ten_thousand "structures", large <= 11*small.
  • reify: same test, "reify".
  • add_gadt_equation + cut_equations: same test, "equations". Each destination is nullary int, so non_recursive_abbrev and duplicate ("O(nodes reached)", "three passes over ty") get no large destination: not covered.
  • find_newtype_level and push_compatible: O(1), none needed.
  • recover ("O(frames above the record + writes restored)"): no step test.
  • mcomp: mcomp_at_ten_thousand. Its doc says "two tuples of n elements" and that "the table makes the second and every later pair … one lookup … not n times the depth". The body builds vec![a; 100]: width 100, not n. Without the table the cost is 100·n, which is still linear in n, so large <= 11*small passes with or without the compatible table. The test does not discriminate what its doc claims.

(d) Items a todo! body must reach in another file. FAIL (one item).

  • mcomp (rows.rs): decision 70 says "a popped marker calls leave_scopes", and the R3r prompt says "calling leave_scopes anywhere but in recover and mcomp's marker". Checker::leave_scopes is private: fn leave_scopes at unify.rs:417 is not visible from rows.rs. It also finds its LeavePoly frame in frames[base..], which mcomp has already popped by design.
  • Everything else is visible: cleanup_abbrev (pub, expand.rs:602), generalize/copy/expand_once/expand_head (pub, expand.rs), Graph::{link, speculate, keep, restore} (pub), Checker::restore (pub, unify.rs:1219), fresh_marks (pub(super)), flatten_row/merge_rows/flatten_fields/enter_poly/unify_univar/open_row/copy_refs (pub, rows.rs), PairSet::keys (pub). push_pair (private, unify.rs:1425) and subst (private, expand.rs:847) are used only from their own files.

(e) Sizes. FAIL: Equation (stated 20 B, one per equation) and Try (stated 40 B, one per open attempt) have no size_of test. FrameKind still has its test (4). DeclMatch is a fieldless return value; LocalDecls is a trait.

(f) Changed signatures. reify(&mut self, ty) -> Result<(), Clash> (was ()). unify_gadt now calls unify_pattern(newtype_level, true, true, ..). git grep '\.reify(\|\.unify_gadt(\|\.unify_pattern(' origin/checker-rewrite-r3-design -- compiler-rust/src finds only r3_tests.rs and differential.rs:2015. No caller outside tests. PASS.

15. No pinned counts: PASS

Added asserts on counts:

  • assert_eq!(coverage.cases, 10_000) is the run size.
  • assert_eq!(program.values.len(), 7) and outcome.failed == Some(9) describe the fixed program.
  • old_side_of_the_pattern_plan_is_not_vacuous checks whole >= 380 && cut >= 20 && ok >= 300 && failed >= 160 && equation >= 40 && two >= 1 && reified >= 60, and generated_cases_find_a_pattern_unification_in_expression_mode checks cases >= 75 && equation >= 7 && refused >= 19. These are lower bounds on the old side only, which no R3 slice changes.
  • assert_eq!(c.equations.len(), 1|2|n) and asked.borrow().len() == n are invariants of one case.
  • shared(n) == 2n+1 is an invariant.

No count of ignored tests or pinned seeds. pattern_plan_agrees_on_generated_cases calls run_cases_except(…, &[]) with no seeds.

16. OCaml citations: UNCLEAR (several drift)

Read on the branch (awk 'NR>=A && NR<=B' ctype.ml).

Right:

  • reify 1813-1859, failure 1837-1839
  • non_aliasable 1870-1872
  • is_instantiable 1874-1881
  • mcomp 1905-2080 (helpers 1967-2078)
  • find_newtype_level 2084-2091 (cited as 2085-2091)
  • add_gadt_equation 2093-2100
  • unify_eq 2205-2214
  • the two-newtypes arm 2258-2270
  • unify3's Pattern arm 2327-2332
  • unify_gadt 2739-2750
  • occur 1467-1490
  • set_mode_pattern 256-273
  • 2685-2706, 1587-1589, btype 229-241, 2189-2202

Off by about 3 lines, and the cut-off lines are the fallback itself. The R3r prompt hands the builder these ranges.

Cited Should be What the cited range misses
non-injective try "2359-2371" (Try doc, 8.9, r3_tests, R3r prompt) 2358-2375 2373-2374 reify env t1; reify env t2
variant arm "2400-2408" 2402-2411 2411 if !(generate_equations ()) then mcomp. 2400 is the previous arm's mcomp line.
package fallback "2416-2421"/"2417-2421" 2416-2424 2422 List.iter (reify env) (tl1 @ tl2)
"2373-2384" (two instantiables) 2376-2387
"2385-2388" 2388-2391
"2389-2392" 2392-2395
"2393-2397" 2396-2400
local_non_recursive_abbrev "1478-1535" (rows.rs doc, decision 67, R3h prompt) 1503-1536 1478-1502 are occur_full/occur/occur_in
mcomp_row table "1988-1995" (rows_that_clash test) 1991-1994 / 1995-2008 minor

Per test: a_field_gains… 2685-2706 is right. the_arguments_of_a_stale_row_name…: btype 126-135 and 229-241 are right. a_free_universal_variable… is right. passive_variants… 2693-2703 and 2189-2202 are right. the_walks… 1569-1589 is right. the_newer_of_two… 2258-2270 is right. mcomp_answers… 1905-2039 is right. mcomp_at_ten_thousand and pattern_mode_at_ten_thousand cite only 8.9. The remaining tests use the drifted arm lines above.

17. Pattern-mode design against OCaml: UNCLEAR

  • unify_pattern state. OCaml (2739-2750) sets current_univar_pairs () := []; the design requires scopes to be empty. It otherwise restores umode, the two flags and the newtype level (to 0/None) and clears the table on both results. Equivalent if the precondition holds; recorded in the doc of unify_pattern.
  • Per arm (64). Matches 2327-2425 row by row, including create_recursion, which runs in both modes (2428-2435). The equation direction uses unify3's own t1'/t2' after the swap. The table order is OCaml's.
  • Not recorded: the variable arms' occur. In Pattern mode OCaml uses allow_recursive (1468, 1390, 1405). See 10.2.
  • 65. Same as 2258-2270. Env.has_local_constraints is read as !equations.is_empty(), and is_newtype (1862-1868) as NEWTYPE without DATATYPE or PRIVATE.
  • 67. Steps 2-5 match 2095-2100. A failure inside the attempt leaves the equations, and so does a failed top-level call; the caller cuts them (cut_equations, recorded). Not recorded: step 1 has no strict/is_contractive/try_expand_once (non-opt) logic. See 10.1.
  • 68. OCaml 2405-2411: let snap = snapshot () in try unify_row env row1 row2 with Unify _ -> backtrack snap; reify env t1'; reify env t2'; if !(generate_equations ()) then mcomp !env t1' t2'. snapshot/backtrack (btype.ml:753-784) cover only the type trail. backtrack runs cleanup_abbrev when something changed (779) and undoes the logged changes. add_gadt_equation writes env := Env.add_local_constraint … (2099), and env is a plain ref outside the trail, so its equations, and the Env.add_local_type of reify (1823-1825), survive a backtrack. Decision 68 is therefore right that a backtrack does not cut equations. Checker::restore runs cleanup_abbrev as backtrack does (unify.rs:1215-1226). Also not recorded but the same as OCaml: pairs added to pairs inside the attempt stay, since unify_eq_set is a hashtable outside the trail. The trace and scopes are cut by recover, which answers the coordinator's note in the first PR-327 comment.
  • reify. Steps match 1813-1859, including the link before the level clash and the fixed row over a fresh constructor for a non-static, non-fixed row (1844-1853). The is_object_type arm (1856-1857) is not built, and that is recorded.
  • 70 (mcomp). Matches 1905-2039, with the recorded "No supplier → clash" where OCaml's Not_found -> () would be compatible (2039).
  • 69. Recorded for structure pairs. Missing for variable pairs (above).
  • 63. Matches 2416-2424. The citation drifts (section 16).

18. The harness: PASS

  • old_judges (differential.rs) runs run_old_until(program, plan, ops, &mut Some(len)). That cuts at the first Op::Gadt that succeeds and turns an operand's structure into a link.
  • compare: let ops = match plan.has(PATTERN) { true => &ops[..old_judges(..)], false => ops };. It applies only to PATTERN plans, so no existing plan's cases are cut.
  • No run_cases_except seed list changed. No existing assertion changed or was removed (section 4).
  • Fault test: generated_cases_find_a_pattern_unification_in_expression_mode, with if compare(case_seed, &program, plan, ops, Fault::ExpressionMode).is_err() { … } and assert!(cases >= 75 && equation >= 7 && refused >= 19).

Observation tests. Each says "observed" (what today's Rust checker does), cites OCaml lines, and says whether it is a judge:

Test OCaml lines cited Judge?
old_checker_gives_the_equation_to_the_newer_locally_abstract_type 2373-2384, 2393-2397, 2276-2280 judge
old_checker_refines_the_arguments_of_a_constructor_by_its_injectivity 2352-2358, 2359-2371 judge
old_checker_reifies_a_variable_and_a_row_variable 1815-1851, 908-922 judge
old_checker_keeps_what_reify_linked_when_a_pattern_unification_fails 1837-1839, 2437-2439, typecore.ml:488-495 judge
old_checker_accepts_rows_that_clash_and_are_compatible 1985-2009 judge
old_checker_links_the_structures_a_pattern_unification_unifies 2327-2331 NOT a judge: asserts the old checker's difference
old_checker_gains_a_type_the_holders_made_a_duplicate (E1) 2685-2706
old_checker_does_not_reach_the_arguments_of_a_stale_row_name (E1) btype 229-241

Plus three harness tests: the_two_sides_agree_on_pattern_programs_without_a_pattern_unification, old_side_of_the_pattern_plan_is_not_vacuous, and generated_cases_find….

19. The build prompts (doc.md:3030-3146): UNCLEAR

  • First edit is named. R3h: "1. The fixed-row rule of Checker::copy_refs". R3r: "1. Checker::{mcomp, push_compatible}".
  • Commit order: R3h commits 2-3 add bodies nothing calls yet; commit 4 turns on unify3 and removes the ignores. R3r commit 1 is mcomp plus its call; commit 2 is recover, the Try arm and the two arms that push Try. No commit deletes something a later one reads. PASS.
  • Criteria are commands or numbers ("cargo test … --lib tc::", "At most 450 lines", "pattern_mode_at_ten_thousand as written"). Shortcut lists are present in both. The bench asks for "unify_vars, unify_ground1, unify_ground3, unify_datatype2 and unify_abbrev2 … No target is set (decision 46)", with no remedy. PASS.
  • End of turn. R3h: "End your turn after the fourth commit is pushed and no test is ignored for "R3h build"". R3r: "after the third commit". Both are the commit where the hand-built tests are first judged. PASS.
  • Disagreement with OCaml. R3h has "If a test of yours fails where your code does what the ctype.ml lines say, stop and report the test with the lines: do not change the test." R3r has that only for generated seeds ("If pattern_plan_agrees_on_generated_cases reports a seed … stop and report"), plus "nothing else in those tests changed". There is no explicit stop-and-report rule for its four hand-built tests. UNCLEAR.
  • Other slice's functions. R3h says "The three places marked 2 … become todo!("R3r")" but does not list R3r's functions as off limits. Sequential ("R3r. R3h is merged."), so they share files (rows.rs, unify.rs) but not concurrently.
  • Size: "each under 450 lines" (8.9) and "At most 450 lines" in each prompt, under 600.
  • The ranges handed to the builder drift: R3h "1478-1535"; R3r "2359-2371, 2400-2408 and 2416-2421" miss the reify/mcomp lines (section 16). The R3r prompt also needs leave_scopes from rows.rs (14d).

20. Decisions 53–57 against the review comments: PASS (one nuance)

  • 53 matches comment 6903064767 item 4: "dropped here and kept, as a duplicate, by OCaml … Accepted … decision 53; a case … reopens it". SAME.
  • 54 matches 6904158571 ("Corrected in a8fae57: each range on its own. No caller sets passive variants yet"). SAME.
  • 55 matches 6903694421 (b): "package_end reads the right node's descriptor without following a link … If pattern mode (R3h) changes … that design reads the representative". SAME; answered by 63.
  • 56 DIFFERS slightly. 6904158571 says the walk "visits again in two cases where OCaml does not (a polymorphic type without bound variables opens a context; a closed sibling context that bound the same variables)". Decision 56 records only the first case, and decision 59 and open question 3 say the revisiting with binders happens "as OCaml". For two closed contexts with the same bound, OCaml does not revisit (1572-1581).
  • 57 matches 6904572154's table (118/122, 120/120, 807/807, 815/815, 2885.06/2886.06; #[cold] reverted; R3p's #[cold] #[inline(never)] kept, per 6903694421). SAME. The sentence "no prompt prescribes a remedy" goes further than the comment ("not chased here … tuned once … at R5c").

Decisions 58–71, one line each:

Decision Subject OCaml lines given in 8.6/8.9/doc comment?
58 split keeps OCaml's lists 2685-2706
59 Tpoly(_, []) opens no context 1587-1589, 1569-1581
60 name args children only of innermost row btype 229-241, 263-265, 126-135
61 PATTERN harness 908-922, 2352, 2368
62 old checker as judge, old_judges 2327-2331, 2373-2392 etc.
63 package_end in pattern mode 2417-2421 (drifted)
64 what replaces the link 2329, 2316-2323, table
65 two-newtypes arm 2258-2270, 1862-1868
66 LOCAL, injective_bits, expands_to_datatype 1870-1872, 2356, 2361
67 equation storage and cut 2093-2100, 1478-1535 (drifted)
68 trying arms as frames 2362-2371, 2400-2408 (drifted)
69 no occur for structures 2316-2329
70 mcomp 1905-2080
71 what a non-pattern unit pays no OCaml lines (cost)

21. Old-checker differences reported: PASS

  • Ambiguity of GADT instances: recorded in decision 62 (doc.md, "Ambiguity is not checked on the old side") and open question 1, citing 176-201, 1220-1227 and 2289-2298. Program, copied from the body:
    type rec t<_> = Int: t<int>
    let f = (type a, x: t<a>, y: a) =>
      switch x {
      | Int => if true { y } else { 0 }
      }
  • Structures linked in pattern mode: decision 62 (old_checker_links_the_structures…) and open question 2. No source program; three were tried.
  • Missing arm for two locally abstract types: decision 62 ("Not observed to differ") and decision 65.
  • lower_scoped and the escaping row name: decision 60 ("Found on the way and NOT corrected", 618-623) and open question 4.
  • git diff --stat $D -- compiler-rust/src/types is empty.

22. CI: PASS

gh pr checks 347 shows every check pass, including compiler-tests (completed and succeeded during this review), compiler-warnings and compare.

  • Instruction count: base 4,135,797,400, head 4,134,839,636, change −957,764 (−0.023%), "Within the threshold of +0.1%."
  • compiler-tests log (job 134437521802):
    • grep -cE "test tc::.* \.\.\. ok$" gives 281.
    • … ignored gives 15: 10 "R3h build", 5 "R3r build", matching 14(b).
    • Library tests: test result: ok. 2969 passed; 0 failed; 39 ignored.
  • compiler-warnings (job 134437520826): cargo clippy … --all-targets --all-features -- -D warnings and --no-default-features both "Finished", and cargo doc --all-features --no-deps "Finished". Pass.

…d owed, and the two prompts held until they are made

The review read the design of pattern mode against compiler/ml/ctype.ml and
ran four source programs through both compilers. Section 8.9 gets the list
of corrections a design turn makes before either slice is built: the rule
of local_non_recursive_abbrev (the test a_recursive_equation_is_not_added
expects the opposite of what OCaml does), the occurrence test of a variable
in pattern mode, the stale row name in pattern mode, two size tests, the
visibility mcomp's marker needs, a step test that does not test its table,
three step tests, line ranges, and the prompts' rules. The prompts of both
slices say they are not issued as they stand. No code changes: one comment
in the test.

Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/os-01a1c9fa-0c5d-7912-a93b-3e7f38e53547
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
@jfrolich

Copy link
Copy Markdown
Owner Author

Coordinator review, final, at 2e50e18 (the author did not write this review). The first-pass checklist (comment 6964023996) was read whole. I read the three corrections of built code (commit c801437) against the OCaml lines myself, checked the first-pass findings on the design against compiler/ml/ctype.ml, and ran source programs through both compilers for two of them.

Verdict: merged as a partly finished design that says so, with a reviewer commit (2e50e18). The corrections of built code and the harness are accepted. The design of pattern mode is accepted in outline and is not ready to build: the two build prompts are held until a design turn has made the corrections listed in section 8.9.

Accepted

  • Decisions 53 to 57: the record of earlier reviews, as those reviews decided.
  • Decision 58 (split_univars): what two Reither fields gain is fixed before the types that hold a universal variable are unified, as tl1' and tl2' are computed before List.iter (unify env tu1) (ctype.ml:2685-2706). The kept types sit in saved after the pair's record and are read once by the second join; every error path cuts saved back. This replaces decision 53, which accepted the dropped duplicate.
  • Decision 59 (free_univar): Tpoly (ty, []) adds nothing to bound (ctype.ml:1587-1589), so it opens no context. The walk was exponential on a chain of such types and is now 2n + 1, asserted at 1,000 and 10,000.
  • Decision 60, in expression mode (drop_name_children): the arguments of a row's name are visited only for the innermost row (iter_row, btype.ml:229-241). Two compares per pair of rows for a unit with variant rows.
  • Decisions 61 and 62: the PATTERN harness and the old_judges cut. The cut applies to PATTERN cases only; no pinned seed list and no existing assertion changed.
  • The cut of pattern mode into R3h and R3r, with R3r after R3h; decisions 63, 65, 66, 68 and 70 as designed. On 68 I read snapshot and backtrack (btype.ml:753-784) and add_gadt_equation (ctype.ml:2093-2100): the environment is a reference outside the trail, so a backtrack does not cut equations, as the decision says.
  • The five open questions, each answered as the designer recommends: (1) ambiguity of GADT instances is a slice of its own after R3r; (2) old_judges stays, the hand-built tests judge a structure pair that succeeds; (3) free_univar revisits per context of a polymorphic type with bound variables, as OCaml; (4) the escaping row name in lower_scoped is corrected with a hand-built test in the next design turn; (5) the builder of R3h reports what generalize writes under a speculation.

Not accepted as written (all in the reviewer commit's list, section 8.9, "Corrections owed after review")

  1. Decision 67, step 1, and the test a_recursive_equation_is_not_added are the opposite of OCaml. local_non_recursive_abbrev (ctype.ml:1503-1536; the cited 1478-1502 are other functions) is called with strict = false: a node that is not a constructor is entered only when strict, a contractive constructor is not entered, any other constructor is expanded once. I ran four programs through both compilers (Refl: eq<'a, 'a> matched at eq<a, T> for a locally abstract a, the branch using a value of type a at type T): for T = (a, int), array<a> and a data type box<a> the equation is added and both compilers accept; for an abstract M.t<a> it is not and both refuse with the same message. The test expects no equation for the tuple. Today's checker agrees with OCaml on all four, so this is a fault of the design only.
  2. The occurrence test of a variable in pattern mode. Decisions 64 and 69 say "as in expression mode". In Pattern, occur runs occur_full with allow_recursive (ctype.ml:1467-1490, occur_rec 1384-1408): no structure other than a constructor is entered, and no contractive constructor. A variable is bound to a tuple that holds it. The design does not say this, and the generated cases would meet it.
  3. Decision 60 in pattern mode. unify_row treats row 1 as kept when last1 is none, which rests on the left node being linked; pattern mode does not link it.
  4. Mechanical: no size tests for Equation and Try; mcomp's marker needs the private leave_scopes, whose frame it has popped; mcomp_at_ten_thousand has a fixed width of 100 and passes with or without the table it is there for; no step tests for non_recursive_abbrev, duplicate, recover; several line ranges a few lines off, which cut the reify and mcomp lines out of what the R3r builder is told to read; the R3r prompt lacks the stop-and-report rule for its hand-built tests; decision 71 leaves out three costs.

What the reviewer commit does: adds that list to 8.9, puts "not issued as it stands" before both prompts in 8.4, and a comment in the one test whose expectation is wrong. No code.

Confirmed from outside this pull request

  • The difference of today's checker the designer reports is real. Both compilers on two programs: OCaml refuses a GADT branch whose result is ambiguous between a locally abstract type and its equation ("This instance of int is ambiguous: it would escape the scope of its equation"), the Rust compiler accepts and emits JavaScript. With a result annotation both accept. It becomes a fix of today's checker on its own.

On record

  • The fifteen ignored tests have never run against anything; the designer says so. The correction turn that makes the list above also owes R3q (instance_poly), which this turn did not reach.
  • Decision 58's source program: OCaml's diagnostic prints two types where the designer's instrumented build showed three in the field. Not explained; the kernel follows the lists of ctype.ml:2685-2706.
  • Not rerun by me: the tests (CI: 281 tc:: tests pass, 15 ignored); the designer's figures for the exponential walk before its correction.

@jfrolich
jfrolich merged commit 7dfc468 into ocaml-to-rust-rewrite Nov 17, 2026
23 checks passed
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.

1 participant