selfhost: fix extend-for method linked list + trait bounds check before indirect call return

- parser: extend-for only linked first 2 methods; now uses lastMethod pointer
- sema: trait bounds checking was after indirect-call early return (tyFunc path),
  so Max<Circle>(...) skipped bounds check when callee had tekFunc refType.
  Moved bounds check before both indirect/direct call returns.
- Negative test: Circle without Comparable impl now correctly errors.
- Selfhost loop: C output IDENTICAL.
This commit is contained in:
2026-06-10 09:02:22 +03:00
parent f63cbd1bf0
commit bb84693acb
2 changed files with 20 additions and 12 deletions
+9 -5
View File
@@ -1635,21 +1635,25 @@ func parserParseDecl(p: *Parser) -> *Decl {
}
discard parserExpect(p, tkLBrace, "expected '{'");
var methods: *Decl = null as *Decl;
var lastMethod: *Decl = null as *Decl;
while !parserCheck(p, tkRBrace) && parserPeek(p, 0) != tkEndOfFile {
if parserCheck(p, tkNewLine) { discard parserAdvance(p); continue; }
if parserCheck(p, tkFunc) {
let m: *Decl = parserParseFuncDecl(p, false, false, false);
// Store method in linked list
if d.methodCount == 0 {
d.childDecl1 = m;
} else if d.methodCount == 1 {
d.childDecl1.childDecl2 = m;
if methods == null as *Decl {
methods = m;
lastMethod = m;
} else {
lastMethod.childDecl2 = m;
lastMethod = m;
}
d.methodCount = d.methodCount + 1;
} else {
break;
}
}
d.childDecl1 = methods;
discard parserExpect(p, tkRBrace, "expected '}'");
return d;
}