diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 64e9c10..2606402 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -204,8 +204,6 @@ extend Array { --- -## P1 — High Impact - ### 9. Trait Bounds (`T: Comparable`) **Why:** Generic functions need constraints on type parameters. @@ -234,27 +232,9 @@ const C: int = A + B; // Evaluated at compile time --- -### 11. Destructors / `Drop` Trait -**Why:** `own T` exists but nothing cleans up automatically. Complements `defer`. - -**Syntax:** -```bux -extend Array { - func Drop(self: own Array) { - Array_Free(self); - } -} -``` - -**Status:** ⏳ Not started. - -**Complexity:** High — needs ownership tracking + C backend scope emission. - ---- - ## P2 — Nice to Have -### 12. Concurrency +### 11. Concurrency **Why:** Go-style goroutines + channels, but without GC. **Syntax:** diff --git a/src/hir_lower.bux b/src/hir_lower.bux index 88d2636..c200d53 100644 --- a/src/hir_lower.bux +++ b/src/hir_lower.bux @@ -1278,18 +1278,10 @@ func Lcx_LowerStmt(ctx: *LowerCtx, stmt: *Stmt) -> *HirNode { // Handle already-monomorphized types like Array_int, Iter_string var isArray: bool = String_Eq(collTypeName, "Array"); var isIter: bool = String_Eq(collTypeName, "Iter"); - if String_Eq(elemTypeName, "") { - // Manual prefix check for "Array_" - var isArrayPrefix: bool = false; - var isIterPrefix: bool = false; - let collName: String = collTypeName; - if collName[0] as int == 65 && collName[1] as int == 114 && collName[2] as int == 114 && collName[3] as int == 97 && collName[4] as int == 121 && collName[5] as int == 95 { - isArrayPrefix = true; - } - if collName[0] as int == 73 && collName[1] as int == 116 && collName[2] as int == 101 && collName[3] as int == 114 && collName[4] as int == 95 { - isIterPrefix = true; - } - if isArrayPrefix { + + // Also check for mangled names like Array_int, Iter_string + if !isArray && !isIter { + if String_StartsWith(collTypeName, "Array_") { isArray = true; let prefixLen: uint = 6; // len("Array_") let totalLen: uint = bux_strlen(collTypeName); @@ -1297,7 +1289,7 @@ func Lcx_LowerStmt(ctx: *LowerCtx, stmt: *Stmt) -> *HirNode { elemTypeName = bux_str_slice(collTypeName, prefixLen, totalLen - prefixLen); elemTypeKind = Lcx_ResolveTypeKindFromName(elemTypeName); } - } else if isIterPrefix { + } else if String_StartsWith(collTypeName, "Iter_") { isIter = true; let prefixLen: uint = 5; // len("Iter_") let totalLen: uint = bux_strlen(collTypeName); diff --git a/tests/golden/algebraic_enums/expected.c b/tests/golden/algebraic_enums/expected.c index 7479cc4..45825a8 100644 --- a/tests/golden/algebraic_enums/expected.c +++ b/tests/golden/algebraic_enums/expected.c @@ -132,6 +132,7 @@ extern const char* bux_str_join2(const char* a, const char* b, const char* sep); extern const char* bux_float_to_string(double f); extern const char* bux_str_format(const char* pattern, const char* a0, const char* a1, const char* a2, const char* a3, const char* a4, const char* a5, const char* a6, const char* a7); extern double bux_str_to_float(const char* s); +extern void bux_bounds_check(unsigned int index, unsigned int len); extern void bux_sha1(const char* data, int len, void* out); extern void bux_sha256(const char* data, int len, void* out); extern void bux_sha384(const char* data, int len, void* out); diff --git a/tests/golden/enums/expected.c b/tests/golden/enums/expected.c index f45bbaa..0a7f9b4 100644 --- a/tests/golden/enums/expected.c +++ b/tests/golden/enums/expected.c @@ -132,6 +132,7 @@ extern const char* bux_str_join2(const char* a, const char* b, const char* sep); extern const char* bux_float_to_string(double f); extern const char* bux_str_format(const char* pattern, const char* a0, const char* a1, const char* a2, const char* a3, const char* a4, const char* a5, const char* a6, const char* a7); extern double bux_str_to_float(const char* s); +extern void bux_bounds_check(unsigned int index, unsigned int len); extern void bux_sha1(const char* data, int len, void* out); extern void bux_sha256(const char* data, int len, void* out); extern void bux_sha384(const char* data, int len, void* out); diff --git a/tests/golden/fibonacci/expected.c b/tests/golden/fibonacci/expected.c index a7f9c3d..80e8824 100644 --- a/tests/golden/fibonacci/expected.c +++ b/tests/golden/fibonacci/expected.c @@ -132,6 +132,7 @@ extern const char* bux_str_join2(const char* a, const char* b, const char* sep); extern const char* bux_float_to_string(double f); extern const char* bux_str_format(const char* pattern, const char* a0, const char* a1, const char* a2, const char* a3, const char* a4, const char* a5, const char* a6, const char* a7); extern double bux_str_to_float(const char* s); +extern void bux_bounds_check(unsigned int index, unsigned int len); extern void bux_sha1(const char* data, int len, void* out); extern void bux_sha256(const char* data, int len, void* out); extern void bux_sha384(const char* data, int len, void* out); diff --git a/tests/golden/generics/expected.c b/tests/golden/generics/expected.c index 8edfb92..65c8ef9 100644 --- a/tests/golden/generics/expected.c +++ b/tests/golden/generics/expected.c @@ -132,6 +132,7 @@ extern const char* bux_str_join2(const char* a, const char* b, const char* sep); extern const char* bux_float_to_string(double f); extern const char* bux_str_format(const char* pattern, const char* a0, const char* a1, const char* a2, const char* a3, const char* a4, const char* a5, const char* a6, const char* a7); extern double bux_str_to_float(const char* s); +extern void bux_bounds_check(unsigned int index, unsigned int len); extern void bux_sha1(const char* data, int len, void* out); extern void bux_sha256(const char* data, int len, void* out); extern void bux_sha384(const char* data, int len, void* out); diff --git a/tests/golden/hello/expected.c b/tests/golden/hello/expected.c index 85cb449..c7f718a 100644 --- a/tests/golden/hello/expected.c +++ b/tests/golden/hello/expected.c @@ -132,6 +132,7 @@ extern const char* bux_str_join2(const char* a, const char* b, const char* sep); extern const char* bux_float_to_string(double f); extern const char* bux_str_format(const char* pattern, const char* a0, const char* a1, const char* a2, const char* a3, const char* a4, const char* a5, const char* a6, const char* a7); extern double bux_str_to_float(const char* s); +extern void bux_bounds_check(unsigned int index, unsigned int len); extern void bux_sha1(const char* data, int len, void* out); extern void bux_sha256(const char* data, int len, void* out); extern void bux_sha384(const char* data, int len, void* out); diff --git a/tests/golden/methods/expected.c b/tests/golden/methods/expected.c index 0195497..65652d5 100644 --- a/tests/golden/methods/expected.c +++ b/tests/golden/methods/expected.c @@ -133,6 +133,7 @@ extern const char* bux_str_join2(const char* a, const char* b, const char* sep); extern const char* bux_float_to_string(double f); extern const char* bux_str_format(const char* pattern, const char* a0, const char* a1, const char* a2, const char* a3, const char* a4, const char* a5, const char* a6, const char* a7); extern double bux_str_to_float(const char* s); +extern void bux_bounds_check(unsigned int index, unsigned int len); extern void bux_sha1(const char* data, int len, void* out); extern void bux_sha256(const char* data, int len, void* out); extern void bux_sha384(const char* data, int len, void* out); diff --git a/tests/golden/strings/expected.c b/tests/golden/strings/expected.c index 0ce48fb..bc01ec9 100644 --- a/tests/golden/strings/expected.c +++ b/tests/golden/strings/expected.c @@ -132,6 +132,7 @@ extern const char* bux_str_join2(const char* a, const char* b, const char* sep); extern const char* bux_float_to_string(double f); extern const char* bux_str_format(const char* pattern, const char* a0, const char* a1, const char* a2, const char* a3, const char* a4, const char* a5, const char* a6, const char* a7); extern double bux_str_to_float(const char* s); +extern void bux_bounds_check(unsigned int index, unsigned int len); extern void bux_sha1(const char* data, int len, void* out); extern void bux_sha256(const char* data, int len, void* out); extern void bux_sha384(const char* data, int len, void* out); diff --git a/tests/golden/structs/expected.c b/tests/golden/structs/expected.c index f6321c1..147e66b 100644 --- a/tests/golden/structs/expected.c +++ b/tests/golden/structs/expected.c @@ -133,6 +133,7 @@ extern const char* bux_str_join2(const char* a, const char* b, const char* sep); extern const char* bux_float_to_string(double f); extern const char* bux_str_format(const char* pattern, const char* a0, const char* a1, const char* a2, const char* a3, const char* a4, const char* a5, const char* a6, const char* a7); extern double bux_str_to_float(const char* s); +extern void bux_bounds_check(unsigned int index, unsigned int len); extern void bux_sha1(const char* data, int len, void* out); extern void bux_sha256(const char* data, int len, void* out); extern void bux_sha384(const char* data, int len, void* out);