Types

Types are interned. Pointer identity is equality (TypeContext). Sema fills resolvedType() on AST nodes; codegen must not invent new language rules.

Kinds in the compiler

TypeKindExamples
Primitivei32, bool, str, void, never
GenericUnique[T], Ptr[i32], list[str], dict[K, V]
Recordclass, struct, enum
Function(i32, i32) -> i32
Aliastype Meters = i32
TypeParamT on a generic def / class
Moduleimported package object
UnionT | U

Any is a top type: every value is assignable to it. Omitted parameter and return types become Any. None is void as a named type, so both of these are valid:

sere
n: i32 | None = None
m: i32 | None = void

Primitives

TypeMeaning
voidNo value (function returns)
boolTrue / False
i8 i16 i32 i64Signed integers
u8 u16 u32 u64Unsigned integers
f32 f64IEEE floats
strString
byteAlias of u8
regexCompiled pattern (backtick literal)
neverDoes not return (panic, todo!)

Prelude aliases (unions):

sere
type Int = i8 | i16 | i32 | i64 | u8 | u16 | u32 | u64
type Float = f32 | f64

Integer widths mix in arithmetic. The result widens:

sere
type Number = i32 | i64
wide: i64 = 10
total: i64 = small + wide

Pointers

TypeMeaning
Unique[T]Exclusive heap pointer; dropped at end of scope
Shared[T]Reference-counted heap pointer
Ptr[T]Raw pointer; caller frees

All three are pointer-like (Type::isPointerLike, pointeeType()). They share an LLVM pointer representation with different drop / retain rules. See Memory.

Collections

TypeMeaning
list[T]Runtime list
array[T]Fixed array from array[T](...)
dict[K, V]Map

Empty dicts need an explicit constructor: dict[str, i32]().

User types

  • class — identity (reference). Inheritance and super() are allowed.
  • struct — copy-by-value. No inheritance.
  • enum — discriminant plus optional payloads.
  • type Name = ... — alias or union.

Cast with as or a constructor: n as i32, i32(tone), T(value), Unique[T](pointer).

What is not a type rule in codegen

If a program reaches IR generation, it is already well-typed. New facts belong on the AST or the Type, not in an LLVM pass. That is the contract that keeps the LSP, --analyze, and sere build agreeing.