Skip to content

Commit

Permalink
Fix subtyping ordering & some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jfecher committed Aug 11, 2024
1 parent d902bd7 commit 1f7660e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/typechecking/instantiation.an
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ id x = x
// add : (forall a b c d e f g h i. ((a - c => e can g) - (a - b => c can g) -> (a => (b => e can g) can h) can i))
// id : (forall a b. (a -> a can b))
// one : (forall a b c d. ((a => b can d) - a -> b can d))
// two1 : (forall a b c. ((a => a can c) - a -> a can c))
// two1 : (forall a b c. ((b => b can c) - b -> b can c))
// two2 : ((a => a can c) => (a => a can c) can d)
2 changes: 1 addition & 1 deletion src/hir/monomorphisation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,8 @@ impl<'c> Context<'c> {
if definition.trait_impl.is_some() {
let definition_type = definition.typ.as_ref().unwrap().remove_forall();
let bindings = typechecker::try_unify(
definition_type,
typ,
definition_type,
definition.location,
&mut self.cache,
TE::MonomorphizationError,
Expand Down
2 changes: 1 addition & 1 deletion src/types/traitchecker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ fn find_matching_normal_impls(

let location = constraint.locate(cache);
let type_bindings = typechecker::try_unify_all_with_bindings(
&impl_typeargs,
constraint.args(),
&impl_typeargs,
bindings.clone(),
location,
cache,
Expand Down
5 changes: 4 additions & 1 deletion src/types/typechecker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type LevelBindings = Vec<(TypeVariableId, LetBindingLevel)>;

/// Arbitrary limit of maximum recursive calls to functions like find_binding.
/// Expected not to happen but leads to better errors than a stack overflow when it does.
const RECURSION_LIMIT: u32 = 15;
const RECURSION_LIMIT: u32 = 100;

#[derive(Debug, Clone)]
pub struct UnificationBindings {
Expand Down Expand Up @@ -716,6 +716,9 @@ pub fn try_unify_with_bindings_inner<'b>(
// ! <: &
(Tag(TypeTag::Mutable), Tag(TypeTag::Immutable)) => Ok(()),

// owned <: shared
(Tag(TypeTag::Owned), Tag(TypeTag::Shared)) => Ok(()),

_ => Err(()),
}
}
Expand Down

0 comments on commit 1f7660e

Please sign in to comment.