Sarek_errortype error = | Unbound_variable of string * Sarek_ast.loc| Unbound_constructor of string * Sarek_ast.loc| Unbound_field of string * Sarek_ast.loc| Unbound_type of string * Sarek_ast.loc| Type_mismatch of {expected : Sarek_types.typ;got : Sarek_types.typ;loc : Sarek_ast.loc;}| Cannot_unify of Sarek_types.typ * Sarek_types.typ * Sarek_ast.loc| Not_a_function of Sarek_types.typ * Sarek_ast.loc| Wrong_arity of {expected : int;got : int;loc : Sarek_ast.loc;}| Not_a_vector of Sarek_types.typ * Sarek_ast.loc| Not_an_array of Sarek_types.typ * Sarek_ast.loc| Not_a_record of Sarek_types.typ * Sarek_ast.loc| Field_not_found of string * Sarek_types.typ * Sarek_ast.loc| Immutable_variable of string * Sarek_ast.loc| Recursive_type of Sarek_types.typ * Sarek_ast.loc| Unsupported_expression of string * Sarek_ast.loc| Parse_error of string * Sarek_ast.loc| Invalid_kernel of string * Sarek_ast.loc| Duplicate_field of string * Sarek_ast.loc| Missing_type_annotation of string * Sarek_ast.loc| Invalid_intrinsic of string * Sarek_ast.loc| Barrier_in_diverged_flow of Sarek_ast.loc| Warp_collective_in_diverged_flow of string * Sarek_ast.loc| Reserved_keyword of string * Sarek_ast.loc| Reserved_prefix of string * Sarek_ast.loc| Unsupported_type_in_registration of string * Sarek_ast.loc| Unsupported_constructor_form of Sarek_ast.loc| Unsupported_registration_form of Sarek_ast.loc| Unsupported_tuple_in_variant of Sarek_ast.loc| Unsupported_function_in_variant of Sarek_ast.loc| Unknown_variant_type of string * Sarek_ast.loc| Expression_needs_statement_context of string * Sarek_ast.loc| Invalid_lvalue of Sarek_ast.loc| Function_value_escapes of string * Sarek_types.typ * Sarek_ast.loc| Instantiation_mismatch of {callee : string;t1 : Sarek_types.typ;t2 : Sarek_types.typ;loc : Sarek_ast.loc;}A call site could not be typed against the callee's type. Reported instead of a bare Cannot_unify when the callee is NAMED, because the bare form ("Cannot unify types: float32 and float64") gives the user two type names and no indication of which function they came from — the reported failure mode of a polymorphic @sarek.module helper instantiated at a non-default element type (#97).
| Aggregate_equality_operand of string * Sarek_types.typ * Sarek_ast.locbacklog-194: a value with no comparable device representation reached = or <> — a tuple, record or variant (a struct: no backend lowers the comparison field-wise, and the C-family emitters print a == b, which those compilers reject), or a function (inlined at its call sites and never emitted, so f == g named identifiers that do not exist in the generated source). The set is Sarek_types.is_uncomparable_operand_typ; the typ is the operand type, so the message can name what was compared. Pointer-shaped operands (a vector, a local array) are NOT this error: src = dst emits (src == dst), which clang -x cl and glslangValidator both accept.
| Float16_operand of string * Sarek_ast.locAn f16 value reached an operator. f16 is a storage-only type, so this is always a user error with a specific remedy; reporting it as Type_mismatch {expected = int32} (what check_numeric's fall-through produced) told the user nothing. The string names the operator.
Error types
val error_loc : error -> Sarek_ast.locGet the location from an error
val binop_display_name : Sarek_ast.binop -> stringHuman-readable operator name for diagnostics, e.g. '=' -> "'='". Lives here rather than in Sarek_typer because two modules render an operator into a diagnostic — the typer's infer_binop and the aggregate-equality backstop in Sarek_lower_ir (backlog-194) — and a per-module match over binop is two spellings of one name with nothing comparing them.
val aggregate_equality_body : Sarek_types.typ -> stringbacklog-194. The body of the aggregate-equality refusal, WITHOUT the leading operator name. It is a function rather than inline text in pp_error because two sites emit this refusal — the typer's, through Aggregate_equality_operand, and the post-monomorphisation backstop in Sarek_lower_ir, which raises a located Ppxlib error directly. An earlier revision had the second site build an Aggregate_equality_operand with a FAKE location purely to borrow this printer; sharing the body instead is what lets the two agree on the wording without either lying about a loc.
What the text does and does not claim. It says no backend lowers the comparison field-wise, which is true of all seven. It does NOT enumerate what each backend prints: that was a standing claim about six modules with nothing tying it to them, and it is the per-backend evidence, dated, that belongs in the negative-test headers instead.
The remedy is given in SOURCE terms. It previously advised a._0 = b._0 for a tuple, which is not writable: _0 is the synthesized field name of the internal _tup_* record, and a field access on a tuple-typed value is refused by the typer with Not_a_record. Destructuring is the spelling that works.
val pp_error : Stdlib.Format.formatter -> error -> unitPretty print an error
val error_to_string : error -> stringConvert error to string
val pp_error_with_loc : Stdlib.Format.formatter -> error -> unitPrint error with location
type 'a result = ('a, error list) Stdlib.Result.tResult type for error accumulation
Monadic operations for error handling
val report_error : error -> 'aReport error to ppxlib
val report_errors : error list -> unitReport multiple errors
exception Sarek_error of errorRaise error as OCaml exception for use in PPX
val raise_error : error -> 'a