Repository navigation
Conversation
TypeVars::reset forgets the declared, used and universal variables of an item head by head (no table is filled whole) and sets the global level one above the given level (reset_type_variables, typetexp.ml:213-216; reset_global_level, ctype.ml:157). Annot::univar, Annot::declared and Annot::add_declared look up and enter rows by Name through dense head tables; univar answers at once when no binder is open. No test is un-ignored: they are reached through later commits. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-e9265965-2056-785e-9365-c3bd2347e914 Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Annot::transl_type translates `t as 'a` (typetexp.ml:394-428) as one
frame. When the alias node is entered its variable is found (a
universal variable as it is, a used variable through its instance) or
made and entered in the used variables at the alias node's location,
BEFORE the aliased type, so `array<'b> as 'b` is refused by the
kernel's unify_var as OCaml refuses it. The variable, and for a new
alias its Name (one NameTable::intern), wait on the value stack below
the aliased type's result; when the frame is left the variable is
unified with the aliased type (Alias_type_mismatch is Stop::Error) and
a new alias names its proxy without validate_name. The variable arm
looks up the universal variables before the used ones; the copy of a
generic node is one helper for both arms. The row ("int as 'a",
AliasType) of r5a_tests::DECLINED goes; the eight alias tests of
r5a2_tests are no longer ignored.
Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
Session: https://os.submodule.nl/session/bks-e9265965-2056-785e-9365-c3bd2347e914
Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Annot::transl_type translates `'a 'b. t` (typetexp.ml:545-571): when the node is entered, begin_def and one variable a name (validate_name with a leading underscore allowed, 548), each a row of TypeVars::univars, the heads written from the last variable to the first so that the first of two of one name is found. When the frame is left the heads are put back from the first to the last, end_def and generalize of the body; ONE marking walk of the body (fresh_marks, work, children) answers deep_occur for every variable of the binder; a marked generic variable becomes a universal variable in place, any other marked one is Cannot_quantify; the Poly node (body, then the bound variables in the binder's order) is generic and lowered to the current level with Checker::lower. validate_name is one helper for the variable arm and the binder. On Err, transl_type now also puts the graph's level back and drops the open binders' universal variables (10.12, decision 21). A new test counts the steps of that drop at 1,000 and 10,000 variables. Four tests of r5a2_tests are no longer ignored. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-e9265965-2056-785e-9365-c3bd2347e914 Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
…heme Annot::globalize is globalize_used_variables (typetexp.ml:705-734) as two loops over TypeVars::used, sorted in place by the bytes of the names when it has two rows or more (decision 8). The first loop, in that order, unifies a new variable at the global level with each used variable inside one speculation, kept on success; on failure it is restored and the unit declines with Declined::PolyType where OCaml skips silently (10.12, decision 16). Then the declared variable of the name, or under the fixed policy Unbound_type_variable, or a second global variable entered as declared. The second loop, from the last row to the first, unifies each used node with its declared variable. The used variables are forgotten on every way out. transl_simple_type empties the universal and used variables, translates and globalizes; transl_type_scheme resets the item's variables, translates one level up, gives the level back on Err too and generalizes. Eight tests of r5a2_tests are no longer ignored. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-e9265965-2056-785e-9365-c3bd2347e914 Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
…LAIN_PARAMS A constructor of a type whose row has no PLAIN_PARAMS is no longer declined: its arguments are translated, its node made, and Annot::unify_params runs typetexp.ml:372-389. ONE copy session of all the declared parameters (instance_list, ctype.ml:891-894: copy_begin, a copy_ref each, copy_drain, then the pass Checker::copy runs after its own session), unify_var of each instance with its argument; then enforce_constraints (ctype.ml:1333-1342): a second session at the node's level and unify_var again, `subst`'s `!unify'` being unify_var (1129-1130, 2767). The instances leave the value stack on both ways out. The doc comment of Annot::transl_type now has the alias, the polymorphic and the constructor arms as 10.12 builds them, and the costs of 10.12.3. r5a_tests::a_type_without_plain_parameters_is_declined goes; arguments_of_shared_parameters_are_unified and three tests of r5a2_tests are no longer ignored. The walk module keeps only the dead_code allowance. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://os.submodule.nl/session/bks-e9265965-2056-785e-9365-c3bd2347e914 Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
jfrolich
marked this pull request as ready for review
November 29, 2026 16:53
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice R5a-2a of the type checker rewrite (CHECKER_REWRITE.md 10.12): the alias arm, universal variables and the polymorphic arm,
globalize,transl_simple_type,transl_type_scheme, andunify_paramswithenforce_constraints, all incompiler-rust/src/tc/walk/typetexp.rs. Nothing a default build runs calls this code.Commits
TypeVars::reset,Annot::univar,Annot::declared,Annot::add_declared, plus the changelog fragment.("int as 'a", AliasType)row ofr5a_tests::DECLINEDgoes.Errexit: the level is put back and the open binders' universal variables are dropped. Also adds a step test of that drop.globalize,transl_simple_type,transl_type_scheme.unify_paramsand the constructor arm's road for a type withoutPLAIN_PARAMS.r5a_tests::a_type_without_plain_parameters_is_declinedgoes, andtransl_type's doc comment is rewritten. Thewalkmodule keeps onlydead_code.In the second loop of
unify_params(enforce_constraints) the body callsChecker::unify_var, notChecker::unify, as OCaml'ssubstdoes (!unify', ctype.ml:1129-1130, isunify_var, 2767).Loops and the step tests that run them 10,000 times
ten_thousand_aliases,aliases_nested_ten_thousand_deepten_thousand_uses_of_one_aliasten_thousand_universal_variablesglobalize;TypeVars::resetover declared rowsten_thousand_variables_globalizedunify_paramsten_thousand_shared_parametersTypeVars::drop_univars(reset and theErrexit)walk::typetexp::tests::ten_thousand_universal_variables_dropped(new)Two loops count no step: writing a binder's heads when it is entered, and putting them back when it is left. Each is one store per variable of the binder, and both run in
ten_thousand_universal_variables.There is no hash map and no allocation per node. The sort in
globalizeissort_unstable_byin place and is skipped for one row or none. No struct was added or grown.Gates
cargo build --manifest-path compiler-rust/Cargo.toml:Finished.cargo test --manifest-path compiler-rust/Cargo.toml --lib tc:::test result: ok. 440 passed; 0 failed; 24 ignored; 0 measured; 2901 filtered out; finished in 954.48stest result: ok. 464 passed; 0 failed; 0 ignored; 0 measured; 2901 filtered out; finished in 902.48scargo test --lib tc::r5aafter each commit: 27/0/24, 35/0/16, 39/0/12, 47/0/4, 50/0/0 (passed/failed/ignored).cargo clippy --manifest-path compiler-rust/Cargo.toml --all-targets -- -D warnings: clean after each commit.RUSTDOCFLAGS="-D warnings" cargo doc --no-deps: clean after each commit.0 differing entries out of 920.+969,814 (+0.022%). Nothing of a default build calls this code, so nothing is saved and the difference is run-to-run noise (the base's five runs span 1.6 million).Started by Jaap Frolich in this Assistant session