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
+32 -1
View File
@@ -1,5 +1,6 @@
module Std::Test {
import Std::Io::{PrintLine, PrintInt};
import Std::String::{String_Eq};
extern func bux_exit(code: int);
extern func bux_assert(cond: int, file: String, line: int, expr: String);
@@ -14,7 +15,7 @@ func Test_Assert(cond: bool) {
func Test_AssertEqInt(a: int, b: int) {
if a != b {
PrintLine("ASSERT_EQ FAILED:");
PrintLine("ASSERT_EQ_INT FAILED:");
PrintInt(a);
PrintLine(" != ");
PrintInt(b);
@@ -22,6 +23,31 @@ func Test_AssertEqInt(a: int, b: int) {
}
}
func Test_AssertNeqInt(a: int, b: int) {
if a == b {
PrintLine("ASSERT_NEQ_INT FAILED: both are");
PrintInt(a);
bux_exit(1);
}
}
func Test_AssertEqString(a: String, b: String) {
if !String_Eq(a, b) {
PrintLine("ASSERT_EQ_STRING FAILED:");
PrintLine(a);
PrintLine(" != ");
PrintLine(b);
bux_exit(1);
}
}
func Test_AssertEqBool(a: bool, b: bool) {
if a != b {
PrintLine("ASSERT_EQ_BOOL FAILED");
bux_exit(1);
}
}
func Test_AssertTrue(cond: bool) {
if !cond {
PrintLine("ASSERT_TRUE FAILED");
@@ -42,4 +68,9 @@ func Test_Fail(msg: String) {
bux_exit(1);
}
func Test_Pass(msg: String) {
PrintLine("PASS:");
PrintLine(msg);
}
}