selfhost: for x in collection works with non-identifier expressions + buxc2 build merges stdlib

- cli: buxc2 build now delegates to Cli_BuildProject for src/Main.bux,
  enabling stdlib merging (Array_Iter, Iter_HasNext, etc. available)
- sema: set expr.refType on ekCall from function return type
  (needed for for-loop type extraction from MakeArr()-style expressions)
- hir_lower: remove ekIdent restriction on collection-based for loops
  - supports arbitrary expressions: for x in MakeArr() { ... }
  - creates temp variable __tmp_coll_N for non-identifier iterators
  - generates proper Array_T struct instances for temp variables
- Test: for x in MakeArr() sums [10,20,30] → 60
- Selfhost loop: C output IDENTICAL
This commit is contained in:
2026-06-10 10:20:16 +03:00
parent bb84693acb
commit 01677001c3
3 changed files with 63 additions and 11 deletions
+2
View File
@@ -579,6 +579,7 @@ func Sema_CheckExpr(sema: *Sema, expr: *Expr) -> int {
if calleeType == tyFunc {
if expr.child1.refType != null as *TypeExpr && expr.child1.refType.kind == tekFunc {
if expr.child1.refType.funcRet != null as *TypeExpr {
expr.refType = expr.child1.refType.funcRet;
return Sema_ResolveType(sema, expr.child1.refType.funcRet);
}
return tyVoid;
@@ -589,6 +590,7 @@ func Sema_CheckExpr(sema: *Sema, expr: *Expr) -> int {
let sym: Symbol = Scope_Lookup(sema.scope, expr.child1.strValue);
if sym.kind == skFunc && sym.decl != null as *Decl {
if sym.decl.retType != null as *TypeExpr {
expr.refType = sym.decl.retType;
return Sema_ResolveType(sema, sym.decl.retType);
}
}