mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-21 15:59:20 +03:00
Simplify ExposedModuleTypes
The `Invalid` variant was never constructed, so we can eliminate it.
This commit is contained in:
parent
2c09907116
commit
a8265426df
@ -70,7 +70,7 @@ impl ExposedForModule {
|
|||||||
|
|
||||||
for symbol in it {
|
for symbol in it {
|
||||||
let module = exposed_by_module.exposed.get(&symbol.module_id());
|
let module = exposed_by_module.exposed.get(&symbol.module_id());
|
||||||
if let Some(ExposedModuleTypes::Valid { .. }) = module {
|
if let Some(ExposedModuleTypes { .. }) = module {
|
||||||
imported_values.push(*symbol);
|
imported_values.push(*symbol);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
@ -86,12 +86,9 @@ impl ExposedForModule {
|
|||||||
|
|
||||||
/// The types of all exposed values/functions of a module
|
/// The types of all exposed values/functions of a module
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum ExposedModuleTypes {
|
pub struct ExposedModuleTypes {
|
||||||
Invalid,
|
pub stored_vars_by_symbol: Vec<(Symbol, Variable)>,
|
||||||
Valid {
|
pub storage_subs: roc_types::subs::StorageSubs,
|
||||||
stored_vars_by_symbol: Vec<(Symbol, Variable)>,
|
|
||||||
storage_subs: roc_types::subs::StorageSubs,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constrain_module(
|
pub fn constrain_module(
|
||||||
|
@ -2121,7 +2121,7 @@ fn update<'a>(
|
|||||||
} else {
|
} else {
|
||||||
state.exposed_types.insert(
|
state.exposed_types.insert(
|
||||||
module_id,
|
module_id,
|
||||||
ExposedModuleTypes::Valid {
|
ExposedModuleTypes {
|
||||||
stored_vars_by_symbol: solved_module.stored_vars_by_symbol,
|
stored_vars_by_symbol: solved_module.stored_vars_by_symbol,
|
||||||
storage_subs: solved_module.storage_subs,
|
storage_subs: solved_module.storage_subs,
|
||||||
},
|
},
|
||||||
@ -3589,21 +3589,10 @@ fn add_imports(
|
|||||||
for symbol in exposed_for_module.imported_values {
|
for symbol in exposed_for_module.imported_values {
|
||||||
let module_id = symbol.module_id();
|
let module_id = symbol.module_id();
|
||||||
match exposed_for_module.exposed_by_module.get_mut(&module_id) {
|
match exposed_for_module.exposed_by_module.get_mut(&module_id) {
|
||||||
Some(t) => match t {
|
Some(ExposedModuleTypes {
|
||||||
ExposedModuleTypes::Invalid => {
|
|
||||||
// make the type a flex var, so it unifies with anything
|
|
||||||
// this way the error is only reported in the module it originates in
|
|
||||||
let variable = subs.fresh_unnamed_flex_var();
|
|
||||||
|
|
||||||
def_types.push((
|
|
||||||
symbol,
|
|
||||||
Loc::at_zero(roc_types::types::Type::Variable(variable)),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
ExposedModuleTypes::Valid {
|
|
||||||
stored_vars_by_symbol,
|
stored_vars_by_symbol,
|
||||||
storage_subs,
|
storage_subs,
|
||||||
} => {
|
}) => {
|
||||||
let variable = match stored_vars_by_symbol.iter().find(|(s, _)| *s == symbol) {
|
let variable = match stored_vars_by_symbol.iter().find(|(s, _)| *s == symbol) {
|
||||||
None => {
|
None => {
|
||||||
// Today we define builtins in each module that uses them
|
// Today we define builtins in each module that uses them
|
||||||
@ -3633,7 +3622,6 @@ fn add_imports(
|
|||||||
Loc::at_zero(roc_types::types::Type::Variable(copied_import.variable)),
|
Loc::at_zero(roc_types::types::Type::Variable(copied_import.variable)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
},
|
|
||||||
None => {
|
None => {
|
||||||
internal_error!("Imported module {:?} is not available", module_id)
|
internal_error!("Imported module {:?} is not available", module_id)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user