Skip to content

Commit 9f9e366

Browse files
authored
Merge pull request #160 from intel/fix-template-name-range
Fix the range for missing template names in 'is'
2 parents d0f98ee + 7cc39ea commit 9f9e366

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
of memory on larger devices.
1111
- Optimizations to reference matching, which should greatly speed up semantic
1212
analysis speed of larger devices.
13+
- Corrected range of error reporting of unknown templates
1314

1415
## 0.9.13
1516
- Corrected the name of "explicit\_param\_decls" provisional. Note that it still

src/analysis/templating/topology.rs

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -580,20 +580,47 @@ pub fn rank_templates_aux<'t>(mut templates: HashMap<&'t str,
580580
severity: Some(DiagnosticSeverity::ERROR),
581581
});
582582
},
583-
inf => {
583+
InferiorVariant::Is(inf) => {
584584
if !BUILTIN_TEMPLATES.iter().any(
585585
|name|name==missing_template_name) {
586-
report.push(
587-
DMLError {
588-
span: *inf.span(),
589-
description: format!(
590-
"No template; '{}'",
591-
missing_template_name),
592-
related: vec![],
593-
severity: Some(DiagnosticSeverity::ERROR),
594-
});
586+
// The 'is' may contain more names than we
587+
// are looking for, find the particular name
588+
// that matches and use that span
589+
// Because the same name could be used multiple
590+
// times, but this only causes inferior binding
591+
// report one error per such span
592+
593+
let spans: Vec<_> = inf.obj.names.iter()
594+
.filter(|dmlname|
595+
&dmlname.val == missing_template_name)
596+
.map(|dmlname|dmlname.span())
597+
.collect();
598+
if spans.is_empty() {
599+
internal_error!("Unexpectedly no name \
600+
matching missing template \
601+
in {:?} (wanted {})",
602+
inf, missing_template_name);
603+
continue;
604+
}
605+
for span in spans {
606+
report.push(
607+
DMLError {
608+
span: *span,
609+
description: format!(
610+
"No template; '{}'",
611+
missing_template_name),
612+
related: vec![],
613+
severity: Some(
614+
DiagnosticSeverity::ERROR),
615+
});
616+
}
595617
}
596-
}
618+
},
619+
inf => {
620+
internal_error!(
621+
"Unexpected template dependency through {:?}",
622+
inf);
623+
},
597624
}
598625
debug!("Added dummy missing template {}",
599626
missing_template_name);

0 commit comments

Comments
 (0)