Errors reported while resolving or inferring a module.
Errors from building a Project (Elm.TypeInference.init,
Elm.TypeInference.addFile) live in
Elm.TypeInference.ProjectError.
Types of errors:
ImpossibleExpr, ImpossiblePattern and ImpossibleType: for
hand-crafted elm-syntax Files with nonsensical data, like a function call
without arguments or a 4-tuple. You should never be able to reach these when
using elm-syntax's parser on real Elm files.
ModuleNotFound: Raised when Elm.TypeInference.getType is called
with module that's not part of the indexed Project.
RangeNotFound: Raised when Elm.TypeInference.getType is called
with a Range not corresponding to an AST node from the provided Files.
VarNotFound:
module Main exposing (foo)
foo =
bar
--> VarNotFound
-- { usedIn = [ "Main" ]
-- , varName = "bar"
-- }AmbiguousName:
module Main exposing (foo)
import A exposing (thing)
import B exposing (thing)
foo =
thing
--> AmbiguousName
-- { usedIn = [ "Main" ]
-- , varName = "thing"
-- , possibleModules = [ [ "A" ], [ "B" ] ]
-- }AmbiguousModuleOwner:
Raised when two direct dependencies expose a module of the same name, eg.
mdgriffith/elm-ui and mdgriffith/style-elements (both expose Element):
module Main exposing (foo)
import Element
foo _ =
Element.text "hi"
--> AmbiguousModuleOwner
-- { moduleName = "Element"
-- , possiblePackages =
-- [ "mdgriffith/elm-ui"
-- , "mdgriffith/style-elements"
-- ]
-- }TypeNotFound:
module Main exposing (foo)
foo : Strng -> Int
foo _ =
1
--> TypeNotFound
-- { usedIn = [ "Main" ]
-- , qualifier = []
-- , typeName = "Strng"
-- }Qualified names need the module to be imported:
module Main exposing (foo)
foo : Dict.Dict String Int -> Int
foo _ =
1
--> TypeNotFound
-- { usedIn = [ "Main" ]
-- , qualifier = [ "Dict" ]
-- , typeName = "Dict"
-- }and the type to be exposed from it:
module Main exposing (foo)
import Other -- `module Other exposing (publicThing)`
foo : Other.Hidden -> Int
foo _ =
1
--> TypeNotFound
-- { usedIn = [ "Main" ]
-- , qualifier = [ "Other" ]
-- , typeName = "Hidden"
-- }WrongTypeArity:
module Main exposing (foo)
foo : Maybe Int Int -> Int
foo _ =
1
--> WrongTypeArity
-- { usedIn = [ "Main" ]
-- , moduleName = [ "Maybe" ]
-- , typeName = "Maybe"
-- , expected = 1
-- , actual = 2
-- }UnboundTypeVariable:
module Main exposing (Foo)
type alias Foo =
{ x : a }
--> UnboundTypeVariable
-- { typeName = "Foo"
-- , typeVar = "a"
-- }TypeMismatch:
module Main exposing (foo)
foo : Int
foo =
"abc"
--> TypeMismatch Type.Int Type.StringInfiniteType:
module Main exposing (foo)
foo x =
x x
--> InfiniteType
-- (Type.TypeVar "a")
-- (Type.Function
-- { from = Type.TypeVar "a"
-- , to = Type.TypeVar "b"
-- }
-- )ConstraintMismatch:
module Main exposing (foo)
foo x =
x + "a"
--> ConstraintMismatch
-- (Type.TypeVar "number")
-- Type.StringRecursiveAlias:
module Main exposing (Comment)
type alias Comment =
{ message : String
, responses : List Comment
}
--> RecursiveAlias
-- { aliases = [ { moduleName = [ "Main" ], name = "Comment" } ] }Render an error for diagnostic output.
A type inference error + location info.