Ignore type errors that have already been reported

This commit is contained in:
Richard Feldman 2021-09-18 02:47:39 -04:00
parent cde9f97415
commit a21ad7064c
6 changed files with 48 additions and 37 deletions

View file

@ -107,12 +107,13 @@ pub fn gen_and_eval<'a>(
} }
for problem in type_problems { for problem in type_problems {
let report = type_problem(&alloc, module_path.clone(), problem); if let Some(report) = type_problem(&alloc, module_path.clone(), problem) {
let mut buf = String::new(); let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette); report.render_color_terminal(&mut buf, &alloc, &palette);
lines.push(buf); lines.push(buf);
}
} }
for problem in mono_problems { for problem in mono_problems {

View file

@ -74,18 +74,19 @@ pub fn report_problems(loaded: &mut MonomorphizedModule) -> usize {
let problems = loaded.type_problems.remove(home).unwrap_or_default(); let problems = loaded.type_problems.remove(home).unwrap_or_default();
for problem in problems { for problem in problems {
let report = type_problem(&alloc, module_path.clone(), problem); if let Some(report) = type_problem(&alloc, module_path.clone(), problem) {
let severity = report.severity; let severity = report.severity;
let mut buf = String::new(); let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette); report.render_color_terminal(&mut buf, &alloc, &palette);
match severity { match severity {
Warning => { Warning => {
warnings.push(buf); warnings.push(buf);
} }
RuntimeError => { RuntimeError => {
errors.push(buf); errors.push(buf);
}
} }
} }
} }

View file

@ -145,12 +145,13 @@ pub fn helper<'a>(
} }
for problem in type_problems { for problem in type_problems {
let report = type_problem(&alloc, module_path.clone(), problem); if let Some(report) = type_problem(&alloc, module_path.clone(), problem) {
let mut buf = String::new(); let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette); report.render_color_terminal(&mut buf, &alloc, &palette);
lines.push(buf); lines.push(buf);
}
} }
for problem in mono_problems { for problem in mono_problems {

View file

@ -16,28 +16,32 @@ pub fn type_problem<'b>(
alloc: &'b RocDocAllocator<'b>, alloc: &'b RocDocAllocator<'b>,
filename: PathBuf, filename: PathBuf,
problem: solve::TypeError, problem: solve::TypeError,
) -> Report<'b> { ) -> Option<Report<'b>> {
use solve::TypeError::*; use solve::TypeError::*;
fn report(title: String, doc: RocDocBuilder<'_>, filename: PathBuf) -> Report<'_> { fn report(title: String, doc: RocDocBuilder<'_>, filename: PathBuf) -> Option<Report<'_>> {
Report { Some(Report {
title, title,
filename, filename,
doc, doc,
severity: Severity::RuntimeError, severity: Severity::RuntimeError,
} })
} }
match problem { match problem {
BadExpr(region, category, found, expected) => { BadExpr(region, category, found, expected) => Some(to_expr_report(
to_expr_report(alloc, filename, region, category, found, expected) alloc, filename, region, category, found, expected,
} )),
BadPattern(region, category, found, expected) => { BadPattern(region, category, found, expected) => Some(to_pattern_report(
to_pattern_report(alloc, filename, region, category, found, expected) alloc, filename, region, category, found, expected,
} )),
CircularType(region, symbol, overall_type) => { CircularType(region, symbol, overall_type) => Some(to_circular_report(
to_circular_report(alloc, filename, region, symbol, overall_type) alloc,
} filename,
region,
symbol,
overall_type,
)),
UnexposedLookup(symbol) => { UnexposedLookup(symbol) => {
let title = "UNRECOGNIZED NAME".to_string(); let title = "UNRECOGNIZED NAME".to_string();
let doc = alloc let doc = alloc
@ -97,6 +101,8 @@ pub fn type_problem<'b>(
report(title, doc, filename) report(title, doc, filename)
} }
SolvedTypeError => None,
other => panic!("unhandled bad type: {:?}", other), other => panic!("unhandled bad type: {:?}", other),
} }
} }

View file

@ -154,8 +154,9 @@ mod test_reporting {
} }
for problem in type_problems { for problem in type_problems {
let report = type_problem(&alloc, filename.clone(), problem.clone()); if let Some(report) = type_problem(&alloc, filename.clone(), problem.clone()) {
reports.push(report); reports.push(report);
}
} }
for problem in mono_problems { for problem in mono_problems {

View file

@ -143,12 +143,13 @@ fn create_llvm_module<'a>(
} }
for problem in type_problems { for problem in type_problems {
let report = type_problem(&alloc, module_path.clone(), problem); if let Some(report) = type_problem(&alloc, module_path.clone(), problem) {
let mut buf = String::new(); let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette); report.render_color_terminal(&mut buf, &alloc, &palette);
lines.push(buf); lines.push(buf);
}
} }
for problem in mono_problems { for problem in mono_problems {