feat: generic struct monomorphization + tkUnknown fix

- Add generic struct instantiation (Box<int>, Pair<T,U>) in HIR lowering
- Fix tkUnknown/tkNamed/tkTypeParam ambiguity in sema.nim (qualify with TypeKind)
- Add generics_struct example
- Update Makefile with new example
This commit is contained in:
2026-05-31 10:33:08 +03:00
parent 7ee6a73ea4
commit 9f733aca7d
9 changed files with 136 additions and 15 deletions
+25
View File
@@ -0,0 +1,25 @@
// Generic structs - Box<T> and Pair<T, U>
import Std::Io::{PrintLine, PrintInt};
struct Box<T> {
value: T,
}
struct Pair<T, U> {
first: T,
second: U,
}
func Main() -> int {
let b: Box<int> = Box<int> { value: 42 };
PrintLine("Box value:");
PrintInt(b.value);
PrintLine("");
let p: Pair<int, String> = Pair<int, String> { first: 10, second: "hello" };
PrintLine("Pair first:");
PrintInt(p.first);
PrintLine("");
return 0;
}