Skip to content

Commit

Permalink
feat(check): Remove the alias dependence for variants
Browse files Browse the repository at this point in the history
Before a variant could only be defined at the top level of a type definition since they needed to construct an instance of that type. This lifts that restriction and variant constructors now returns a row type of `forall a . | VARIANT_NAME ARGS*  | a`. Which ends up meaning that they construct an open variant row which contains at least the constructor in question, but could also contain more constructors.
  • Loading branch information
Marwes committed Dec 9, 2018
1 parent 203f7a8 commit 8c4678c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
7 changes: 0 additions & 7 deletions check/src/typecheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1984,13 +1984,6 @@ impl<'a> Typecheck<'a> {
self.translate_ast_type(&type_cache, typ)
});

if let Type::Variant(ref row) = **alias.unresolved_type().remove_forall() {
for field in row.row_iter() {
let symbol = self.symbols.scoped_symbol(field.name.as_ref());
self.original_symbols.insert(field.name.clone(), symbol);
}
}

// alias.unresolved_type() is a dummy in this context
self.named_variables.extend(
alias
Expand Down
2 changes: 1 addition & 1 deletion check/tests/pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,6 @@ else

assert_req!(
result.map(|t| t.to_string()),
Ok("forall a . | test.A Int | test.B String | a")
Ok("forall a . | A Int\n| B String\n| a")
);
}

0 comments on commit 8c4678c

Please sign in to comment.