mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-08 21:10:32 +00:00
Capture import params location for better errors
This commit is contained in:
parent
f0fe0a3ea6
commit
90c7745989
6 changed files with 24 additions and 16 deletions
|
@ -1031,7 +1031,7 @@ impl<'a, 'b> Iterator for RecursiveValueDefIter<'a, 'b> {
|
|||
params,
|
||||
}) => {
|
||||
if let Some(ModuleImportParams { before: _, params }) = params {
|
||||
for loc_assigned_field in params.items {
|
||||
for loc_assigned_field in params.value.items {
|
||||
if let Some(expr) = loc_assigned_field.value.value() {
|
||||
self.push_pending_from_expr(&expr.value);
|
||||
}
|
||||
|
@ -1079,7 +1079,7 @@ pub struct ModuleImport<'a> {
|
|||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct ModuleImportParams<'a> {
|
||||
pub before: &'a [CommentOrNewline<'a>],
|
||||
pub params: Collection<'a, Loc<AssignedField<'a, Expr<'a>>>>,
|
||||
pub params: Loc<Collection<'a, Loc<AssignedField<'a, Expr<'a>>>>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
|
|
|
@ -993,9 +993,11 @@ fn import_params<'a>() -> impl Parser<'a, ModuleImportParams<'a>, EImportParams<
|
|||
then(
|
||||
and(
|
||||
backtrackable(space0_e(EImportParams::Indent)),
|
||||
specialize_err(EImportParams::Record, record_help()),
|
||||
specialize_err(EImportParams::Record, loc(record_help())),
|
||||
),
|
||||
|arena, state, _, (before, record): (_, RecordHelp<'a>)| {
|
||||
|arena, state, _, (before, loc_record): (_, Loc<RecordHelp<'a>>)| {
|
||||
let record = loc_record.value;
|
||||
|
||||
if let Some(update) = record.update {
|
||||
return Err((
|
||||
MadeProgress,
|
||||
|
@ -1013,7 +1015,10 @@ fn import_params<'a>() -> impl Parser<'a, ModuleImportParams<'a>, EImportParams<
|
|||
}
|
||||
})?;
|
||||
|
||||
let import_params = ModuleImportParams { before, params };
|
||||
let import_params = ModuleImportParams {
|
||||
before,
|
||||
params: Loc::at(loc_record.region, params),
|
||||
};
|
||||
|
||||
Ok((MadeProgress, import_params, state))
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue