fix(selfhost): resolve segfault in buxc2 compiling src/

- Replace Decl's 256 inline struct fields with dynamic fields: *StructField
  array to avoid parser field limit truncation and name shifts.
- Update parser.bux and hir_lower.bux to use decl.fields[i].
- Fix uninitialized Symbol.refType in three stack-allocated Symbol sites:
  loopSym (for-loop iterator), vSym (enum variants), and HIR param sym.
  Garbage refType values (e.g. 0xFF) were leaking into scope tables,
  later copied to expr->refType, causing SIGSEGV in Lcx_LowerExpr.
This commit is contained in:
2026-06-09 15:03:45 +03:00
parent 0c41c7bb25
commit 4a860095fd
6 changed files with 66 additions and 1287 deletions
+4
View File
@@ -571,6 +571,7 @@ func Sema_CheckStmt(sema: *Sema, stmt: *Stmt) {
loopSym.name = stmt.strValue;
loopSym.typeKind = tyUnknown;
loopSym.typeName = "";
loopSym.refType = null as *TypeExpr;
loopSym.isMutable = true;
loopSym.isPublic = false;
loopSym.decl = null as *Decl;
@@ -678,6 +679,7 @@ func Sema_CollectGlobals(sema: *Sema) {
vSym.name = variantName2;
vSym.typeKind = tyNamed;
vSym.typeName = String_Concat(decl.strValue, "_Tag");
vSym.refType = null as *TypeExpr;
vSym.isMutable = false;
vSym.isPublic = decl.isPublic;
vSym.decl = decl;
@@ -734,6 +736,7 @@ func Sema_CollectGlobals(sema: *Sema) {
sym.name = name;
sym.typeKind = tyUnknown;
sym.typeName = "";
sym.refType = null as *TypeExpr;
sym.isMutable = false;
sym.isPublic = true;
sym.decl = null as *Decl;
@@ -772,6 +775,7 @@ func Sema_CollectGlobals(sema: *Sema) {
sym.name = lastSeg;
sym.typeKind = tyUnknown;
sym.typeName = "";
sym.refType = null as *TypeExpr;
sym.isMutable = false;
sym.isPublic = true;
sym.decl = null as *Decl;