mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
Get rid of variable name on DelayedAlias
This commit is contained in:
parent
2e62fba7bc
commit
c225515a1b
4 changed files with 28 additions and 44 deletions
|
@ -510,10 +510,8 @@ fn can_annotation_help(
|
||||||
|
|
||||||
let mut type_var_to_arg = Vec::new();
|
let mut type_var_to_arg = Vec::new();
|
||||||
|
|
||||||
for (loc_var, arg_ann) in alias.type_variables.iter().zip(args) {
|
for (_, arg_ann) in alias.type_variables.iter().zip(args) {
|
||||||
let name = loc_var.value.0.clone();
|
type_var_to_arg.push(arg_ann);
|
||||||
|
|
||||||
type_var_to_arg.push((name, arg_ann));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut lambda_set_variables =
|
let mut lambda_set_variables =
|
||||||
|
@ -671,8 +669,6 @@ fn can_annotation_help(
|
||||||
let alias = scope.lookup_alias(symbol).unwrap();
|
let alias = scope.lookup_alias(symbol).unwrap();
|
||||||
local_aliases.insert(symbol, alias.clone());
|
local_aliases.insert(symbol, alias.clone());
|
||||||
|
|
||||||
// Type::Alias(symbol, vars, Box::new(alias.typ.clone()))
|
|
||||||
|
|
||||||
if vars.is_empty() && env.home == symbol.module_id() {
|
if vars.is_empty() && env.home == symbol.module_id() {
|
||||||
let actual_var = var_store.fresh();
|
let actual_var = var_store.fresh();
|
||||||
introduced_variables.insert_host_exposed_alias(symbol, actual_var);
|
introduced_variables.insert_host_exposed_alias(symbol, actual_var);
|
||||||
|
|
|
@ -4738,16 +4738,13 @@ fn default_aliases() -> roc_solve::solve::Aliases {
|
||||||
|
|
||||||
let typ = Type::DelayedAlias(AliasCommon {
|
let typ = Type::DelayedAlias(AliasCommon {
|
||||||
symbol: Symbol::NUM_NUM,
|
symbol: Symbol::NUM_NUM,
|
||||||
type_arguments: vec![(
|
type_arguments: vec![Type::Alias {
|
||||||
"range".into(),
|
symbol: Symbol::NUM_INTEGER,
|
||||||
Type::Alias {
|
type_arguments: vec![("range".into(), Type::Variable(tvar))],
|
||||||
symbol: Symbol::NUM_INTEGER,
|
lambda_set_variables: vec![],
|
||||||
type_arguments: vec![("range".into(), Type::Variable(tvar))],
|
actual: Box::new(Type::Variable(tvar)),
|
||||||
lambda_set_variables: vec![],
|
kind: AliasKind::Opaque,
|
||||||
actual: Box::new(Type::Variable(tvar)),
|
}],
|
||||||
kind: AliasKind::Opaque,
|
|
||||||
},
|
|
||||||
)],
|
|
||||||
lambda_set_variables: vec![],
|
lambda_set_variables: vec![],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4770,16 +4767,13 @@ fn default_aliases() -> roc_solve::solve::Aliases {
|
||||||
|
|
||||||
let typ = Type::DelayedAlias(AliasCommon {
|
let typ = Type::DelayedAlias(AliasCommon {
|
||||||
symbol: Symbol::NUM_NUM,
|
symbol: Symbol::NUM_NUM,
|
||||||
type_arguments: vec![(
|
type_arguments: vec![Type::Alias {
|
||||||
"range".into(),
|
symbol: Symbol::NUM_FLOATINGPOINT,
|
||||||
Type::Alias {
|
type_arguments: vec![("range".into(), Type::Variable(tvar))],
|
||||||
symbol: Symbol::NUM_FLOATINGPOINT,
|
lambda_set_variables: vec![],
|
||||||
type_arguments: vec![("range".into(), Type::Variable(tvar))],
|
actual: Box::new(Type::Variable(tvar)),
|
||||||
lambda_set_variables: vec![],
|
kind: AliasKind::Opaque,
|
||||||
actual: Box::new(Type::Variable(tvar)),
|
}],
|
||||||
kind: AliasKind::Opaque,
|
|
||||||
},
|
|
||||||
)],
|
|
||||||
lambda_set_variables: vec![],
|
lambda_set_variables: vec![],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1928,9 +1928,7 @@ fn type_to_variable<'a>(
|
||||||
let length = type_arguments.len() + lambda_set_variables.len();
|
let length = type_arguments.len() + lambda_set_variables.len();
|
||||||
let new_variables = VariableSubsSlice::reserve_into_subs(subs, length);
|
let new_variables = VariableSubsSlice::reserve_into_subs(subs, length);
|
||||||
|
|
||||||
for (target_index, (_, arg_type)) in
|
for (target_index, arg_type) in (new_variables.indices()).zip(type_arguments) {
|
||||||
(new_variables.indices()).zip(type_arguments)
|
|
||||||
{
|
|
||||||
let copy_var = helper!(arg_type);
|
let copy_var = helper!(arg_type);
|
||||||
subs.variables[target_index] = copy_var;
|
subs.variables[target_index] = copy_var;
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ impl LambdaSet {
|
||||||
#[derive(PartialEq, Eq, Clone)]
|
#[derive(PartialEq, Eq, Clone)]
|
||||||
pub struct AliasCommon {
|
pub struct AliasCommon {
|
||||||
pub symbol: Symbol,
|
pub symbol: Symbol,
|
||||||
pub type_arguments: Vec<(Lowercase, Type)>,
|
pub type_arguments: Vec<Type>,
|
||||||
pub lambda_set_variables: Vec<LambdaSet>,
|
pub lambda_set_variables: Vec<LambdaSet>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ impl fmt::Debug for Type {
|
||||||
}) => {
|
}) => {
|
||||||
write!(f, "(DelayedAlias {:?}", symbol)?;
|
write!(f, "(DelayedAlias {:?}", symbol)?;
|
||||||
|
|
||||||
for (_, arg) in type_arguments {
|
for arg in type_arguments {
|
||||||
write!(f, " {:?}", arg)?;
|
write!(f, " {:?}", arg)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ impl Type {
|
||||||
lambda_set_variables,
|
lambda_set_variables,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
for (_, value) in type_arguments.iter_mut() {
|
for value in type_arguments.iter_mut() {
|
||||||
stack.push(value);
|
stack.push(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,7 +803,7 @@ impl Type {
|
||||||
lambda_set_variables,
|
lambda_set_variables,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
for (_, value) in type_arguments.iter_mut() {
|
for value in type_arguments.iter_mut() {
|
||||||
stack.push(value);
|
stack.push(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -903,7 +903,7 @@ impl Type {
|
||||||
lambda_set_variables: _no_aliases_in_lambda_sets,
|
lambda_set_variables: _no_aliases_in_lambda_sets,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
for (_, ta) in type_arguments {
|
for ta in type_arguments {
|
||||||
ta.substitute_alias(rep_symbol, rep_args, actual)?;
|
ta.substitute_alias(rep_symbol, rep_args, actual)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -985,9 +985,7 @@ impl Type {
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
symbol == &rep_symbol
|
symbol == &rep_symbol
|
||||||
|| type_arguments
|
|| type_arguments.iter().any(|v| v.contains_symbol(rep_symbol))
|
||||||
.iter()
|
|
||||||
.any(|v| v.1.contains_symbol(rep_symbol))
|
|
||||||
|| lambda_set_variables
|
|| lambda_set_variables
|
||||||
.iter()
|
.iter()
|
||||||
.any(|v| v.0.contains_symbol(rep_symbol))
|
.any(|v| v.0.contains_symbol(rep_symbol))
|
||||||
|
@ -1163,10 +1161,8 @@ impl Type {
|
||||||
if false {
|
if false {
|
||||||
let mut type_var_to_arg = Vec::new();
|
let mut type_var_to_arg = Vec::new();
|
||||||
|
|
||||||
for (loc_var, arg_ann) in alias.type_variables.iter().zip(args) {
|
for (_, arg_ann) in alias.type_variables.iter().zip(args) {
|
||||||
let name = loc_var.value.0.clone();
|
type_var_to_arg.push(arg_ann.clone());
|
||||||
|
|
||||||
type_var_to_arg.push((name, arg_ann.clone()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut lambda_set_variables =
|
let mut lambda_set_variables =
|
||||||
|
@ -1383,7 +1379,7 @@ fn symbols_help(initial: &Type) -> Vec<Symbol> {
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
output.push(*symbol);
|
output.push(*symbol);
|
||||||
stack.extend(type_arguments.iter().map(|v| &v.1));
|
stack.extend(type_arguments);
|
||||||
}
|
}
|
||||||
Alias {
|
Alias {
|
||||||
symbol: alias_symbol,
|
symbol: alias_symbol,
|
||||||
|
@ -1491,7 +1487,7 @@ fn variables_help(tipe: &Type, accum: &mut ImSet<Variable>) {
|
||||||
lambda_set_variables,
|
lambda_set_variables,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
for (_, arg) in type_arguments {
|
for arg in type_arguments {
|
||||||
variables_help(arg, accum);
|
variables_help(arg, accum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1623,7 +1619,7 @@ fn variables_help_detailed(tipe: &Type, accum: &mut VariableDetail) {
|
||||||
lambda_set_variables,
|
lambda_set_variables,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
for (_, arg) in type_arguments {
|
for arg in type_arguments {
|
||||||
variables_help_detailed(arg, accum);
|
variables_help_detailed(arg, accum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue