elm-in-elm / compiler / Elm.Compiler.Error
All the errors the compiler can encounter.
type Error = ParseError ParseError
| DesugarError DesugarError
| TypeError TypeError
| EmitError EmitError
The top-level error type that breaks down into specific error types.
toString : Error -> String
An English description of the error. Feel free to write your own though!
type ParseError = ModuleNameDoesntMatchFilePath ({ moduleName : Elm.Data.ModuleName.ModuleName, filePath : Elm.Data.FilePath.FilePath })
| EmptySourceDirectories
| InvalidElmJson Json.Decode.Error
| ParseProblem (List (Parser.Advanced.DeadEnd ParseContext ParseProblem))
Errors encountered during parsing from String to AST.
The DeadEnd
type in this definition is the one from elm/parser
.
type ParseProblem = ExpectingPortKeyword
| ExpectingEffectKeyword
| ExpectingModuleKeyword
| ExpectingModuleName
| ExpectingExposingKeyword
| ExpectingExposingAllSymbol
| ExpectingExposingListLeftParen
| ExpectingExposingListRightParen
| ExpectingExposingListSeparatorComma
| ExpectingExposedTypeDoublePeriod
| ExpectingVarName
| ExpectingTypeOrConstructorName
| ExposingListCantBeEmpty
| ExpectingImportKeyword
| ExpectingAsKeyword
| ExpectingModuleNameWithoutDots
| ExpectingModuleNamePart
| ExpectingQualifiedVarNameDot
| ExpectingEqualsSign
| ExpectingMinusSign
| ExpectingNumber
| ExpectingSingleQuote
| ExpectingChar
| ExpectingEscapeBackslash
| ExpectingEscapeCharacter Char
| ExpectingUnicodeEscapeLeftBrace
| ExpectingUnicodeEscapeRightBrace
| InvalidUnicodeCodePoint
| ExpectingDoubleQuote
| ExpectingTripleQuote
| ExpectingPlusOperator
| ExpectingConsOperator
| ExpectingConcatOperator
| ExpectingModuleDot
| ExpectingBackslash
| ExpectingRightArrow
| ExpectingLeftParen
| ExpectingRightParen
| ExpectingLeftBracket
| ExpectingRightBracket
| ExpectingListSeparator
| ExpectingTupleSeparator
| ExpectingNotBeginningOfLine
| ExpectingIf
| ExpectingThen
| ExpectingElse
| ExpectingTrue
| ExpectingFalse
| ExpectingLet
| ExpectingIn
| ExpectingUnit
| InvalidNumber
| TriedToParseCharacterStoppingDelimiter
| CompilerBug String
The specific problem the parser encountered. Together with ParseContext
and the location info this should give you enough info about what's wrong.
type ParseContext = InNumber
| InChar
| InCharEscapeMode
| InUnicodeCharacter
| InString
| InDoubleQuoteString
| InTripleQuoteString
| InExpr
| InIf
| InLet
| InLetBinding
| InLambda
| InList
| InUnit
| InTuple
| InTuple3
Context information about what was the parser trying to do at the time of
the error. Was it trying to parse an if
expression? A list? etc.
type DesugarError = VarNotInEnvOfModule ({ var : { module_ : Maybe Elm.Data.ModuleName.ModuleName, name : Elm.Data.VarName.VarName }, module_ : Elm.Data.ModuleName.ModuleName })
Errors encountered during desugaring from the Frontend AST to Canonical AST.
type TypeError = TypeMismatch Elm.Data.Type.Type Elm.Data.Type.Type
| OccursCheckFailed Basics.Int Elm.Data.Type.Type
Errors encountered during typechecking.
type EmitError = MainDeclarationNotFound
| ModuleNotFoundForVar ({ module_ : Elm.Data.ModuleName.ModuleName, var : Elm.Data.VarName.VarName })
| ModuleNotFoundForType ({ module_ : Elm.Data.ModuleName.ModuleName, type_ : Elm.Data.VarName.VarName })
| DeclarationNotFound ({ module_ : Elm.Data.ModuleName.ModuleName, name : Elm.Data.VarName.VarName })
Errors encountered during emitting. As you're free to do the emit phase however
you want, this is only returned from the helpers in Stage.Emit in the compiler CLI.
- TODO: maybe expose Stage.Emit in this library (probably under the name
Elm.Compiler.Emit
or something similar)