Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/checker-rewrite-r5a-2a.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Checker rewrite R5a-2a: the new checker translates aliases, universal variables, the parameters of a type without plain parameters and the variables of an item (`globalize_used_variables`, `transl_simple_type`, `transl_type_scheme`).
2 changes: 1 addition & 1 deletion compiler-rust/src/tc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub mod scope;
// from the module it completes (CHECKER_REWRITE.md, "R5a as designed").
#[allow(dead_code, unused_variables)]
pub(crate) mod decl;
#[allow(dead_code, unused_variables)]
#[allow(dead_code)]
pub(crate) mod walk;

// The old environment's report of its bindings, opens and lookups, for the
Expand Down
23 changes: 0 additions & 23 deletions compiler-rust/src/tc/r5a2_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,6 @@ fn value_line(w: &mut World, root: Ty) -> String {
/// new (second branch), the proxy named or not, an alias inside an
/// alias, an alias used again as an argument.
#[test]
#[ignore = "R5a-2 build"]
fn aliases_agree_with_todays_checker() {
for (annotation, line) in ALIASES {
let mut w = world();
Expand All @@ -580,7 +579,6 @@ fn aliases_agree_with_todays_checker() {
/// and leaves the two stacks empty. A body that does not unify the
/// alias's variable with the aliased type accepts both.
#[test]
#[ignore = "R5a-2 build"]
fn an_alias_bound_to_two_types_is_an_error() {
for annotation in ALIAS_CLASHES {
let mut w = world();
Expand All @@ -605,7 +603,6 @@ fn an_alias_bound_to_two_types_is_an_error() {
/// deep_occur t1 t2 -> unify`, ctype.ml:2753, and `unify` expands):
/// `id<'b> as 'b` is a variable named `b` (OCaml prints `'a => int`).
#[test]
#[ignore = "R5a-2 build"]
fn a_self_alias_is_refused_as_in_ocaml() {
for annotation in SELF_ALIASES_OCAML_REFUSES {
let mut w = world();
Expand All @@ -631,7 +628,6 @@ fn a_self_alias_is_refused_as_in_ocaml() {
/// ends on it (`@1`), `Checker::generalize` and `Checker::copy` end on
/// it, and the copy is again one node that names itself.
#[test]
#[ignore = "R5a-2 build"]
fn a_phantom_self_alias_is_a_type_that_names_itself() {
let mut w = world();
w.c.g.begin_def();
Expand All @@ -654,7 +650,6 @@ fn a_phantom_self_alias_is_a_type_that_names_itself() {
/// of the alias node holds the aliased type's node; every node is at
/// the current level; and no node is made for the second use of `'b`.
#[test]
#[ignore = "R5a-2 build"]
fn an_alias_enters_its_variable_first_at_the_alias_location() {
let mut w = world();
w.c.g.begin_def();
Expand Down Expand Up @@ -716,7 +711,6 @@ fn field_type(w: &mut World, annotation: &str, declared: &[&str]) -> Result<Ty,
/// variable when `globalize` meets it and its unification is skipped,
/// typetexp.ml:712-717).
#[test]
#[ignore = "R5a-2 build"]
fn polymorphic_fields_agree_with_todays_checker() {
for (annotation, line) in FIELDS {
let mut w = world();
Expand Down Expand Up @@ -747,7 +741,6 @@ fn polymorphic_fields_agree_with_todays_checker() {
/// variable was made (`Extras::univars`), named `a`, in slot 1 of the
/// node; `'b`, which does not occur, is still a variable.
#[test]
#[ignore = "R5a-2 build"]
fn a_polymorphic_type_binds_the_variables_that_occur() {
let mut w = world();
let (arena, root) = parse_field("'a 'b. 'a => int");
Expand Down Expand Up @@ -785,7 +778,6 @@ fn a_polymorphic_type_binds_the_variables_that_occur() {
/// `'a` again: the first and the third are one variable node, and the
/// field's bound variable is another node.
#[test]
#[ignore = "R5a-2 build"]
fn a_universal_variable_hides_a_used_variable_inside_its_binder() {
let mut w = world();
let (arena, root) = parse("'a");
Expand Down Expand Up @@ -813,7 +805,6 @@ fn a_universal_variable_hides_a_used_variable_inside_its_binder() {
/// empty, and the next annotation of the worker translates: `'a` after
/// it is a used variable, not the dead binder's.
#[test]
#[ignore = "R5a-2 build"]
fn an_error_inside_a_binder_leaves_no_binder() {
let mut w = world();
w.c.g.begin_def();
Expand Down Expand Up @@ -850,7 +841,6 @@ fn declared_names(w: &World) -> Vec<&str> {
/// afterwards; a second annotation of the item finds `'b` and is one
/// node with the first's.
#[test]
#[ignore = "R5a-2 build"]
fn used_variables_are_globalized_in_the_order_of_their_names() {
let mut w = world();
let level = w.c.g.level;
Expand Down Expand Up @@ -893,7 +883,6 @@ fn used_variables_are_globalized_in_the_order_of_their_names() {
/// `transl_simple_type` empties the used variables first (738): `'q`,
/// used by a translation before it, is not globalized.
#[test]
#[ignore = "R5a-2 build"]
fn globalized_variables_are_at_the_global_level() {
let mut w = world();
w.st.vars.reset(1);
Expand Down Expand Up @@ -921,7 +910,6 @@ fn globalized_variables_are_at_the_global_level() {
/// by an alias is no error (`fixed && is_Tvar (repr ty)`): `(int as 'c,
/// 'c)` passes under the fixed policy and enters `c`.
#[test]
#[ignore = "R5a-2 build"]
fn the_fixed_policy_refuses_a_variable_that_is_not_declared() {
let mut w = world();
assert_eq!(field_type(&mut w, "('b, 'a)", &[]), Err(Stop::Error));
Expand Down Expand Up @@ -953,7 +941,6 @@ fn the_fixed_policy_refuses_a_variable_that_is_not_declared() {
/// today's checker and `.. y: int as 'a}` accepted:
/// `old_checker_globalize_programs_are_pinned`).
#[test]
#[ignore = "R5a-2 build"]
fn a_name_bound_to_two_types_by_two_annotations_is_an_error() {
let mut w = world();
let level = w.c.g.level;
Expand Down Expand Up @@ -982,7 +969,6 @@ fn a_name_bound_to_two_types_by_two_annotations_is_an_error() {
/// type); the variables of the item before are forgotten (`'a` of an
/// earlier scheme is not this one's). An error gives the level back.
#[test]
#[ignore = "R5a-2 build"]
fn a_scheme_is_generalized() {
let mut w = world();
let level = w.c.g.level;
Expand Down Expand Up @@ -1029,7 +1015,6 @@ fn a_scheme_is_generalized() {
/// whole), the used variables with them, and the global level is one
/// above the level given (`reset_global_level`, ctype.ml:157).
#[test]
#[ignore = "R5a-2 build"]
fn reset_forgets_the_declared_variables() {
let mut w = world();
let (arena, root) = parse("('x, 'y)");
Expand All @@ -1056,7 +1041,6 @@ fn reset_forgets_the_declared_variables() {
/// that is the same instance unifies the two arguments; an instance
/// that is not a variable is unified (`cl`).
#[test]
#[ignore = "R5a-2 build"]
fn parameters_without_plain_params_agree_with_todays_checker() {
for (annotation, line) in PARAMETERS {
let mut w = world();
Expand Down Expand Up @@ -1085,7 +1069,6 @@ fn parameters_without_plain_params_agree_with_todays_checker() {
/// (`update_level env t1.level t2`, 2758): `'x`, first used one level
/// deeper, is at the annotation's level afterwards.
#[test]
#[ignore = "R5a-2 build"]
fn the_declared_parameters_are_instantiated_not_bound() {
let mut w = world();
let (arena, root) = parse("sh<int, int>");
Expand Down Expand Up @@ -1141,7 +1124,6 @@ fn extensible(w: &mut World, arena: &ParseArena, root: CoreTypeIdx) {
/// reading the variable back follows its link (measured on the
/// prototype: 70,001 at 10,000).
#[test]
#[ignore = "R5a-2 build"]
fn ten_thousand_aliases() {
let make = |n: usize| format!("({})", (0..n).map(|i| format!("int as 'v{i}")).collect::<Vec<_>>().join(", "));
linear("aliases", make, extensible, 7);
Expand All @@ -1155,7 +1137,6 @@ fn ten_thousand_aliases() {
/// no node, where a body that takes an instance or unifies at every
/// use pays the aliased type each time.
#[test]
#[ignore = "R5a-2 build"]
fn ten_thousand_uses_of_one_alias() {
let make = |n: usize| format!("(k<int> as 'a, {})", vec!["'a"; n].join(", "));
linear("uses of an alias", make, extensible, 2);
Expand Down Expand Up @@ -1184,7 +1165,6 @@ fn ten_thousand_uses_of_one_alias() {
/// followed to the node inside). The parse runs on a thread with a large stack (the
/// parser recurses; the translation does not).
#[test]
#[ignore = "R5a-2 build"]
fn aliases_nested_ten_thousand_deep() {
let steps_at = |n: usize| {
let mut annotation = String::from("int");
Expand Down Expand Up @@ -1225,7 +1205,6 @@ fn aliases_nested_ten_thousand_deep() {
/// declared names come out increasing. Measured on the prototype:
/// 60,001 at 10,000.
#[test]
#[ignore = "R5a-2 build"]
fn ten_thousand_variables_globalized() {
let make = |n: usize| format!("({})", (0..n).rev().map(|i| format!("'v{i:05}")).collect::<Vec<_>>().join(", "));
let run = |w: &mut World, arena: &ParseArena, root: CoreTypeIdx| {
Expand Down Expand Up @@ -1257,7 +1236,6 @@ fn ten_thousand_variables_globalized() {
/// ty` as written, typetexp.ml:560) is quadratic and fails here.
/// Measured on the prototype: 70,006 at 10,000.
#[test]
#[ignore = "R5a-2 build"]
fn ten_thousand_universal_variables() {
let make = |n: usize| {
let names: Vec<String> = (0..n).map(|i| format!("'v{i}")).collect();
Expand All @@ -1283,7 +1261,6 @@ fn ten_thousand_universal_variables() {
/// two `int` nodes after the first (measured on the prototype: 139,995
/// at 10,000).
#[test]
#[ignore = "R5a-2 build"]
fn ten_thousand_shared_parameters() {
let steps_at = |n: usize| {
let mut w = world();
Expand Down
24 changes: 1 addition & 23 deletions compiler-rust/src/tc/r5a_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ const REJECTED: [&str; 5] = [
];

/// Annotations R5a-1 declines, with the variant (CHECKER_REWRITE 10.5).
const DECLINED: [(&str, Declined); 6] = [
const DECLINED: [(&str, Declined); 5] = [
("{\"x\": int}", Declined::ObjectType),
("[#a | #b]", Declined::PolyVariantType),
("int as 'a", Declined::AliasType),
("M.t", Declined::TypePath),
("module(S)", Declined::PackageType),
("(@as(\"x\") int) => int", Declined::TypeAttribute),
Expand Down Expand Up @@ -560,26 +559,6 @@ fn old_checker_unifies_arguments_of_shared_parameters() {
}
}

/// R5a-1. Reaches the same bodies as `annotations_agree_with_todays_
/// checker`, and no other slice.
///
/// A type whose row has no `PLAIN_PARAMS` is not R5a-1's: the
/// constructor stops with `Declined::NotBuilt` before an argument is
/// translated (no node is made), where a body that only lowers the
/// arguments would accept `t<int, string>`.
#[test]
fn a_type_without_plain_parameters_is_declined() {
let mut w = world();
declare_shared(&mut w, "t");
let (arena, root) = parse("t<int, string>");
let nodes = w.c.g.nodes.len();
assert_eq!(
translate(&mut w, &arena, root, Policy::Extensible),
Err(Stop::Declined(Declined::NotBuilt))
);
assert_eq!(w.c.g.nodes.len(), nodes);
}

/// R5a-2. Reaches `Annot::unify_params` (R5a-2) and the bodies of R5a-1.
///
/// Decision 5's shared case: with the two parameters of `t` one
Expand All @@ -590,7 +569,6 @@ fn a_type_without_plain_parameters_is_declined() {
/// k<'v>>` makes its two arguments one node: both list slots of the
/// constructor resolve to the `k<'v>` node.
#[test]
#[ignore = "R5a-2 build"]
fn arguments_of_shared_parameters_are_unified() {
let mut w = world();
declare_shared(&mut w, "t");
Expand Down
Loading
Loading