mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Report unexpected params
This commit is contained in:
parent
db76ab4015
commit
bc6a84a215
10 changed files with 137 additions and 24 deletions
|
@ -3173,6 +3173,22 @@ fn to_pending_value_def<'a>(
|
|||
}
|
||||
});
|
||||
|
||||
match (module_import.params, env.modules_expecting_params.contains(&module_id)) {
|
||||
(None, true) => {
|
||||
env.problems.push(Problem::MissingParams {
|
||||
module_id,
|
||||
region,
|
||||
});
|
||||
}
|
||||
(Some(import_params), false) => {
|
||||
env.problems.push(Problem::UnexpectedParams {
|
||||
module_id,
|
||||
region: import_params.params.region,
|
||||
});
|
||||
}
|
||||
(None, false) | (Some(_), true) => { /* All good */}
|
||||
}
|
||||
|
||||
if let Err(existing_import) =
|
||||
scope
|
||||
.modules
|
||||
|
|
|
@ -24,6 +24,8 @@ pub struct Env<'a> {
|
|||
|
||||
pub qualified_module_ids: &'a PackageModuleIds<'a>,
|
||||
|
||||
pub modules_expecting_params: VecSet<ModuleId>,
|
||||
|
||||
/// Problems we've encountered along the way, which will be reported to the user at the end.
|
||||
pub problems: Vec<Problem>,
|
||||
|
||||
|
@ -52,6 +54,7 @@ impl<'a> Env<'a> {
|
|||
home: ModuleId,
|
||||
module_path: &'a Path,
|
||||
dep_idents: &'a IdentIdsByModule,
|
||||
modules_expecting_params: VecSet<ModuleId>,
|
||||
qualified_module_ids: &'a PackageModuleIds<'a>,
|
||||
opt_shorthand: Option<&'a str>,
|
||||
) -> Env<'a> {
|
||||
|
@ -60,6 +63,7 @@ impl<'a> Env<'a> {
|
|||
home,
|
||||
module_path,
|
||||
dep_idents,
|
||||
modules_expecting_params,
|
||||
qualified_module_ids,
|
||||
problems: Vec::new(),
|
||||
closures: MutMap::default(),
|
||||
|
|
|
@ -286,6 +286,7 @@ pub fn canonicalize_module_defs<'a>(
|
|||
qualified_module_ids: &'a PackageModuleIds<'a>,
|
||||
exposed_ident_ids: IdentIds,
|
||||
dep_idents: &'a IdentIdsByModule,
|
||||
modules_expecting_params: VecSet<ModuleId>,
|
||||
aliases: MutMap<Symbol, Alias>,
|
||||
imported_abilities_state: PendingAbilitiesStore,
|
||||
initial_scope: MutMap<Ident, (Symbol, Region)>,
|
||||
|
@ -311,6 +312,7 @@ pub fn canonicalize_module_defs<'a>(
|
|||
home,
|
||||
arena.alloc(Path::new(module_path)),
|
||||
dep_idents,
|
||||
modules_expecting_params,
|
||||
qualified_module_ids,
|
||||
opt_shorthand,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue