package libsail

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Libsail.Type_errorSource

Type error utilities

This file wraps the functions in Type_check, so they return Fatal_error exceptions from the Reporting module rather than Type_errors.

Sourceval opt_explain_all_variables : bool ref

If false (default), we'll only explain generated variables, not variables written explicitly by the user in the source.

Sourceval opt_explain_constraints : bool ref

If false (default), we'll list relevant constraints, but not go into detail about how they were derived

Sourceval opt_explain_all_overloads : bool ref

If false (default), we will try to pick the most likely error to have caused an overload to fail, and only show those. If true, we will show all type errors that caused an overload to fail.

Sourcetype constraint_reason = (Ast.l * string) option
Sourcetype type_error =
  1. | Err_no_overloading of Ast.id * (Ast.id * Parse_ast.l * type_error) list
  2. | Err_unresolved_quants of Ast.id * Ast.quant_item list * (Ast_util.mut * Ast.typ) Ast_util.Bindings.t * Type_env.type_variables * Ast.n_constraint list
  3. | Err_failed_constraint of Ast.n_constraint * (Ast_util.mut * Ast.typ) Ast_util.Bindings.t * Type_env.type_variables * Ast.n_constraint list
  4. | Err_subtype of Ast.typ * Ast.typ * Ast.n_constraint option * (constraint_reason * Ast.n_constraint) list * Type_env.type_variables
  5. | Err_no_num_ident of Ast.id
  6. | Err_other of string
  7. | Err_inner of type_error * Parse_ast.l * string * type_error
  8. | Err_not_in_scope of string option * Parse_ast.l option * string Project.spanned option * string Project.spanned option * bool
  9. | Err_instantiation_info of int * type_error
  10. | Err_function_arg of Parse_ast.l * Ast.typ * type_error
  11. | Err_no_function_type of {
    1. id : Ast.id;
    2. functions : (Ast.typquant * Ast.typ) Ast_util.Bindings.t;
    }
    (*

    Takes the name of the function and the set of functions in scope

    *)
  12. | Err_unbound_id of {
    1. id : Ast.id;
    2. locals : (Ast_util.mut * Ast.typ) Ast_util.Bindings.t;
    3. have_function : bool;
    }
    (*

    Takes the name of the identifier, the set of local bindings, and whether we have a function of the same name in scope.

    *)
  13. | Err_hint of string
    (*

    A short error that only appears attached to a location

    *)
  14. | Err_with_hint of string * type_error
Sourceexception Type_error of Parse_ast.l * type_error
Sourcetype suggestion =
  1. | Suggest_add_constraint of Ast.n_constraint
  2. | Suggest_none

Analyze an unresolved quantifier type error

Sourceval string_of_type_error : type_error -> string * string option
Sourceval to_reporting_exn : Parse_ast.l -> type_error -> exn

Convert a type error into a general purpose error from the Reporting file