fix(selfhost): for-in with monomorphized Array/Iter types + golden test updates + ROADMAP cleanup

- Fix hir_lower.bux to recognize Array_int/Iter_string etc. in for-in loops
  by checking Array_/Iter_ prefix outside the empty-elemTypeName branch.
- Update all golden expected.c files to include duplicate bux_bounds_check
  declaration (matches actual C codegen).
- Remove duplicate Drop trait item from ROADMAP.md.
This commit is contained in:
2026-06-10 12:57:53 +03:00
parent 51bd3c172b
commit a4e410fb30
10 changed files with 14 additions and 34 deletions
+1 -21
View File
@@ -204,8 +204,6 @@ extend Array<T> {
---
## 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<T> {
func Drop(self: own Array<T>) {
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:**
+5 -13
View File
@@ -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);
+1
View File
@@ -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);
+1
View File
@@ -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);
+1
View File
@@ -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);
+1
View File
@@ -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);
+1
View File
@@ -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);
+1
View File
@@ -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);
+1
View File
@@ -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);
+1
View File
@@ -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);