Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Types

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

Defines the type grammar, nominal type declarations, and static rules shared by resolution, type checking, and lowering. Expression typing is completed in Type inference; dispatch in Method dispatch.

A type expression (BeskidType) must be exactly one of:

FormSyntaxMeaning
Primitivebool, i32, i64, u8, f64, char, string, unitBuiltin scalar types
NamedPath with optional GenericArgumentsNominal reference to type, enum, or generic parameter
ArrayT[]Homogeneous slice-like sequence; runtime ABI uses fat pointer layout
Referenceref TBy-reference parameter passing surface (see memory chapter)
FunctionT(params) or (params) => RFunction types for values and signatures

Primitives must map to HirPrimitiveType variants in the reference compiler.

  • type Name<G…> : Contracts… { fields } introduces a nominal record-like type.
  • Fields may be value fields (T name), event fields (see Events), or inject fields (composition only).
  • Conformance list (: I, J) declares contract implementations checked in Contracts.
  • enum declarations are specified in Enums and match.
  • extend type adds members externally per extend type.
  • Duplicate type or member names in the same scope must error (E1001, E1006).
  • Unknown types in definitions must error (E1005, E1201).
  • Generic arity must match at use sites (E1203, E1204).
  • unit is the statement-result type; never is the bottom type for non-returning calls.
  • There is no null literal and no nullable reference type (?T, T?, or optional keyword) in v0.1.
  • Optional presence must use Option<T> (Query.Contracts.Option in corelib) or an explicit enum with a dedicated absent variant at API boundaries.
  • ref T in signatures denotes by-reference passing; it must not imply nullability or a separate reference/value type split.

Types describe compile-time properties; runtime representation is defined by lowering and execution ABI. Array values must use the BeskidArray layout documented in execution ABI material.

Type band E12xx (unknown type, mismatch, missing annotation, member access). Registry: Diagnostic code registry.

L2 conforming implementations must reject programs with unknown types, arity mismatches, and invalid field access per the reference beskid_analysis type tests.

  • D-LM-TYP-001 — Nominal types: Beskid uses nominal, path-resolved types; structural equivalence is not user-definable in v0.1.
  • D-LM-TYP-002 — Option<T> only: Optional values use Option<T> or explicit enums; null and optional keyword are forbidden.
  • D-LM-TYP-003 — T[] fat pointer: Array types share one runtime representation across targets unless a profile documents otherwise.
  • D-LM-TYP-004 — Single type system: No parallel reference/value kinds; ref is a passing mode, not a second class of types.

The type grammar (nominal types, generics, ref T, Option<T>) is the backbone of static checking. All analysis phases share these definitions.