drilling into every error type when getting region

This commit is contained in:
faldor20 2024-12-12 02:25:02 +10:00
parent 81f2095e61
commit 7eb81fbcf3
No known key found for this signature in database
GPG key ID: F2216079B890CD57
2 changed files with 642 additions and 48 deletions

View file

@ -75,6 +75,7 @@ impl ToRocPosition for tower_lsp::lsp_types::Position {
pub(crate) mod diag {
use std::{fmt::Debug, path::Path};
use log::debug;
use roc_load::LoadingProblem;
use roc_region::all::{LineInfo, Region};
use roc_solve_problem::TypeError;
@ -117,6 +118,8 @@ pub(crate) mod diag {
))
.to_range(line_info);
debug!("range is {:?}", range);
let msg = match self {
LoadingProblem::FileProblem { filename, error } => {
format!(
@ -153,10 +156,8 @@ pub(crate) mod diag {
LoadingProblem::TriedToImportAppModule => {
"Attempted to import app module".to_string()
}
LoadingProblem::FormattedReport(report, region) => {
range = region.unwrap_or(Region::zero()).to_range(line_info);
report.clone()
}
LoadingProblem::FormattedReport(report, region) =>
report.clone(),
LoadingProblem::ImportCycle(_, _) => {
"Circular dependency between modules".to_string()
}
@ -204,6 +205,7 @@ pub(crate) mod diag {
))
.to_range(fmt.line_info);
debug!("range is {:?}", range);
let report = roc_reporting::report::can_problem(
fmt.alloc,
fmt.line_info,