mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
refactor introduced variables
This has lead to so many problems, so I made a special-purpose type for it
This commit is contained in:
parent
c6121e3805
commit
4848eb5901
7 changed files with 133 additions and 94 deletions
|
@ -72,6 +72,10 @@ pub fn constrain_imported_values(
|
|||
rigid_vars.push(var);
|
||||
}
|
||||
|
||||
for var in free_vars.wildcards {
|
||||
rigid_vars.push(var);
|
||||
}
|
||||
|
||||
// Variables can lose their name during type inference. But the unnamed
|
||||
// variables are still part of a signature, and thus must be treated as rigids here!
|
||||
for (_, var) in free_vars.unnamed_vars {
|
||||
|
@ -151,9 +155,10 @@ pub fn load_builtin_aliases(
|
|||
pub struct FreeVars {
|
||||
pub named_vars: ImMap<Lowercase, Variable>,
|
||||
pub unnamed_vars: ImMap<VarId, Variable>,
|
||||
pub wildcards: Vec<Variable>,
|
||||
}
|
||||
|
||||
pub fn to_type(solved_type: &SolvedType, free_vars: &mut FreeVars, var_store: &VarStore) -> Type {
|
||||
fn to_type(solved_type: &SolvedType, free_vars: &mut FreeVars, var_store: &VarStore) -> Type {
|
||||
use roc_types::solved_types::SolvedType::*;
|
||||
|
||||
match solved_type {
|
||||
|
@ -196,7 +201,11 @@ pub fn to_type(solved_type: &SolvedType, free_vars: &mut FreeVars, var_store: &V
|
|||
Type::Variable(var)
|
||||
}
|
||||
}
|
||||
Wildcard => Type::Variable(var_store.fresh()),
|
||||
Wildcard => {
|
||||
let var = var_store.fresh();
|
||||
free_vars.wildcards.push(var);
|
||||
Type::Variable(var)
|
||||
}
|
||||
Record { fields, ext } => {
|
||||
let mut new_fields = SendMap::default();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue