Types
Platform spec node
Types
Spec standingStandard
No architecture decision records under adr/ for this feature yet. Standard features must
publish at least one ADR or keep a ## Decisions summary on the hub.
- Enums and match Algebraic enums and exhaustive `match` tie data representation to control flow. Lowering must preserve discriminant layout described in Execution where relevant.
- Method dispatch Virtual dispatch, overload resolution, and receiver rules decide which code runs. Interop and codegen consume the same dispatch table model.
- Type inference Local type inference reduces annotation burden while keeping programs predictable. The inference algorithm is specified here; diagnostics reference these rules.
- Types The type grammar (nominal types, generics, ref T, Option T) is the backbone of static checking. All analysis phases share these definitions.
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
| Section id | Required | Found |
|---|---|---|
scope | yes | yes |
features | yes | yes |
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
Normative specification
Section titled “Normative specification”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.
Type expressions
Section titled “Type expressions”A type expression (BeskidType) must be exactly one of:
| Form | Syntax | Meaning |
|---|---|---|
| Primitive | bool, i32, i64, u8, f64, char, string, unit | Builtin scalar types |
| Named | Path with optional GenericArguments | Nominal reference to type, enum, or generic parameter |
| Array | T[] | Homogeneous slice-like sequence; runtime ABI uses fat pointer layout |
| Reference | ref T | By-reference parameter passing surface (see memory chapter) |
| Function | T(params) or (params) => R | Function types for values and signatures |
Primitives must map to HirPrimitiveType variants in the reference compiler.
Type declarations
Section titled “Type declarations”type Name<G…> : Contracts… { fields }introduces a nominal record-like type.- Fields may be value fields (
T name),eventfields (see Events), orinjectfields (composition only). - Conformance list (
: I, J) declares contract implementations checked in Contracts. enumdeclarations are specified in Enums and match.extend typeadds members externally per extend type.
Static rules
Section titled “Static rules”- 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).
unitis the statement-result type;neveris the bottom type for non-returning calls.- There is no
nullliteral and no nullable reference type (?T,T?, oroptionalkeyword) in v0.1. - Optional presence must use
Option<T>(Query.Contracts.Optionin corelib) or an explicitenumwith a dedicated absent variant at API boundaries. ref Tin signatures denotes by-reference passing; it must not imply nullability or a separate reference/value type split.
Dynamic semantics
Section titled “Dynamic semantics”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.
Diagnostics
Section titled “Diagnostics”Type band E12xx (unknown type, mismatch, missing annotation, member access). Registry: Diagnostic code registry.
Conformance
Section titled “Conformance”L2 conforming implementations must reject programs with unknown types, arity mismatches, and invalid field access per the reference beskid_analysis type tests.
Decisions
Section titled “Decisions”- 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 useOption<T>or explicit enums;nullandoptionalkeyword 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;
refis a passing mode, not a second class of types.
Platform view
Section titled “Platform view”The type grammar (nominal types, generics, ref T, Option<T>) is the backbone of static checking. All analysis phases share these definitions.