fix(selfhost): collection-based for-in with Std::Array + monomorphization fixes
- Fix Fmt_Format name conflict between lib/Fmt.bux and src/fmt.bux by renaming selfhost formatter function to Fmt_FormatSource. - Fix collection-based for-in loops to handle already-monomorphized types like Array_int and Iter_string (typeArgCount=0 cases). - Fix ekSizeOf and ekCast in HIR lowering to apply Lcx_SubstituteType during generic monomorphization, so sizeof(T) and *T casts emit correct concrete types in C output. - Fix sema to infer stmt.refStmtType from initializer expression when no explicit type annotation is given, ensuring C backend emits correct pointer types for let data = ... as *T.
This commit is contained in:
@@ -756,6 +756,15 @@ func Sema_CheckStmt(sema: *Sema, stmt: *Stmt) {
|
||||
} else {
|
||||
sym.typeName = stmt.refStmtType.typeName;
|
||||
}
|
||||
} else if stmt.child1 != null as *Expr && stmt.child1.refType != null as *TypeExpr {
|
||||
// Infer type from initializer expression
|
||||
sym.refType = stmt.child1.refType;
|
||||
stmt.refStmtType = stmt.child1.refType;
|
||||
if stmt.child1.refType.kind == tekPointer && stmt.child1.refType.pointerPointee != null as *TypeExpr {
|
||||
sym.typeName = String_Concat(stmt.child1.refType.pointerPointee.typeName, "*");
|
||||
} else {
|
||||
sym.typeName = stmt.child1.refType.typeName;
|
||||
}
|
||||
}
|
||||
sym.isMutable = stmt.boolValue;
|
||||
sym.isPublic = false;
|
||||
|
||||
Reference in New Issue
Block a user