selfhost: auto-Drop for Array<T> in @[Checked] functions

In @[Checked] functions, variables of type Array<T> automatically get
a defer Array_Free_T(&var) injected at declaration site. This ensures
Array values are freed when they go out of scope, preventing leaks.

Implementation:
- HIR lowering detects Array_<T> types in skLet statements
- Generates Array_Free_T generic instance if needed
- Builds synthetic defer node: defer Array_Free_T(&var)
- Wraps let+defer in hBlock for proper statement chaining

Also adds checkedFunc flag to HirFunc and CEmitter for future use.
This commit is contained in:
2026-06-10 11:40:11 +03:00
parent 5eec4328f3
commit a099999e02
3 changed files with 47 additions and 0 deletions
+1
View File
@@ -114,6 +114,7 @@ struct HirFunc {
captureType7: int;
envStructName: String;
envInstanceName: String;
checkedFunc: bool;
}
// ---------------------------------------------------------------------------