Commit 7193b99
Type checker: Kategoria L1-L3 + L7 linear types + @Budget tracking
typechecker.rs (~2650 lines):
- Type IR covering all Kategoria levels (concrete L1-7, extension L8-10)
- Three-pass architecture: declaration gathering, type checking, linear verification
- L1: primitive inference, binop rules, Harvard violation detection
- L2: constructor typing, pattern exhaustiveness, enum registration
- L3: unification engine with occurs check, generic instantiation, purity subtyping
- L7: linear binding tracking — use exactly once, branch-consistent merging,
send_final consumption, exchange handle swap, spawn handle creation
- @Budget: token budget as linear quantity, cost deduction per operation,
cached branch (0 cost), @neural (0 cost), BudgetExceeded errors
- resolve_type_str: recursive-descent parser bridging String→Type IR
- Public API: check_program(), infer_expr(), infer_data()
typechecker_tests.rs (36 tests, 141 total):
- L1: literals, binop rules, Harvard violation
- L2: constructor typing, exhaustiveness checking
- L3: function calls, unification, purity enforcement
- L7: linear use-once/twice/never, branch consistent/inconsistent
- Budget: within/exceed, cached zero-cost, neural zero-cost
CLI: `oo7 typecheck <file>` command added.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 3b78b5f commit 7193b99
4 files changed
Lines changed: 3618 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| |||
102 | 105 | | |
103 | 106 | | |
104 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
105 | 132 | | |
106 | 133 | | |
107 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
0 commit comments