Fix generic struct monomorphization and C output for imports

- Fix nested Lcx_GenerateStructInstance overwriting parent slot by
  incrementing structCount BEFORE field processing
- Fix Lcx_LowerModule to skip generic structs from hm.structs (was missing
  continue due to bootstrap compiler codegen limitation)
- Fix C backend to forward-declare ALL structs at top, removing second
  generic-only forward declaration section that came too late
- Add empty-name guard in CBE_EmitStructDef
- Import system: parser supports ::* glob imports, sema two-pass resolution
This commit is contained in:
2026-06-09 23:33:44 +03:00
parent b36df0f5b7
commit 40bcbeb710
4 changed files with 154 additions and 165 deletions
+24 -17
View File
@@ -1434,25 +1434,32 @@ func parserParseImportDecl(p: *Parser, isPublic: bool) -> *Decl {
}
d.usePath = pathStr;
// Optional ::{name1, name2}
if parserMatch(p, tkColonColon) && parserCheck(p, tkLBrace) {
discard parserAdvance(p); // {
var names: String = "";
while !parserCheck(p, tkRBrace) && parserPeek(p, 0) != tkEndOfFile {
while parserCheck(p, tkNewLine) {
discard parserAdvance(p);
// Optional ::{name1, name2} or ::*
if parserMatch(p, tkColonColon) {
if parserCheck(p, tkLBrace) {
discard parserAdvance(p); // {
var names: String = "";
while !parserCheck(p, tkRBrace) && parserPeek(p, 0) != tkEndOfFile {
while parserCheck(p, tkNewLine) {
discard parserAdvance(p);
}
if parserCheck(p, tkRBrace) || parserPeek(p, 0) == tkEndOfFile {
break;
}
let n: LexToken = parserExpect(p, tkIdent, "expected import name");
names = String_Concat(names, n.text);
names = String_Concat(names, ",");
if !parserMatch(p, tkComma) { break; }
}
if parserCheck(p, tkRBrace) || parserPeek(p, 0) == tkEndOfFile {
break;
}
let n: LexToken = parserExpect(p, tkIdent, "expected import name");
names = String_Concat(names, n.text);
names = String_Concat(names, ",");
if !parserMatch(p, tkComma) { break; }
discard parserExpect(p, tkRBrace, "expected '}'");
d.useNames = names;
d.useKind = 2; // ukMulti
} else if parserCheck(p, tkStar) {
discard parserAdvance(p); // *
d.useKind = 1; // ukGlob
} else {
d.useKind = 0; // ukSingle
}
discard parserExpect(p, tkRBrace, "expected '}'");
d.useNames = names;
d.useKind = 2; // ukMulti
} else {
d.useKind = 0; // ukSingle
}