Explorer

definy.type-error-text

description
A readable text of a core.type-error (e.g. type_mismatch (expected: number, actual: string)). located is unwrapped
type
Fn(error: @core.type-error) -> String
expression
fn(error$0) =>
  match $0 {
    #located(located$1) =>
      @definy.type-error-text(error: $1.error),
    #type_mismatch(detail$2) =>
      @std.string-join(
        items: [
          "type_mismatch (expected: ",
          @definy.type-ast-text(type: $2.expected),
          ", actual: ",
          @definy.type-ast-text(type: $2.actual),
          ")"
        ],
        separator: ""
      ),
    #undefined_variable(detail$3) =>
      @std.string-join(
        items: ["undefined_variable (variable_id: ", @std.number-to-string(value: $3.variable_id), ")"],
        separator: ""
      ),
    #not_a_function(detail$4) =>
      @definy.type-error-detail-text(tag: "not_a_function", key: "actual", text: @definy.type-ast-text(type: $4.actual)),
    #function_not_called(detail$5) =>
      @definy.type-error-detail-text(tag: "function_not_called", key: "actual", text: @definy.type-ast-text(type: $5.actual)),
    #unexpected_function(detail$6) =>
      @definy.type-error-detail-text(tag: "unexpected_function", key: "expected", text: @definy.type-ast-text(type: $6.expected)),
    #not_a_record(detail$7) =>
      @definy.type-error-detail-text(tag: "not_a_record", key: "actual", text: @definy.type-ast-text(type: $7.actual)),
    #not_a_union(detail$8) =>
      @definy.type-error-detail-text(tag: "not_a_union", key: "actual", text: @definy.type-ast-text(type: $8.actual)),
    #not_a_list(detail$9) =>
      @definy.type-error-detail-text(tag: "not_a_list", key: "actual", text: @definy.type-ast-text(type: $9.actual)),
    #variant_not_found(detail$10) =>
      @definy.type-error-detail-text(tag: "variant_not_found", key: "tag", text: @definy.quoted-text(value: $10.tag)),
    #non_exhaustive_match(detail$11) =>
      @definy.type-error-detail-text(
        tag: "non_exhaustive_match",
        key: "missing_tag",
        text: @definy.quoted-text(value: $11.missing_tag)
      ),
    #field_not_found(detail$12) =>
      @definy.type-error-detail-text(tag: "field_not_found", key: "key", text: @definy.quoted-text(value: $12.key)),
    #cannot_infer_empty_list(_) =>
      "cannot_infer_empty_list",
    #part_not_found(detail$13) =>
      @definy.type-error-detail-text(
        tag: "part_not_found",
        key: "part_definition_event_hash",
        text: @definy.quoted-text(value: $13.part_definition_event_hash)
      ),
    #invalid_type_declaration(detail$14) =>
      @definy.type-error-detail-text(tag: "invalid_type_declaration", key: "message", text: @definy.quoted-text(value: $14.message)),
    #unknown_error(_) =>
      "unknown_error",
    #unfilled_hole(_) =>
      "unfilled_hole",
    #hole_expected_type(detail$15) =>
      @definy.type-error-detail-text(
        tag: "hole_expected_type",
        key: "expected",
        text: match $15.expected {
          #some(expected$16) =>
            @definy.type-ast-text(type: $16),
          #none(_) =>
            "none"
        }
      )
  }
visibility
public
definy.type-error-text (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: ZusTj6wJ7q-WPX8sFstvQO8XfHrems9K1Sl-1RzM3XU
content hash: V4BXW2FBph9VYiI6Pw9neNHkCsgWNjl2DbkHirk0-Jo