feat: multi-instance closures, richer stdlib, and Rust-style diagnostics

Introduce fat function pointers (BuxFn {code, env}) so capturing closures
are heap-allocated per value in both bootstrap and selfhost. Expand
Array/Map/Set/String/Test/Result APIs, add proper tuple codegen and
error snippets with multi-char underlines, golden diagnostic tests, and
LSP diagnostics via buxc check.
This commit is contained in:
2026-07-15 16:00:21 +03:00
parent 94e6806dda
commit 61ac06ab5f
48 changed files with 2789 additions and 362 deletions
+3 -1
View File
@@ -153,7 +153,9 @@ Array_Filter(nums, |x| { return x > 10; });
4. In thunk body: rewrite captured identifiers to `env_instance.x` via `hFieldAccess`.
5. C backend: emit env struct definition + global instance before thunk function.
**Limitations:** One global instance per closure AST node (no multiple instances). No loop/return support in closures yet.
**Status:** Multi-instance capturing closures work in **both** bootstrap and selfhost via fat
function pointers (`BuxFn { code, env }` + heap-allocated env per creation). Capture-less
closures and named functions use the same ABI (`env = NULL`, adapters for named funcs).
**Complexity:** High — touches parser, sema, type system, HIR/LIR backend.