Type System
Primitive types
Section titled “Primitive types”| Type | Size | Description |
|---|---|---|
i64 | 8 bytes | 64-bit signed integer |
f64 | 8 bytes | 64-bit IEEE 754 float |
bool | 1 byte | Boolean (i8 in Cranelift) |
void | 0 bytes | No value (unit type) |
Heap types
Section titled “Heap types”| Type | Description |
|---|---|
string | UTF-8 string (runtime-managed) |
array<T> | Dynamic array of type T |
struct<Name> | Named struct with typed fields |
Reference types
Section titled “Reference types”| Type | Description |
|---|---|
&T | Immutable reference |
&mut T | Mutable reference (exclusive) |
Error handling types
Section titled “Error handling types”| Type | Description |
|---|---|
result<T, E> | Success (Ok(T)) or failure (Err(E)) |
option<T> | Value (Some(T)) or nothing (None) |
Type annotations in JSON-LD
Section titled “Type annotations in JSON-LD”Types are specified via duumbi:valueType and duumbi:returnType:
{ "@type": "duumbi:Const", "duumbi:value": 42, "duumbi:valueType": "i64"}{ "@type": "duumbi:Function", "duumbi:returnType": "result<i64, string>", "duumbi:params": [ { "duumbi:name": "x", "duumbi:paramType": "&array<i64>" } ]}Type compatibility
Section titled “Type compatibility”- Arithmetic ops (
Add,Sub,Mul,Div) require matching operand types Compareworks on matching numeric types, returningboolBranchrequires aboolconditionCallvalidates parameter types against function signatureMatchrequires aresult<T,E>oroption<T>discriminant