From 60129b7d1c0ea8bdf2ec666fa51957e97465e88f Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 6 May 2019 23:17:26 +0200 Subject: Consolidate errors in the error module --- dhall/src/phase/typecheck.rs | 114 +++++-------------------------------------- 1 file changed, 11 insertions(+), 103 deletions(-) (limited to 'dhall/src/phase/typecheck.rs') diff --git a/dhall/src/phase/typecheck.rs b/dhall/src/phase/typecheck.rs index 6b12077..aee9892 100644 --- a/dhall/src/phase/typecheck.rs +++ b/dhall/src/phase/typecheck.rs @@ -2,19 +2,20 @@ use std::borrow::Borrow; use std::borrow::Cow; use std::collections::BTreeMap; -use std::fmt; +use dhall_proc_macros as dhall; +use dhall_syntax::context::Context; +use dhall_syntax::{ + rc, Builtin, Const, Expr, ExprF, InterpolatedTextContents, Label, Span, + SubExpr, V, X, +}; + +use crate::error::{TypeError, TypeMessage}; use crate::phase::normalize::{ AlphaVar, NormalizationContext, Thunk, TypeThunk, Value, }; -use crate::phase::*; +use crate::phase::{Normalized, Resolved, Type, TypeInternal, Typed}; use crate::traits::DynamicType; -use dhall_proc_macros as dhall; -use dhall_syntax; -use dhall_syntax::context::Context; -use dhall_syntax::*; - -use self::TypeMessage::*; impl TypeThunk { fn to_type(&self, ctx: &TypecheckContext) -> Result { @@ -244,6 +245,7 @@ pub(crate) enum TypeIntermediate { impl TypeIntermediate { fn typecheck(self) -> Result { + use crate::error::TypeMessage::*; let mkerr = |ctx, msg| TypeError::new(ctx, msg); Ok(match &self { TypeIntermediate::Pi(ctx, x, ta, tb) => { @@ -503,6 +505,7 @@ fn type_last_layer( ctx: &TypecheckContext, e: ExprF, ) -> Result { + use crate::error::TypeMessage::*; use dhall_syntax::BinOp::*; use dhall_syntax::Builtin::*; use dhall_syntax::ExprF::*; @@ -801,101 +804,6 @@ pub(crate) fn skip_typecheck(e: Resolved) -> Typed { Typed::from_thunk_untyped(Thunk::new(NormalizationContext::new(), e.0)) } -/// The specific type error -#[derive(Debug)] -pub(crate) enum TypeMessage { - UnboundVariable(V