mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
Ignore type errors that have already been reported
This commit is contained in:
parent
cde9f97415
commit
a21ad7064c
6 changed files with 48 additions and 37 deletions
|
@ -107,13 +107,14 @@ 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 {
|
||||||
let report = mono_problem(&alloc, module_path.clone(), problem);
|
let report = mono_problem(&alloc, module_path.clone(), problem);
|
||||||
|
|
|
@ -74,7 +74,7 @@ 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();
|
||||||
|
|
||||||
|
@ -89,6 +89,7 @@ pub fn report_problems(loaded: &mut MonomorphizedModule) -> usize {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let problems = loaded.mono_problems.remove(home).unwrap_or_default();
|
let problems = loaded.mono_problems.remove(home).unwrap_or_default();
|
||||||
|
|
||||||
|
|
|
@ -145,13 +145,14 @@ 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 {
|
||||||
let report = mono_problem(&alloc, module_path.clone(), problem);
|
let report = mono_problem(&alloc, module_path.clone(), problem);
|
||||||
|
|
|
@ -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),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,9 +154,10 @@ 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 {
|
||||||
let report = mono_problem(&alloc, filename.clone(), problem.clone());
|
let report = mono_problem(&alloc, filename.clone(), problem.clone());
|
||||||
|
|
|
@ -143,13 +143,14 @@ 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 {
|
||||||
let report = mono_problem(&alloc, module_path.clone(), problem);
|
let report = mono_problem(&alloc, module_path.clone(), problem);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue