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/error/mod.rs | 169 +++++++++++++++++++++ dhall/src/error/text/AnnotMismatch.txt | 117 ++++++++++++++ dhall/src/error/text/CantTextAppend.txt | 28 ++++ dhall/src/error/text/DuplicateAlternative.txt | 18 +++ dhall/src/error/text/FieldCollision.txt | 43 ++++++ dhall/src/error/text/HandlerInputTypeMismatch.txt | 49 ++++++ dhall/src/error/text/HandlerNotAFunction.txt | 32 ++++ dhall/src/error/text/HandlerOutputTypeMismatch.txt | 51 +++++++ dhall/src/error/text/IfBranchMismatch.txt | 63 ++++++++ dhall/src/error/text/IfBranchMustBeTerm.txt | 51 +++++++ dhall/src/error/text/InvalidAlterantive.txt | 48 ++++++ dhall/src/error/text/InvalidAlterantiveType.txt | 49 ++++++ dhall/src/error/text/InvalidField.txt | 35 +++++ dhall/src/error/text/InvalidFieldType.txt | 34 +++++ dhall/src/error/text/InvalidInputType.txt | 61 ++++++++ dhall/src/error/text/InvalidListElement.txt | 30 ++++ dhall/src/error/text/InvalidListType.txt | 43 ++++++ dhall/src/error/text/InvalidOptionType.txt | 44 ++++++ dhall/src/error/text/InvalidOptionalElement.txt | 29 ++++ dhall/src/error/text/InvalidOptionalLiteral.txt | 53 +++++++ dhall/src/error/text/InvalidOutputType.txt | 68 +++++++++ dhall/src/error/text/InvalidPredicate.txt | 51 +++++++ dhall/src/error/text/MissingField.txt | 30 ++++ dhall/src/error/text/MissingHandler.txt | 32 ++++ dhall/src/error/text/MustCombineARecord.txt | 46 ++++++ dhall/src/error/text/MustMergeARecord.txt | 43 ++++++ dhall/src/error/text/MustMergeUnion.txt | 31 ++++ dhall/src/error/text/NoDependentLet.txt | 76 +++++++++ dhall/src/error/text/NoDependentTypes.txt | 31 ++++ dhall/src/error/text/NotAFunction.txt | 68 +++++++++ dhall/src/error/text/NotARecord.txt | 48 ++++++ dhall/src/error/text/TypeMismatch.txt | 117 ++++++++++++++ dhall/src/error/text/UnboundVariable.txt | 97 ++++++++++++ dhall/src/error/text/Untyped.txt | 117 ++++++++++++++ dhall/src/error/text/UnusedHandler.txt | 32 ++++ 35 files changed, 1934 insertions(+) create mode 100644 dhall/src/error/mod.rs create mode 100644 dhall/src/error/text/AnnotMismatch.txt create mode 100644 dhall/src/error/text/CantTextAppend.txt create mode 100644 dhall/src/error/text/DuplicateAlternative.txt create mode 100644 dhall/src/error/text/FieldCollision.txt create mode 100644 dhall/src/error/text/HandlerInputTypeMismatch.txt create mode 100644 dhall/src/error/text/HandlerNotAFunction.txt create mode 100644 dhall/src/error/text/HandlerOutputTypeMismatch.txt create mode 100644 dhall/src/error/text/IfBranchMismatch.txt create mode 100644 dhall/src/error/text/IfBranchMustBeTerm.txt create mode 100644 dhall/src/error/text/InvalidAlterantive.txt create mode 100644 dhall/src/error/text/InvalidAlterantiveType.txt create mode 100644 dhall/src/error/text/InvalidField.txt create mode 100644 dhall/src/error/text/InvalidFieldType.txt create mode 100644 dhall/src/error/text/InvalidInputType.txt create mode 100644 dhall/src/error/text/InvalidListElement.txt create mode 100644 dhall/src/error/text/InvalidListType.txt create mode 100644 dhall/src/error/text/InvalidOptionType.txt create mode 100644 dhall/src/error/text/InvalidOptionalElement.txt create mode 100644 dhall/src/error/text/InvalidOptionalLiteral.txt create mode 100644 dhall/src/error/text/InvalidOutputType.txt create mode 100644 dhall/src/error/text/InvalidPredicate.txt create mode 100644 dhall/src/error/text/MissingField.txt create mode 100644 dhall/src/error/text/MissingHandler.txt create mode 100644 dhall/src/error/text/MustCombineARecord.txt create mode 100644 dhall/src/error/text/MustMergeARecord.txt create mode 100644 dhall/src/error/text/MustMergeUnion.txt create mode 100644 dhall/src/error/text/NoDependentLet.txt create mode 100644 dhall/src/error/text/NoDependentTypes.txt create mode 100644 dhall/src/error/text/NotAFunction.txt create mode 100644 dhall/src/error/text/NotARecord.txt create mode 100644 dhall/src/error/text/TypeMismatch.txt create mode 100644 dhall/src/error/text/UnboundVariable.txt create mode 100644 dhall/src/error/text/Untyped.txt create mode 100644 dhall/src/error/text/UnusedHandler.txt (limited to 'dhall/src/error') diff --git a/dhall/src/error/mod.rs b/dhall/src/error/mod.rs new file mode 100644 index 0000000..e70b9a9 --- /dev/null +++ b/dhall/src/error/mod.rs @@ -0,0 +1,169 @@ +use std::io::Error as IOError; + +use dhall_syntax::{BinOp, Import, Label, ParseError, V}; + +use crate::phase::resolve::ImportStack; +use crate::phase::typecheck::TypecheckContext; +use crate::phase::{Normalized, Type, Typed}; + +pub type Result = std::result::Result; + +#[derive(Debug)] +#[non_exhaustive] +pub enum Error { + IO(IOError), + Parse(ParseError), + Decode(DecodeError), + Resolve(ImportError), + Typecheck(TypeError), + Deserialize(String), +} + +#[derive(Debug)] +pub enum ImportError { + Recursive(Import, Box), + UnexpectedImport(Import), + ImportCycle(ImportStack, Import), +} + +#[derive(Debug)] +pub enum DecodeError { + CBORError(serde_cbor::error::Error), + WrongFormatError(String), +} + +/// A structured type error that includes context +#[derive(Debug)] +pub struct TypeError { + type_message: TypeMessage, + context: TypecheckContext, +} + +/// The specific type error +#[derive(Debug)] +pub(crate) enum TypeMessage { + UnboundVariable(V