Simplify ExposedModuleTypes

The `Invalid` variant was never constructed, so we can eliminate it.
This commit is contained in:
Ayaz Hafiz 2022-05-18 09:59:37 -04:00
parent 2c09907116
commit a8265426df
No known key found for this signature in database
GPG Key ID: 0E2A37416A25EF58
2 changed files with 33 additions and 48 deletions

View File

@ -70,7 +70,7 @@ impl ExposedForModule {
for symbol in it {
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);
} else {
continue;
@ -86,12 +86,9 @@ impl ExposedForModule {
/// The types of all exposed values/functions of a module
#[derive(Clone, Debug)]
pub enum ExposedModuleTypes {
Invalid,
Valid {
stored_vars_by_symbol: Vec<(Symbol, Variable)>,
storage_subs: roc_types::subs::StorageSubs,
},
pub struct ExposedModuleTypes {
pub stored_vars_by_symbol: Vec<(Symbol, Variable)>,
pub storage_subs: roc_types::subs::StorageSubs,
}
pub fn constrain_module(

View File

@ -2121,7 +2121,7 @@ fn update<'a>(
} else {
state.exposed_types.insert(
module_id,
ExposedModuleTypes::Valid {
ExposedModuleTypes {
stored_vars_by_symbol: solved_module.stored_vars_by_symbol,
storage_subs: solved_module.storage_subs,
},
@ -3589,21 +3589,10 @@ fn add_imports(
for symbol in exposed_for_module.imported_values {
let module_id = symbol.module_id();
match exposed_for_module.exposed_by_module.get_mut(&module_id) {
Some(t) => match t {
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 {
Some(ExposedModuleTypes {
stored_vars_by_symbol,
storage_subs,
} => {
}) => {
let variable = match stored_vars_by_symbol.iter().find(|(s, _)| *s == symbol) {
None => {
// 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)),
));
}
},
None => {
internal_error!("Imported module {:?} is not available", module_id)
}