Section 5: Type Declarations
Goal: User-defined types
SPEC:
spec/08-types.md,spec/09-properties-of-types.md,spec/10-declarations.md
Status: In-progress — Structs (5.1), sum types (5.2), newtypes (5.3), generics (5.4), built-in generics (5.6), derive (5.7), visibility (5.8), associated functions (5.9) all working in evaluator. Compound type inference (5.5) entirely pending. LLVM tests missing. Verified 2026-02-10.
SYNC POINT: Adding a new built-in type (e.g.,
Duration,Size,CPtr,Nursery) requires updates acrossori_ir(type variant),ori_types(registration + method signatures),ori_eval(runtime representation + method dispatch),ori_llvm(type layout + codegen), andlibrary/std/(prelude or module definitions). This section primarily covers user-defined types, but built-in types added by other sections (11, 16, 17, 18) follow the same pattern.
5.1 Struct Types
-
Implement: Parse
type Name = { field: Type, ... }— spec/08-types.md § Struct Types, spec/10-declarations.md § Type Declarations [done] (2026-02-10)- Rust Tests:
ori_parse/src/grammar/attr.rs—test_parse_struct_type - Ori Tests:
tests/spec/declarations/struct_types.ori(30+ tests: basic, single field, empty, nested, many fields, mixed types, generic, with Option/List/Tuple/Function fields)
- Rust Tests:
-
Implement: Register struct in type environment — spec/10-declarations.md § Type Declarations [done] (2026-02-10)
- Rust Tests:
ori_types/src/check/registration/— type registry tests - Ori Tests: All struct tests verify type registration
- Rust Tests:
-
Implement: Parse struct literals
Name { field: value }— spec/08-types.md § Struct Types [done] (2026-02-10)- Rust Tests:
ori_parse/src/grammar/postfix.rs— struct literal parsing - Ori Tests:
tests/spec/declarations/struct_types.ori— all tests create struct literals
- Rust Tests:
-
Implement: Type check struct literals — spec/08-types.md § Struct Types [done] (2026-02-10)
- Rust Tests:
ori_types/src/infer/— struct literal type checking - Ori Tests:
tests/spec/declarations/struct_types.ori - LLVM Support: LLVM codegen for struct literal construction
- LLVM Rust Tests:
ori_llvm/tests/struct_tests.rs— struct literal codegen (file does not exist) - AOT Tests:
ori_llvm/tests/aot/structs.rs— 30 tests, 1 ignored (struct construction with int/bool/str/mixed fields, update syntax, nested structs, function params/returns, closures, derived Eq)
- Rust Tests:
-
Implement: Shorthand
Point { x, y }— spec/08-types.md § Struct Types [done] (2026-02-10)- Rust Tests:
ori_parse/src/grammar/postfix.rs— shorthand parsing - Ori Tests:
tests/spec/declarations/struct_types.ori—test_shorthand_init,test_mixed_shorthand - LLVM Support: LLVM codegen for shorthand struct construction
- LLVM Rust Tests:
ori_llvm/tests/struct_tests.rs— shorthand struct codegen (file does not exist) - AOT Tests: No AOT coverage yet —
ori_llvm/tests/aot/structs.rsdoes not test shorthand syntax
- Rust Tests:
-
Implement: Field access — spec/08-types.md § Struct Types [done] (2026-02-10)
- Rust Tests:
ori_types/src/infer/— field access type inference - Ori Tests:
tests/spec/declarations/struct_types.ori— field chaining (c.ceo.name, deep nesting) - LLVM Support: LLVM codegen for struct field access
- LLVM Rust Tests:
ori_llvm/tests/struct_tests.rs— field access codegen (file does not exist) - AOT Tests:
ori_llvm/tests/aot/structs.rs— all 30 tests exercise field access; nested field chains intest_struct_nested_basic,test_struct_nested_three_levels
- Rust Tests:
-
Implement: Destructuring — spec/14-expressions.md § Destructuring [done] (2026-02-10)
- Rust Tests: Parser in
ori_parse/src/grammar/expr/primary.rs—parse_binding_pattern() - Ori Tests:
tests/spec/declarations/struct_types.ori—test_destructure,test_destructure_partial,test_destructure_rename - LLVM Support: LLVM codegen for struct destructuring
- LLVM Rust Tests:
ori_llvm/tests/struct_tests.rs— destructuring codegen (file does not exist) - AOT Tests: No AOT coverage yet —
ori_llvm/tests/aot/structs.rsdoes not test struct destructuring
- Rust Tests: Parser in
5.2 Sum Types (Enums) — COMPLETED 2026-01-28
-
Implement: Parse
type Name = Variant1 | Variant2(Type)[done] (2026-02-10)- Rust Tests:
ori_parse/src/grammar/attr.rs—test_parse_sum_type - Ori Tests:
tests/spec/declarations/sum_types.ori(30+ tests)
- Rust Tests:
-
Implement: Unit variants [done] (2026-02-10)
- Rust Tests:
ori_parse/src/grammar/attr.rs— included intest_parse_sum_type - Ori Tests: Color (Red|Green|Blue), Direction (NSEW), Toggle (On|Off), Status (4 variants)
- Rust Tests:
-
Implement: Single-field variants
Variant(Type)[done] (2026-02-10)- Rust Tests:
ori_parse/src/grammar/attr.rs— single-field variant parsing - Ori Tests: MyOption (MySome/MyNone), Message (Text/Empty)
- LLVM Support: LLVM codegen for single-field variants
- LLVM Rust Tests:
ori_llvm/tests/sum_type_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Multi-field variants
Variant(x: Type, y: Type)[done] (2026-02-10)- Rust Tests:
ori_parse/src/grammar/attr.rs— multi-field variant parsing - Ori Tests: Shape (Circle/Rectangle), Point3D, Event (Click/KeyPress/Quit), Response (Success/Error)
- LLVM Support: LLVM codegen for multi-field variants
- LLVM Rust Tests:
ori_llvm/tests/sum_type_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Struct variants [done] (2026-02-10)
- Rust Tests:
ori_parse/src/grammar/attr.rs— struct variant parsing (named fields) - Ori Tests: All multi-field variants use named fields
- Rust Tests:
-
Implement: Variant constructors [done] (2026-02-10)
- Rust Tests:
ori_types/src/infer/— variant constructor type checking - Ori Tests: All sum type tests construct variants; generic sum types (MyResult, MyOptional, LinkedList, Tree)
- LLVM Support: LLVM codegen for variant constructors
- LLVM Rust Tests:
ori_llvm/tests/sum_type_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Pattern matching on variants [done] (2026-02-10)
- Rust Tests:
ori_types/src/infer/— variant pattern matching - Ori Tests: Exhaustive match, wildcard, nested match, variable binding, recursive Expr eval
- LLVM Support: LLVM codegen for variant pattern matching
- LLVM Rust Tests:
ori_llvm/tests/matching_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Note:
#derive(Eq)for sum types NOT working (skipped in tests)
- Rust Tests:
5.3 Newtypes
Proposal: proposals/approved/newtype-pattern-proposal.md
-
Implement: Parse
type Name = ExistingType[done] (2026-02-10)- Rust Tests:
ori_parse/src/grammar/attr.rs—test_parse_newtype - Ori Tests:
tests/spec/types/newtypes.ori(UserId, Email, Age, Score)
- Rust Tests:
-
Implement: Distinct type identity (nominal) [done] (2026-02-10)
- Rust Tests:
ori_types/src/check/ (type registry)— nominal type identity - Ori Tests:
tests/spec/types/newtypes.ori— separate UserId/Email types, validate_user/validate_email - LLVM Support: Transparent at runtime (same as underlying type)
- Rust Tests:
-
Implement: Wrapping/unwrapping [done] (2026-02-10)
- Rust Tests:
ori_eval/src/methods.rs— newtype unwrap method - Ori Tests:
tests/spec/types/newtypes.ori— 9 tests (construction, unwrap, equality, params, computation) - LLVM Support: Transparent at runtime (newtype constructor just stores underlying value)
- Rust Tests:
-
Implement: Change
.unwrap()to.inneraccessor — spec/08-types.md § Newtypes- Rust Tests: Update
ori_eval/src/methods.rstests to use.inner - Ori Tests: Update
tests/spec/types/newtypes.orito use.inner - LLVM Support: Update LLVM codegen to use
.innerfield access - LLVM Rust Tests:
ori_llvm/tests/newtype_tests.rs—.inneraccessor codegen - AOT Tests: No AOT coverage yet
- Note:
.inneris always public regardless of newtype visibility - Note: Currently using
.unwrap()— migration to.innerpending
- Rust Tests: Update
5.4 Generic Types
-
Implement: Parse
type Name<T> = ...[done] (2026-02-10)- Rust Tests:
ori_parse/src/grammar/attr.rs—test_parse_generic_type_with_bounds - Ori Tests:
tests/spec/types/generic.ori(Box, Pair<A,B>, Container , Wrapper )
- Rust Tests:
-
Implement: Multiple parameters
<T, U>[done] (2026-02-10)- Rust Tests: Covered by parser tests
- Ori Tests:
tests/spec/types/generic.ori—test_pair_int_str,test_pair_str_bool
-
Implement: Constrained
<T: Trait>— spec/10-declarations.md § Generic Declarations- Rust Tests:
ori_types/src/check/bound_checking.rs— constrained generics - Ori Tests:
tests/spec/declarations/attributes.ori—GenericDerived<T: Eq>works - LLVM Support: LLVM codegen for constrained generics
- LLVM Rust Tests:
ori_llvm/tests/generic_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Multiple bounds
<T: A + B>— spec/10-declarations.md § Generic Declarations- Rust Tests:
ori_types/src/check/bound_checking.rs— multiple bounds - Ori Tests: Not tested yet
- LLVM Support: LLVM codegen for multiple bounds
- LLVM Rust Tests:
ori_llvm/tests/generic_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Generic application / Instantiation [done] (2026-02-10)
- Rust Tests:
ori_types/src/infer/—infer_structhandles instantiation - Ori Tests:
tests/spec/types/generic.ori— 14 tests (Box, Box , Pair<int,str>, nested, chained access, method calls on fields) - Note:
Type::Appliedtracks instantiated generic types.
- Rust Tests:
-
Implement: Constraint checking — spec/08-types.md § Generic Types
- Rust Tests:
ori_types/src/check/bound_checking.rs— constraint checking - Ori Tests:
tests/spec/declarations/attributes.ori—GenericDerived<T: Eq>constraint checked - LLVM Support: LLVM codegen for constraint checking
- LLVM Rust Tests:
ori_llvm/tests/generic_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
5.5 Compound Types
Note: tests/spec/types/collections.ori is ENTIRELY COMMENTED OUT — type checker doesn’t support collection type inference yet. Lists, tuples, maps work in the evaluator but type checker support is pending.
-
Implement: List
[T]— spec/08-types.md § List Type- Rust Tests:
ori_types/src/infer/collections.rs— list type inference - Ori Tests:
tests/spec/types/collections.ori— all commented out - LLVM Support: LLVM codegen for list type
- LLVM Rust Tests:
ori_llvm/tests/collection_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Note: Lists work in evaluator (used in struct_types.ori, sum_types.ori) but type inference commented out
- Rust Tests:
-
Implement: Map
{K: V}— spec/08-types.md § Map Type- Rust Tests:
ori_types/src/infer/collections.rs— map type inference - Ori Tests:
tests/spec/types/collections.ori— all commented out - LLVM Support: LLVM codegen for map type
- LLVM Rust Tests:
ori_llvm/tests/collection_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Set
Set<T>— spec/08-types.md § Set Type- Rust Tests:
ori_types/src/infer/collections.rs— set type inference - Ori Tests:
tests/spec/types/collections.ori— all commented out - LLVM Support: LLVM codegen for set type
- LLVM Rust Tests:
ori_llvm/tests/collection_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Tuple
(T, U)— spec/08-types.md § Tuple Types- Parser: Numeric field access
.0,.1—expect_member_name()accepts integer literals (2026-02-15) - Parser Rust Tests:
ori_parse/src/tests/parser.rs—test_tuple_field_access,test_chained_tuple_field_access_with_parens,test_bare_chained_tuple_field_is_error(2026-02-15) - Ori Tests:
tests/spec/types/tuple_types.ori— 6 field access tests: pair, different types, triple, nested with parens, single-element, return value (2026-02-15) - Spec/Grammar: Updated
grammar.ebnf§member_name,09-expressions.md,06-types.md(2026-02-15) - Rust Tests:
ori_types/src/infer/— tuple type inference - Ori Tests:
tests/spec/types/collections.ori— all commented out - LLVM Support: LLVM codegen for tuple type
- LLVM Rust Tests:
ori_llvm/tests/collection_tests.rs(file does not exist) - AOT Tests:
ori_llvm/tests/aot/tuples.rs— 28 tests, 6 ignored (construction, field access, destructuring, nested tuples, function param/return, strings, control flow, closures, equality) - Parser: Chained field access without parens (
t.0.1) — requires source text in parser or text inFloattoken - Note: Tuples work in evaluator (used in struct_types.ori destructuring) but type inference commented out
- BUG FOUND: decision tree column count mismatch on tuple patterns with nested constructors + wildcard (e.g.,
(None, _)) — seecompile/mod.rs:67
- Parser: Numeric field access
-
Implement: Range
Range<T>— spec/08-types.md § Range Type- Rust Tests:
ori_types/src/infer/— range type inference - Ori Tests:
tests/spec/expressions/loops.ori - LLVM Support: LLVM codegen for range type
- LLVM Rust Tests:
ori_llvm/tests/range_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Function
(T) -> U— spec/08-types.md § Function Types- Rust Tests:
ori_types/src/infer/lambda.rs— function type inference - Ori Tests:
tests/spec/expressions/lambdas.ori - LLVM Support: LLVM codegen for function types
- LLVM Rust Tests:
ori_llvm/tests/function_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Note: Function types work in evaluator (used in struct_types.ori
WithFunction)
- Rust Tests:
5.6 Built-in Generic Types
-
Implement:
Option<T>withSome/None[done] (2026-02-10)- Rust Tests:
ori_types/src/infer/— Option type handling - Ori Tests: Used throughout test suite (struct_types.ori, sum_types.ori, traits/)
- LLVM Support: LLVM codegen for Option type — inline IR in lower_calls.rs
- LLVM Rust Tests:
ori_llvm/tests/option_result_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement:
Result<T, E>withOk/Err[done] (2026-02-10)- Rust Tests:
ori_types/src/infer/— Result type handling - Ori Tests: Used in traits/core/ tests, test suite
- LLVM Support: LLVM codegen for Result type — inline IR in lower_calls.rs
- LLVM Rust Tests:
ori_llvm/tests/option_result_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement:
OrderingwithLess/Equal/Greater[done] (2026-02-10)- Rust Tests:
ori_types/src/infer/— Ordering type handling - Ori Tests:
tests/spec/types/ordering/methods.ori(32 tests) - LLVM Support: LLVM codegen for Ordering type — i8 comparison in lower_calls.rs
- LLVM Rust Tests:
ori_llvm/tests/ordering_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement:
Errortype — spec/17-errors-and-panics.md § Error Conventions- Rust Tests:
ori_types/src/infer/— Error type handling - Ori Tests:
tests/spec/types/error.ori— not verified - LLVM Support: LLVM codegen for Error type
- LLVM Rust Tests:
ori_llvm/tests/error_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement:
Channel<T>— spec/08-types.md § Channel- Rust Tests:
ori_types/src/infer/— Channel type handling - Ori Tests:
tests/spec/types/channel.ori— not implemented - LLVM Support: LLVM codegen for Channel type
- LLVM Rust Tests:
ori_llvm/tests/channel_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
5.7 with Clause on Type Declarations (Capability Unification)
Proposal: proposals/approved/capability-unification-generics-proposal.md — Phase 1
Replace #derive(Trait) with type T: Trait = .... Derivation moves from attribute syntax into the type declaration grammar as a : trait clause.
SUPERSEDES: Previous syntax
#derive(Eq, Clone)and#[derive(Eq, Clone)]are both replaced bytype T: Eq, Clone = { ... }.
Syntax Migration
- Implement: Parser — parse
:trait clause inparse_type_decl()between generics andwhere/=- Rust Tests:
ori_parse/src/tests/parser.rs—:trait clause parsing - Ori Tests:
tests/spec/declarations/trait_clause.ori
- Rust Tests:
- Implement: IR — add
derive_traits: Vec<DerivedTrait>toTypeDefnode (replacing attribute-sourced data) - Implement: Remove
parse_derive_attr()from parser; keep as migration error suggesting:- Ori Tests:
tests/compile-fail/old_derive_syntax.ori
- Ori Tests:
- Migration: Update all
#derive(...)in spec tests to:trait clause (~193 files) - Migration: Migration script (
scripts/migrate_derive_syntax.py) - Update Spec:
grammar.ebnf—type_defproduction - Update:
.claude/rules/ori-syntax.md— derive syntax - Verify:
./test-all.shpasses after migration
Existing Derive Functionality (carries forward)
-
Implement: Parse
#[derive(Trait1, Trait2)][done] (2026-02-10) — to be replaced by:trait clause- Rust Tests:
ori_parse/src/grammar/attr.rs— derive attribute parsing - Ori Tests:
tests/spec/declarations/attributes.ori(15+ tests) - LLVM Support: LLVM codegen for derive attributes
- LLVM Rust Tests:
ori_llvm/tests/derive_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement:
#derive(Eq)[done] (2026-02-10)- Rust Tests:
ori_types/src/check/ (derive Eq)— derive Eq generation - Ori Tests:
tests/spec/declarations/attributes.ori— EqPoint, EmptyDerived, SingleFieldDerived, nested derive, generic derive - LLVM Support: LLVM codegen for derived Eq
- LLVM Rust Tests:
ori_llvm/tests/derive_tests.rs(file does not exist) - AOT Tests:
ori_llvm/tests/aot/structs.rs—test_struct_derived_eq,test_struct_derived_eq_string(struct Eq with int and string fields) - Note: Derive(Eq) for SUM TYPES not working (skipped in tests)
- Rust Tests:
-
Implement:
#derive(Clone)[done] (2026-02-10)- Rust Tests:
ori_types/src/check/ (derive Clone)— derive Clone generation - Ori Tests:
tests/spec/declarations/attributes.ori— ClonePoint, SingleFieldDerived - LLVM Support: LLVM codegen for derived Clone
- LLVM Rust Tests:
ori_llvm/tests/derive_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement:
#derive(Hashable)[done] (2026-02-10)- Rust Tests:
ori_types/src/check/ (derive Hashable)— derive Hashable generation - Ori Tests:
tests/spec/declarations/attributes.ori— HashPoint, MultiAttrPoint - LLVM Support: LLVM codegen for derived Hashable
- LLVM Rust Tests:
ori_llvm/tests/derive_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement:
#derive(Printable)— spec/10-declarations.md § Attributes- Rust Tests:
ori_types/src/check/derives/printable.rs— derive Printable generation - Ori Tests:
tests/spec/declarations/attributes.ori— skipped (“derive(Printable) not fully implemented”) - LLVM Support: LLVM codegen for derived Printable
- LLVM Rust Tests:
ori_llvm/tests/derive_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Note: Works in traits/derive/all_derives.ori but skipped in declarations/attributes.ori
- Rust Tests:
-
Implement:
#derive(Default)— spec/10-declarations.md § Attributes- Rust Tests:
ori_types/src/check/derives/default.rs— derive Default generation - Ori Tests: Not tested
- LLVM Support: LLVM codegen for derived Default
- LLVM Rust Tests:
ori_llvm/tests/derive_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
5.8 Visibility
-
Implement: Parse
pub type Name = ...[done] (2026-02-10)- Rust Tests:
ori_parse/src/grammar/item.rs— pub type parsing - Ori Tests:
tests/spec/declarations/struct_types.ori—pub type PublicStruct,tests/spec/declarations/sum_types.ori—pub type PublicStatus - LLVM Support: LLVM codegen for pub type visibility
- LLVM Rust Tests:
ori_llvm/tests/visibility_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Public visible from other modules [done] (2026-02-10)
- Rust Tests:
ori_eval/src/interpreter/module/visibility.rs— public visibility - Ori Tests:
tests/spec/modules/use_imports.ori—pub type Pointimported cross-module - LLVM Support: LLVM codegen for public visibility
- LLVM Rust Tests:
ori_llvm/tests/visibility_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement: Private only in declaring module [done] (2026-02-10)
- Rust Tests:
ori_eval/src/interpreter/module/visibility.rs— private visibility - Ori Tests:
tests/spec/modules/use_imports.ori—type InternalPoint(private) - LLVM Support: LLVM codegen for private visibility
- LLVM Rust Tests:
ori_llvm/tests/visibility_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- Rust Tests:
5.9 Associated Functions
Proposal: proposals/approved/associated-functions-language-feature.md
Generalize associated functions to work for ANY type with an impl block, removing hardcoded type checks. Enables syntax like Point.origin(), Builder.new(), Duration.from_seconds(s: 10).
Migration
- Implement: Remove
is_type_name_for_associated_functions()hardcoded checks [done] (2026-02-10)- Rust Tests:
ori_types/src/infer/ (calls)— general type name resolution - Ori Tests:
tests/spec/types/associated_functions.ori— user types (Point, Builder, Counter, Rectangle, Pair) all work
- Rust Tests:
Parsing
-
Implement: Parse
Type.method(...)syntax in expression position [done] (2026-02-10)- Rust Tests:
ori_parse/src/grammar/postfix.rs— type-prefixed method call - Ori Tests:
Point.origin(),Builder.new(),Counter.zero(),Rectangle.square(size: 5)
- Rust Tests:
-
Implement: Distinguish type name vs value in resolution [done] (2026-02-10)
- Rust Tests:
ori_types/src/infer/— type vs value resolution - Ori Tests:
test_instance_vs_associated—Pair.create()(type) vsp.sum()(value)
- Rust Tests:
Associated Function Registry
-
Implement: Track methods without
selfin impl blocks [done] (2026-02-10)- Rust Tests:
ori_types/src/check/ (method registry)— associated function registry - Ori Tests: Point.origin(), Point.new(), Builder.new(), Counter.zero(), Counter.starting_at(), Rectangle.square/from_dimensions/unit(), Pair.create()
- Rust Tests:
-
Implement: Built-in associated functions for Duration [done] (2026-02-10)
- Ori Tests:
tests/spec/types/associated_functions.ori—Duration.from_seconds(s: 5)verified - Duration.from_nanoseconds(ns:), from_microseconds(us:), from_milliseconds(ms:)
- Duration.from_seconds(s:), from_minutes(m:), from_hours(h:)
- Ori Tests:
-
Implement: Built-in associated functions for Size [done] (2026-02-10)
- Ori Tests:
tests/spec/types/associated_functions.ori—Size.from_megabytes(mb: 2)verified - Size.from_bytes(b:), from_kilobytes(kb:), from_megabytes(mb:)
- Size.from_gigabytes(gb:), from_terabytes(tb:)
- Ori Tests:
Generic Types
- Implement: Full type arguments required for generic associated functions
- Ori Tests: Not tested —
Option<int>.some(value: 42)pattern not verified - Example:
Option<int>.some(value: 42)
- Ori Tests: Not tested —
Self Return Type
- Implement: Allow
Selfas return type in associated functions [done] (2026-02-10)- Ori Tests:
tests/spec/types/associated_functions.ori— Point.origin() -> Self, Builder.new() -> Self, Counter.zero() -> Self, Counter.increment(self) -> Self
- Ori Tests:
Trait Associated Functions
- Implement: Traits can define associated functions without
self- Rust Tests:
ori_types/src/check/registration/traits.rs— trait associated functions - Ori Tests: Not tested —
trait Default { @default () -> Self }pattern - Example:
trait Default { @default () -> Self }
- Rust Tests:
LLVM Support
- LLVM Support: Codegen for associated function calls
- LLVM Rust Tests:
ori_llvm/tests/associated_function_tests.rs(file does not exist) - AOT Tests: No AOT coverage yet
- LLVM Rust Tests:
5.10 Section Completion Checklist
- Struct types (definition, literal, shorthand, field access, destructuring, spread, generic) [done]
- Sum types (unit, single-field, multi-field, generic, recursive, pattern matching) [done]
- Newtypes (construction, unwrap, nominal identity) [done]
- Generic types (single/multiple params, instantiation, field access chain) [done]
- Built-in generics: Option, Result, Ordering [done]
- Derive: Eq, Clone, Hashable on structs [done]
- Visibility: pub type, private by default [done]
- Associated functions: Type.method() for user types, Duration, Size [done]
- Compound type inference (5.5) — entirely pending
- Derive: Printable, Default — not working
- Derive(Eq) for sum types — not working
- Newtype
.inneraccessor migration — pending - Generic associated functions with type args — not tested
- Trait associated functions — not tested
- LLVM codegen for all type declarations — no dedicated test files
- Run full test suite:
./test-all.sh
Exit Criteria: User-defined structs and enums work Status: Evaluator support complete for core features. Type checker compound inference and several derive impls pending. Verified 2026-02-10.