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:
+3
-1
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user