From b36250d183f5639d79b1dfd4919b3f910be1acdf Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 6 Aug 2024 11:45:42 +0200 Subject: [PATCH] Provide better errors on unknown type in cyclic definitions. Let's consider the following case: ``` type Var = Integer type Vars = List ``` This incorrectly reports an infinite cycle; due to the inability to properly type-check `Var` which is also a dependent var of `Vars`. Yet the real issue here being that `Integer` is an unknown type. This commit also upgrades miette to 7.2.0, so that we can also display a better error output when the problem is actually a cycle. --- crates/aiken-project/src/error.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/aiken-project/src/error.rs b/crates/aiken-project/src/error.rs index 05e030e3..0f8277cf 100644 --- a/crates/aiken-project/src/error.rs +++ b/crates/aiken-project/src/error.rs @@ -61,7 +61,7 @@ pub enum Error { TomlLoading { path: PathBuf, src: String, - named: Box>, + named: NamedSource, location: Option, help: String, }, @@ -76,7 +76,7 @@ pub enum Error { Parse { path: PathBuf, src: String, - named: Box>, + named: NamedSource, #[source] error: Box, }, @@ -454,7 +454,7 @@ impl Diagnostic for Error { Error::Type { named, .. } => Some(named), Error::StandardIo(_) => None, Error::MissingManifest { .. } => None, - Error::TomlLoading { named, .. } => Some(named.as_ref()), + Error::TomlLoading { named, .. } => Some(named), Error::Format { .. } => None, Error::TestFailure { .. } => None, Error::Http(_) => None,