glimpse/error

Types

pub type GlimpseError(a) {
  LoadError(a)
  ParseError(
    glance_error: glance.Error,
    module_name: String,
    module_content: String,
  )
  ImportError(GlimpseImportError)
  TypeCheckError(TypeCheckError)
}

Constructors

pub type GlimpseImportError {
  CircularDependencyError(module_name: String)
  MissingImportError(module_name: String)
  SrcImportingDevDependency(module_name: String)
}

Constructors

  • CircularDependencyError(module_name: String)
  • MissingImportError(module_name: String)
  • SrcImportingDevDependency(module_name: String)

    Raised when a source module imports a module that is only available as a development dependency.

pub type TypeCheckError {
  InvalidReturnType(
    function_name: String,
    got: String,
    expected: String,
  )
  InvalidName(name: String)
  InvalidType(got: String, expected: String, message: String)
  InvalidBinOp(
    operator: String,
    left_got: String,
    right_got: String,
    expected: String,
  )
  UnknownCustomType(name: String)
  RecursiveTypeAlias(name: String)
  NotCallable(got: String)
  InvalidArguments(expected: String, actual_arguments: String)
  InvalidArgumentLabel(expected: String, got: String)
  UnexpectedLabelledArgument(label: String)
  DuplicateCustomType(name: String)
  InvalidFieldAccess(container: String, label: String)
  UnexpectedType(got: String, expected: String)
  InvalidAnnotation(got: String, expected: String, name: String)
  CaseClauseMismatch(got: String, expected: String)
  PatternMismatch(pattern: String, expected: String, got: String)
  InvalidGuard(got: String)
  InvalidGuardExpression
  LowercaseBoolPattern(name: String)
  MissingParameterAnnotation(name: String)
  MissingReturnAnnotation(function_name: String)
  UnexpectedTypeHole(name: String)
  InvalidUse(subject_count: Int)
  InexhaustivePattern(description: String)
  InvalidBitStringSegment(mismatch: String)
  UnsafeRecordUpdate(name: String)
  RecordUpdateOnUnlabelledConstructor(constructor: String)
  DuplicateArgument(field: String)
  MissingField(message: String)
  DuplicateArgumentName(name: String)
  UnlabelledArgumentAfterLabelled
  PositionalArgumentAfterLabelled
  DuplicateConstructor(name: String)
  PrivateTypeLeak(name: String)
  TodoInConstant
  InvalidConstantExpression
  FnInConstant
  UnusedTypeParameter(name: String)
  UnnecessarySpread
  InvalidPatternArity(expected: Int, got: Int)
  DoubleVariableAssignment
  DuplicateDefinition(name: String)
  DuplicateTypeParameter(name: String)
  DuplicateLabel(label: String)
  TypeUsedAsConstructor(type_name: String)
  ExternalTypeWithConstructors(type_name: String)
  IncorrectPatternCount(patterns: Int, subjects: Int)
  DuplicatePatternVariable(name: String)
  MissingPatternVariable(name: String)
  ExtraPatternVariable(name: String)
  RecursiveType
  FloatOutOfRange(value: String)
  InvalidEscape(value: String)
  UnknownTarget(name: String)
  InvalidExternalAttribute
  InvalidExternalModule(module: String)
  InvalidExternalFunction(name: String)
  ExternalAttributePlacement(scope: String)
  InvalidAttributePlacement(attribute: String, scope: String)
  InvalidTypeName(name: String)
  InvalidFunctionName(name: String)
  InvalidConstantName(name: String)
  InvalidArgumentName(name: String)
  InvalidTypeVariableName(name: String)
  InvalidVariableName(name: String)
  InvalidVariantName(name: String)
  InvalidTypeAliasName(name: String)
  InvalidAttributeShape(attribute: String)
  UnknownAttribute(name: String)
  DuplicateAttribute(name: String)
  UnsupportedTarget(name: String)
  MissingImplementation(name: String)
  DuplicateImport(name: String)
}

Constructors

  • InvalidReturnType(
      function_name: String,
      got: String,
      expected: String,
    )
  • InvalidName(name: String)
  • InvalidType(got: String, expected: String, message: String)
  • InvalidBinOp(
      operator: String,
      left_got: String,
      right_got: String,
      expected: String,
    )
  • UnknownCustomType(name: String)
  • RecursiveTypeAlias(name: String)

    Raised when type aliases reference each other in a cycle

  • NotCallable(got: String)
  • InvalidArguments(expected: String, actual_arguments: String)
  • InvalidArgumentLabel(expected: String, got: String)
  • UnexpectedLabelledArgument(label: String)

    Raised when todo or panic is given a labelled or shorthand argument: their wildcard signature expects no labels at all.

  • DuplicateCustomType(name: String)
  • InvalidFieldAccess(container: String, label: String)
  • UnexpectedType(got: String, expected: String)

    Raised when a type is used where a tuple/record/etc is required

  • InvalidAnnotation(got: String, expected: String, name: String)

    Raised when an annotation on a let or parameter does not match the inferred type

  • CaseClauseMismatch(got: String, expected: String)

    Raised when a case expression’s clauses don’t all agree on their type

  • PatternMismatch(pattern: String, expected: String, got: String)

    Raised when a pattern expects a type that doesn’t match the scrutinee

  • InvalidGuard(got: String)

    Raised when the guard of a case clause is not a Bool

  • InvalidGuardExpression

    Raised when a case clause guard uses syntax that is not part of the restricted guard grammar (e.g. function calls, pipelines, case).

  • LowercaseBoolPattern(name: String)

    Raised when a pattern names a variable true or false, which is almost certainly a mistake for the True/False constructors.

  • MissingParameterAnnotation(name: String)

    Raised when a function parameter is missing a type annotation

  • MissingReturnAnnotation(function_name: String)

    Raised when a function with an @external implementation is missing a return type annotation.

  • UnexpectedTypeHole(name: String)

    Raised when a function with an @external implementation uses a type hole (_ or an underscore-prefixed name) in a parameter or return type annotation, whose exact type must be known.

  • InvalidUse(subject_count: Int)

    Raised when use syntax is used with an unsupported number of subjects

  • InexhaustivePattern(description: String)

    Raised when a case (or let/use) pattern does not cover every possible shape of its subject type.

  • InvalidBitStringSegment(mismatch: String)

    Raised when a bit-array segment mixes options from different families (e.g. conflicting sizes, units, or signedness/endianness duplicates).

  • UnsafeRecordUpdate(name: String)

    Raised when a .. record update is unsafe because the spread value’s variant is open or its type parameters would change.

  • RecordUpdateOnUnlabelledConstructor(constructor: String)

    Raised when .. record update syntax is used with a constructor that has no labelled fields. Only constructors with at least one labelled field can be used with the update syntax.

  • DuplicateArgument(field: String)

    Raised when a record update lists a field more than once.

  • MissingField(message: String)

    Raised when a field access is attempted on a label that is not present on every variant (or is at a different position across variants).

  • DuplicateArgumentName(name: String)

    Raised when an anonymous function declares two parameters with the same name, or a signature declares the same label twice.

  • UnlabelledArgumentAfterLabelled

    Raised when a signature places an unlabelled parameter after a labelled one.

  • PositionalArgumentAfterLabelled

    Raised when a function call passes a positional argument after a labelled one.

  • DuplicateConstructor(name: String)

    Raised when a custom type defines two constructors with the same name.

  • PrivateTypeLeak(name: String)

    Raised when a private type (or value) appears in a public interface.

  • TodoInConstant

    Raised when todo is used in a module constant value.

  • InvalidConstantExpression

    Raised when a module constant value contains an expression that is not allowed in constants, e.g. const x = 1 + 2. The Gleam compiler only permits literal values, constants references, list/tuple/bit-array literals, record construction and updates, string concatenation, and negation of numeric literals.

  • FnInConstant

    Raised when an anonymous function literal appears in a module constant value (including nested inside variants, tuples, lists, etc.). The Gleam compiler rejects this at parse time.

  • UnusedTypeParameter(name: String)

    Raised when a type alias declares a type parameter it never uses.

  • UnnecessarySpread

    Raised when a constructor pattern lists every field yet also uses ...

  • InvalidPatternArity(expected: Int, got: Int)

    Raised when a constructor pattern names the wrong number of fields, e.g. Some(x) matched against a two-field constructor.

  • DoubleVariableAssignment

    Raised when a bit-string pattern assigns a variable twice, e.g. <<a as b>>.

  • DuplicateDefinition(name: String)

    Raised when a module defines two functions, two constants, or a function and a constant with the same name.

  • DuplicateTypeParameter(name: String)

    Raised when a custom type or type alias declares the same type parameter name twice.

  • DuplicateLabel(label: String)

    Raised when a constructor declares two fields with the same label.

  • TypeUsedAsConstructor(type_name: String)

    Raised when a type that takes no parameters is written with an argument list, e.g. -> Int().

  • ExternalTypeWithConstructors(type_name: String)

    Raised when a custom type has an @external annotation yet declares constructors.

  • IncorrectPatternCount(patterns: Int, subjects: Int)

    Raised when a case clause lists a different number of patterns than the case has subjects.

  • DuplicatePatternVariable(name: String)

    Raised when a pattern binds the same variable twice, or when a variable is bound to different positions by the alternatives of a clause.

  • MissingPatternVariable(name: String)

    Raised when a variable bound by one or-alternative of a clause is not bound by the other alternatives.

  • ExtraPatternVariable(name: String)

    Raised when a variable is bound by an or-alternative of a clause but not by the alternative that came before it.

  • RecursiveType

    Raised when a value’s type is defined in terms of itself.

  • FloatOutOfRange(value: String)

    Raised when a float literal is too large to be represented.

  • InvalidEscape(value: String)

    Raised when a string literal contains an invalid escape sequence, e.g. "\1", which the Gleam compiler rejects at parse time.

  • UnknownTarget(name: String)

    Raised when a @target attribute names a build target that does not exist, e.g. @target(python). The Gleam compiler rejects this at parse time; only erlang and javascript are recognised.

  • InvalidExternalAttribute

    Raised when an @external attribute has the wrong shape, e.g. a non-Variable target, or a target/module/function count other than three.

  • InvalidExternalModule(module: String)

    Raised when a JavaScript @external names a module path that the Gleam compiler rejects at parse time, e.g. one containing a space. Only the JavaScript target validates module paths.

  • InvalidExternalFunction(name: String)

    Raised when a JavaScript @external names a function that the Gleam compiler rejects at parse time, e.g. one starting with a digit or containing a dash. Only the JavaScript target validates function names.

  • ExternalAttributePlacement(scope: String)

    Raised when an @external attribute is attached somewhere the compiler does not allow it: constants, variants, type aliases, or imports. Only functions and custom type declarations may carry @external.

  • InvalidAttributePlacement(attribute: String, scope: String)

    Raised when @target or @internal is attached somewhere the compiler does not allow it. @target cannot be used on variants; @internal must be on a public declaration (or an import), so private functions, constants, types, and type aliases are rejected.

  • InvalidTypeName(name: String)

    Raised when a custom type name contains an underscore, e.g. Foo_bar, which the Gleam compiler rejects at parse time (“Invalid type name”).

  • InvalidFunctionName(name: String)

    Raised when a lowercase identifier contains an uppercase letter, e.g. a function named doStuff, which the Gleam compiler rejects at parse time (“Invalid function name”). Import aliases are exempt.

  • InvalidConstantName(name: String)

    Same as InvalidFunctionName, for module constants.

  • InvalidArgumentName(name: String)

    Same as InvalidFunctionName, for function arguments.

  • InvalidTypeVariableName(name: String)

    Same as InvalidFunctionName, for custom type and type alias parameters.

  • InvalidVariableName(name: String)

    Same as InvalidFunctionName, for locally bound variables.

  • InvalidVariantName(name: String)

    Raised when a variant constructor name contains an underscore, e.g. Bar_, which the Gleam compiler rejects at parse time (“Invalid type variant name”).

  • InvalidTypeAliasName(name: String)

    Raised when a type alias name contains an underscore, e.g. A_b, which the Gleam compiler rejects at parse time (“Invalid type alias name”).

  • InvalidAttributeShape(attribute: String)

    Raised when an attribute such as @deprecated or @target has arguments of the wrong shape, e.g. @deprecated without a string message, or @target without a single variable target.

  • UnknownAttribute(name: String)

    Raised when an attribute is not a recognised Gleam attribute, e.g. @deprecated__zzz(...). The only valid attributes are @external, @internal, @deprecated and @target; the compiler rejects anything else at parse time.

  • DuplicateAttribute(name: String)

    Raised when the same attribute is declared twice on one declaration (e.g. @deprecated("a") @deprecated("b") on a single function). The compiler rejects this with “Duplicate attribute”; @external is exempt since a function may have one @external per target.

  • UnsupportedTarget(name: String)

    Raised when a value is only implemented for another build target.

  • MissingImplementation(name: String)

    Raised when a function is declared without a body and without an @external implementation, e.g. pub fn f() -> Int. The real compiler reports this as “Function without an implementation”. (A function with no return annotation cannot be told apart from one with an empty {} body, so only annotated functions are caught here.)

  • DuplicateImport(name: String)

    Raised when two imports resolve to the same local module name.

pub type TypeCheckFold(a) =
  list.ContinueOrStop(Result(a, TypeCheckError))
pub type TypeCheckResult(a) =
  Result(a, TypeCheckError)
Search Document