Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't refine already refined skolems #899

Merged
merged 2 commits into from
Dec 25, 2020
Merged
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
8 changes: 1 addition & 7 deletions base/src/scoped_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,9 @@ impl<K: Eq + Hash + Clone, V> ScopedMap<K, V> {
self.get(k).is_some()
}

/// Returns the number of elements in the container.
/// Shadowed elements are not counted
pub fn len(&self) -> usize {
self.map.len()
}

/// Returns the number of elements in the container.
/// Shadowed elements are counted
pub fn full_len(&self) -> usize {
pub fn len(&self) -> usize {
self.map.values().map(|v| v.len()).sum()
}

Expand Down
2 changes: 1 addition & 1 deletion check/src/typecheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2733,7 +2733,7 @@ impl<'a, 'ast> Typecheck<'a, 'ast> {
) -> RcType {
debug!("Refine {} : {}", expected, actual);
types::walk_type(&actual, &mut |typ: &RcType| {
if let Type::Skolem(skolem) = &**typ {
if let Type::Skolem(skolem) = &**self.subs.real(typ) {
self.refined_variables.entry(skolem.id).or_insert(());
}
});
Expand Down
37 changes: 37 additions & 0 deletions check/tests/pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,3 +1135,40 @@ match writer with
"#,
"test.List String"
}

test_check! {
issue_842,
r#"
type Digit a =
| One a
| Two a a

type Node b =
| Node2 b b

type FingerTree c =
| Empty
| Single c
| Deep (Digit c) (FingerTree (Node c)) (Digit c)

type View d =
| Nil
| View d (FingerTree d)

rec
let viewl xs : FingerTree e -> View e =
match xs with
| Empty -> Nil
| Single x -> View x Empty
| Deep (One a) deeper suffix ->
match viewl deeper with
| View (Node2 b c) rest -> View a (Deep (Two b c) rest suffix)
| Nil ->
match suffix with
| One w -> View a (Single w)
in

viewl
"#,
"forall a . test.FingerTree a -> test.View a"
}