Repository navigation
The result types of an application are lowered with GADT instances traced, as in OCaml - #352
Conversation
Why:
OCaml records, per `switch` whose patterns may add equations, the
types known only through an equation (`Env.gadt_instances`,
compiler/ml/env.ml:1305-1345), and refuses to expand or lower one
below that level (ctype.ml:587-589, 1215-1227). Rust did not track
them (`Env::add_gadt_instance_level` took no level), so it accepted
and compiled programs OCaml refuses.
Typing modified (expanding an equation's type below its switch):
Example:
type rec t<_> = Int: t<int>
let f = (type a, x: t<a>, y: a) =>
switch x {
| Int => if true { y } else { 0 }
}
Before (diagnostic): accepted; `function f(x, y) { return y; }`
After (diagnostic):
We've found a bug for you!
Main.res:4:33
This has type: int
But this if statement is expected to return: a (defined as int)
This instance of int is ambiguous:
it would escape the scope of its equation
if expressions must return the same type in all branches (if, else if, else).
The instance sets live in the type context, one per scope, each holding
its enclosing scope's handle; the environment holds the innermost
handle (`EnvData::gadt_instances`), so cloning an environment copies a
`u32` and no set. Additions are journaled and undone on backtrack, as
OCaml trails `set_typeset`. Ported: the expansion level of an equation
(env.ml:1805-1810), `cleanup_abbrev` when tracing starts (ctype.ml:182),
the test and the additions of `expand_abbrev_gen` (ctype.ml:1215-1227),
the chain of `try_expand_head` (ctype.ml:1270-1276), `unify2`'s
expansions failing with the pair (ctype.ml:2289-2292), the test of
`update_level` (ctype.ml:587-589), and the arm of `unify` for two
locally abstract types (ctype.ml:2255-2268), without which an accepted
`eq<a, b>` program became refused.
Review: What does a program without GADTs pay? The test in the level
update is one load of `has_gadt_instance_scopes` and a branch; every
other read and write runs only while tracing is on (under local
constraints) or in an environment with an instance scope.
Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Why:
OCaml's `copy ?env` (compiler/ml/ctype.ml:770-774), reached through
`instance env` and `instance_list env` (ctype.ml:879-894), adds the
copy of a node in an instance set to that set when the environment
has local constraints. Rust's `instance` takes no environment, so a
function generalized inside a case gave copies that were no
instances, and its result left the case.
Typing modified (instantiating a generalized instance below its switch):
Example:
type rec t<_> = Int: t<int>
let f = (type a, x: t<a>, y: a) =>
switch x {
| Int => {
let k = () => if true { y } else { 0 }
k()
}
}
Before (diagnostic): accepted; `function f(x, y) { return y; }`
After (diagnostic):
Main.res:6:7-9
This has type: a (defined as int)
But it's expected to have type: 'a
This instance of int is ambiguous:
it would escape the scope of its equation
`instance_in` and `instance_list_in` take the environment; the type
checker's `instance env` sites use them (constants and predefined types
keep `instance`, OCaml's `instance_def`). The copy is made as before;
then, only in an environment with local constraints and an instance
scope, the copy table is walked once and the copy of each instance is
added. Without a scope in the unit an `instance` call pays one load and
one branch.
Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
The third round of CHECKER_DEPARTURES.md gets the place A1: the 64 programs run through both compilers before and after the two commits of the port, the causes on both sides, and the OCaml sites left open because no program shows them. The twelve probes that differed on trunk and had no fixture become super_errors fixtures. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Why:
The instruction count of a clean tests/tests build rose by 0.313%
with the port: the expansion of a head returned a `Result` through
two more call layers, which changed what was inlined
(`try_expand_head_with_mode` -29.4M, `try_expand_head_traced`
+23.6M, `expand_head_traced` +15.1M, `find_abbrev_expansion` +8.2M
instructions), and every `instance_in` call tested for an instance
scope before copying (+2.3M).
The expansion of one head is again trunk's function returning an
`Option`; an ambiguous instance is written to an out-slot that only the
unifier reads, and the traced end of `expand_abbrev_gen` is a cold
function reached only while tracing. The head-expansion loop is one
function, generic over whether it propagates the refusal, so the safe
instantiation is trunk's loop. The test of `try_expand_head`'s chain is
made only while tracing: one load and one branch outside it. `instance`
and `instance_in` share one body; the instance-scope test follows a copy
of a generic root only. `unify` reuses its local-constraints test for the
newtype arm. All 64 programs of A1 agree as before.
Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b
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-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Why:
The checker tests on trunk drive the old checker's pattern
unification on an environment that has an equation (expansion
level 999) but no instance scope, which the type checker never
builds: both callers of `Env::add_gadt_instance_level` add the scope
before the patterns that add equations. `add_gadt_instances`
panicked there, where OCaml's `List.assoc` asserts
(compiler/ml/env.ml:1326-1328). It now adds nothing;
`tc::differential::tests::old_checker_gives_the_equation_to_the_newer_locally_abstract_type`,
`generated_cases_find_a_pattern_unification_in_expression_mode` and
`old_side_of_the_pattern_plan_is_not_vacuous` pass unchanged.
Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
tests/tests gained gadt_instance_ambiguous_accepted, one more unit the new checker declines (NotBuilt 832 -> 833); recorded with `scripts/tc_coverage.py --rescript rewatch/target/release/rescript --write`. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
The instruction counts the CI check measured, by function, and the line numbers after the expansion was moved off the default path. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
`instance` and `instance_list` are trunk's again. The `instance env` sites test the unit's flag and then the environment at hand; only when it has an instance scope do they call the copy that walks the finished copy table (`instance_with_gadt_instances`, not inlined). Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
…as an instance scope Trunk's head expansion runs unchanged outside an instance scope. In an environment with one, a traced loop calls the traced instantiation of the expansion, which makes the test of expand_abbrev_gen, and adds try_expand_head's chain whenever the result is an instance, as OCaml does whatever the tracing flag. The unifier's expansions take the same choice. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
The chain of try_expand_head (compiler/ml/env.ml:1342) has its own scan of the memorized expansions, so find_abbrev_expansion keeps trunk's one caller, the head expansion, and is inlined there as on trunk. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
rustfmt's layout for the lines the three attempts changed; no code change. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b 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-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Why:
An instance scope exists inside almost every `switch` of more than
one case: OCaml's `type_cases` adds the level whenever the
exhaustiveness check will run (compiler/ml/typecore.ml:4814-4818,
4913-4914), so 434 of the 788 units of tests/tests add one. Every
read of a set is a no-op while every set is empty, and a set gets
its first member only from `expand_abbrev_gen` (ctype.ml:1217-1227)
under the tracing flag.
The type context's flag is now "a type has been added to an instance
set in this unit", set where a member is pushed, not where a scope is
created, and kept in one byte with the tracing flag. Copies and level
updates test it; the expansion sites test the byte (tracing or a
member), so the test that adds the first member still runs. Without
either, every site runs trunk's code after one load and one branch.
Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
… copy The traced expansion was a second instantiation of `try_expand_head_with_mode`, so `find_abbrev_expansion` and `find_pdot_expansion` had two callers and were no longer inlined into trunk's. `try_expand_head_traced` now wraps trunk's function: while tracing and with no memorized expansion, it looks up the equation and its expansion level, refuses an ambiguous instance before expanding (nothing to undo), and otherwise records the type and its expansion in their instance set after it. A type that is an instance through another route is tested after the expansion, whose memo is then forgotten as OCaml's `try_expand_safe` backtracks it. The memo test is a scan of its own (`has_memorized_expansion`). Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
… can be expanded `expand_head_for_unify` returned a `Result` from both arms and tested the guard once per side. The pair sites now test it once (`expand_heads_unif`) and, while it is false, make trunk's two expansions directly; the traced pair, which refuses an ambiguous instance, is a separate function. The fully expanded comparison's site (`expand_head_in_unify`) does the same for one side. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Corrects why 434 units add an instance scope: type_cases adds one for every switch whose exhaustiveness is checked. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Inlined, it grew unify's frame from 0x1e8 to 0x238 bytes, so every call spilled more registers. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b 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-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
…+1,914,955) This reverts commit 89b7ae1. Measured locally against trunk 459b87c (fat LTO, one codegen unit, five runs a side), the total fell from +5,213,073 to +4,521,654, but only through functions the commit does not touch (`IdTbl::find_by_ident` -802,026, the path iterator), which move by as much between runs. `unify` itself rose from +1,130,695 to +1,914,955: with `#[inline(never)]` on `unify_newtypes` its frame grows from 0x238 to 0x258 bytes (trunk: 0x1e8), so the attribute adds to what a unit without an instance pays. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b 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-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
… link to a private item The documentation build refused the link from a public function to a private one. The sentence about the guard now says what the guard is: a type has joined an instance set in this unit. 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>
No change to the tree. The port measures about +0.12 to +0.14% on the tests/tests build: one load and one branch at each copy, expansion and level-update site while no type has joined an instance set, a larger frame in unify, and the instance lookups OCaml also makes in the units that add an instance. The split by function is in the pull request and under A1 of CHECKER_DEPARTURES.md. Instruction-count-increase: GADT instance tracking as OCaml has it; guard tests at the ported sites and the instance work in units that add an instance, split by function in the pull request 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>
OCaml's copy adds to an instance set only when given the environment (`instance env`, `instance_list env`; ctype.ml:877-894); `instance_def` and typetexp's `instance_list` (`Ctype.instance_list Env.empty`, typetexp.ml:61) add nothing. Back to `instance` / `instance_list`, where OCaml passes no environment: the declaration parameters of a type constructor (typetexp.ml:373), the constructor result under local constraints (typecore.ml:4739 `instance_def ty_res`), and the label result and argument of a record field and of a field assignment (typecore.ml:4315, 4319). To `instance_in`, where OCaml passes it: `rue` (typecore.ml:2607 `instance env ty_expected`; `rue_unify`, `finish_expected` and `finish_expected_at` take the environment), `object_field_use_type` (typecore.ml:2553 `instance env ty`), and the expected type of a record (typecore.ml:3044, 3148) and of a coercion's `rue`, through `instance_if_generic_in`. The tuple's copy has no OCaml counterpart (typecore.ml:2940 unifies `ty_expected` itself) and keeps trunk's. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
…them Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
No behaviour change. Cost notes for `expand_head_plain`, `expand_heads_traced`, `ambiguous_instance`, `instance_list_in` and `instance_list_with_gadt_instances`; a step test of `add_gadt_instance_chain` at 1,000 and 10,000 members (its membership scan now ticks the test-only step counter). Under A1: where Rust creates instance scopes, which corrects the reason given for the 434 units; the scope OCaml adds for a `switch` without a generalized constructor and Rust does not, as a difference without a program; duplicates in the member sets; the newtype arm; the journal; and the figures of the two remaining `#[inline(never)]`. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
OCaml has no copy there: typecore.ml:3165 stores the copy of 3153 (`ty_exp = instance env exp.exp_type`) as the base's type, so this Rust-only copy adds to no instance set. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
typecore.ml:3780 gives `assert(false)` the type `instance env ty_expected`; Rust used the expected type uncopied, which adds nothing to an instance set. A type that is not generic is returned unchanged by the copy, as before. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b 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-bd5a5126-dea8-7249-82a4-e8fae2447c0b 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-bd5a5126-dea8-7249-82a4-e8fae2447c0b 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-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
OCaml runs the application's `lower_args` inside
`wrap_trace_gadt_instances` (compiler/ml/typecore.ml:2828,
compiler/ml/ctype.ml:188-192). Under local constraints its `expand_head`
of the function's result type then makes the instance test of
`expand_abbrev_gen` (ctype.ml:1215-1227): an equation's type and its
expansion join the equation's instance set, and a later level update
refuses to lower them below that set's level (ctype.ml:587-589), the
"ambiguous instance" error. Rust's `lower_args` ran untraced, added
nothing, and accepted `switch x { | Int => { let g = (z: a) => z; g(y) } }`
with an unannotated result.
`ctype::wrap_trace_gadt_instances` is OCaml's helper; the application
calls `lower_args` through it. Cost: one local-constraint test and one
branch per application.
Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Thirteen super_errors fixtures `gadt_instance_application_*`, the programs OCaml refuses and trunk accepted: an applied function literal, a function bound in the case and applied, the same with the result annotated in the function, with two parameters, and behind an `if`; an equality witness, applied and as a literal; two nested equations; an object parameter; a field of a record declared in the case; a tuple component; a unit whose first function has no generalized constructor; a polymorphic variant payload. Their expected files are the OCaml compiler's output. `tests/tests/src/gadt_instance_application_accepted.res` holds the fourteen neighbours both compilers accept; `tc_coverage.txt` is re-recorded for the new unit. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b 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-bd5a5126-dea8-7249-82a4-e8fae2447c0b 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-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
A further program refused by OCaml and accepted by trunk, for the same cause: the application's lower_args ran untraced. Expected file from the OCaml compiler. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-bd5a5126-dea8-7249-82a4-e8fae2447c0b 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-bd5a5126-dea8-7249-82a4-e8fae2447c0b 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-bd5a5126-dea8-7249-82a4-e8fae2447c0b Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
|
Coordinator review at 7dbeec6 (the author did not write this review). Merging. The change is one wrapper: the application's The cause I gave with the task (the expansion arm of the level update) was wrong. The builder traced both compilers before editing, found the levels equal on both sides and the arm never taken, found where OCaml adds the member, and stopped to ask instead of fitting a fix into the functions the task named. The record under A1 says so. What I ran on this head
On record, open without a program (18 programs aimed at them by the builder agree): the wrappers of Not rerun by me: the builder's 67 programs and the parity suites (CI ran the suites: 23 of 23 checks pass). |
OCaml runs an application's
lower_argsinsidewrap_trace_gadt_instances(compiler/ml/typecore.ml:2828,compiler/ml/ctype.ml:188-192). Rust ran it untraced, so it accepted programs OCaml refuses. For example, withtype rec t<_> = Int: t<int>:OCaml reports "This instance of int is ambiguous: it would escape the scope of its equation" at
g(y). Trunk accepted it and emitted JavaScript.Cause, as traced
get_levelofaafter the equation is 1004 in both. The last lowering is also the same, the nodeafrom 2006 to 1004, so the level update's expansion arm (ctype.ml:591-596) never fires in either compiler.ctype.ml:587-589refuses to lower it below that. In Rust, no type had joined a set in that unit.expand_abbrev_gen(ctype.ml:1227), fromexpand_head←Typecore.lower_args(typecore.ml:2504) ←wrap_trace_gadt_instances(ctype.ml:190) ←Pexp_apply(typecore.ml:2828). Expanding the function's result typeaunder tracing addsaandintto the equation's set.Change
ctype::wrap_trace_gadt_instancesis OCaml's helper. It turns tracing on under local constraints and turns it off only if it turned it on.lower_argsthrough it.Tests
gadt_instance_application_*: the 13 programs OCaml refuses and trunk accepted, plus the tuple-pattern parameter described below. Their expected files are the OCaml compiler's output.tests/tests/src/gadt_instance_application_accepted.res: 14 neighbours that both compilers accept.compiler-rust/tc_coverage.txtis re-recorded for the new unit.The three other tracing wrappers
These are still open under A1:
unify_var's wrapper (ctype.ml:2759-2766),expand_head_trace(ctype.ml:2781-2784, used byfilter_arrow_nand the object filters), andlocal_non_recursive_abbrev(ctype.ml:1533-1534). I aimed 18 programs at them; all 18 agree with OCaml on this head. On trunk, one differed: a tuple-pattern parameter applied in the case. Its cause is the same as above, so it is the 14th fixture,gadt_instance_application_parameter_pattern. All three sites stay open, and the programs are recorded under A1.Gates (on
7dbeec670; the code is that of4234cb251)--release: 2281/2281.--release: 784/784.cargo clippy --all-targets -- -D warnings: clean.RUSTDOCFLAGS="-D warnings" cargo doc --no-deps: clean.tc::differential: 65 passed.Instruction counton7dbeec670: base 4,164,037,467, head 4,161,515,688, −2,521,779 (−0.061%), within the threshold. The total is allocator andIdTbl::find_by_identmovement. The one checker function that grew istype_application_parts, by +177,750, where the wrapper is inlined.Started by Jaap Frolich in this Assistant session