feat: generic enums, fix is-operator, Type_Eq, hardcoded limit diagnostics
ci / build (ubuntu) (push) Has been cancelled
ci / unit + fmt (push) Has been cancelled
ci / examples (push) Has been cancelled
ci / goldens + tools (push) Has been cancelled
ci / apps (push) Has been cancelled
ci / selfhost smoke (push) Has been cancelled
ci / macos smoke (push) Has been cancelled
ci / windows smoke (push) Has been cancelled
ci / CI gate (push) Has been cancelled
selfhost-loop / bootstrap determinism (push) Has been cancelled

- feat: generic enum support (parser, lowering, codegen — both selfhost + bootstrap)
  - enum Result<T,E> { Ok(T), Err(E) } parsing + monomorphization
  - tag constant mangling in monomorphized function bodies
  - data field access (l-value + r-value) for generated enum instances
  - multiple concrete instances in same file
  - HIR walker for enum reference mangling (selfhost + bootstrap)

- feat: stdlib Result<T,E> and Option<T> made truly generic
  - breaking: explicit type args required (Result<int, String>)

- fix: 'is' operator — lowering to hBinary tag comparison + C backend fallback
- fix: Type_Eq structural comparison (inner types for pointer/slice/tuple)
- fix: hardcoded limit diagnostics (>8 params/variants/captures now emit errors)
- docs: Iter<T> safety warning for dangling pointer
- docs: IMPROVEMENTS.md — comprehensive plan and changelog
- test: generic_enum example added to EXAMPLES

All tests pass (0 FAIL). Selfhost loop deterministic.
This commit is contained in:
2026-07-28 01:54:15 +03:00
parent fa1521a71e
commit d517c62380
15 changed files with 714 additions and 96 deletions
+40
View File
@@ -0,0 +1,40 @@
// generic_enum.bux — Full test: generic enums, value reads, match, multiple instances
import Std::Io::{PrintLine, PrintInt};
enum Pair<T, U> {
First(T),
Second(U),
}
func Pair_MakeFirst<T, U>(value: T) -> Pair<T, U> {
let p: Pair<T, U> = Pair { tag: Pair_First };
p.data.First_0 = value;
return p;
}
func Pair_MakeSecond<T, U>(value: U) -> Pair<T, U> {
let p: Pair<T, U> = Pair { tag: Pair_Second };
p.data.Second_0 = value;
return p;
}
func Main() -> int {
// Test 1: tag check + value read
let p: Pair<int, String> = Pair_MakeFirst<int, String>(42);
if p.tag == Pair_First {
Print("First value: ");
PrintInt(p.data.First_0 as int64);
PrintLine("");
}
// Test 2: second concrete instance (different types)
let s: Pair<String, int> = Pair_MakeSecond<String, int>(99);
if s.tag == Pair_Second {
Print("Second value: ");
PrintInt(s.data.Second_0 as int64);
PrintLine("");
}
return 0;
}