1.2 Type System
Runtime Representation
udewy treats everything as 64-bit integers at runtime. Pointers, booleans, characters—all are integers under the hood. There is no runtime type checking.
Type Annotations
Type annotations are syntactically required in variable declarations and function signatures but are not checked by the udewy compiler. They exist to:
- Maintain compatibility with full Dewy (which does check types)
- Document programmer intent
- Guide certain parsing decisions
Variable type annotation (:type):
let x:int = 42
Parameterized types (:type<param> or <param> alone):
let data:array<int> = buffer
let mixed<int|string> = value # type param without colon
The content inside <> is not validated, and annotations such as array<T> are opaque to udewy. This allows complex type expressions that udewy couldn't otherwise parse:
let x<(int & Something<10>) | undefined> = 10
Function return type (:>type, :>type<param> or :> <param>):
let add = (a:int b:int):>int => { return a + b }
let get_value = ():>result<int> => { ... }
let flexible = ():> <A&B|C<int>> => { ... } # complex return type
The transmute Keyword
transmute is a bit-preserving type cast that is a no-op in udewy:
let ptr:int = some_address transmute int
let arr:int = buffer transmute array<byte>
transmute preserves the underlying bits while changing the type annotation. It allows udewy code that manipulates raw integers to be valid in the strictly-typed full Dewy.
Syntax: <expr> transmute <type>
Where <type> can be an identifier, an identifier with type parameters, or just type parameters:
expr transmute int
expr transmute array<int>
expr transmute <T|U>
Ignored Type Declarations
udewy also accepts a narrow Dewy-compatibility declaration form:
Point:type = [x:int y:int]
let Point:type = [x:int y:int]
Line:type = [start:Point end:Point]
This form is recognized only when the annotation is the literal type. In udewy, it is treated like an ignored type-level declaration:
- the entire right-hand side is consumed syntactically and ignored
- no runtime code is generated
- no local or global value binding is created
This allows shared udewy/Dewy source to include named type or struct declarations for the full Dewy compiler without affecting udewy execution.