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:
+11
-7
@@ -565,6 +565,16 @@ func Sema_CheckExpr(sema: *Sema, expr: *Expr) -> int {
|
||||
ai = ai + 1;
|
||||
}
|
||||
}
|
||||
// Trait bounds checking for explicit generic calls: Max<Circle>(...)
|
||||
// Must happen before indirect/direct call returns
|
||||
if expr.child1.kind == ekIdent {
|
||||
let sym: Symbol = Scope_Lookup(sema.scope, expr.child1.strValue);
|
||||
if sym.kind == skFunc && sym.decl != null as *Decl {
|
||||
if expr.child1.genericTypeArgCount > 0 {
|
||||
Sema_CheckTraitBounds(sema, sym.decl, expr.child1.genericTypeArg0, expr.child1.genericTypeArg1, expr.child1.genericTypeArgCount, expr.line, expr.column);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Indirect call through function-typed value
|
||||
if calleeType == tyFunc {
|
||||
if expr.child1.refType != null as *TypeExpr && expr.child1.refType.kind == tekFunc {
|
||||
@@ -577,17 +587,11 @@ func Sema_CheckExpr(sema: *Sema, expr: *Expr) -> int {
|
||||
// Direct call to named function
|
||||
if expr.child1.kind == ekIdent {
|
||||
let sym: Symbol = Scope_Lookup(sema.scope, expr.child1.strValue);
|
||||
if sym.kind == skFunc {
|
||||
if sym.decl != null as *Decl {
|
||||
// Trait bounds checking for explicit generic calls: Max<Circle>(...)
|
||||
if expr.child1.genericTypeArgCount > 0 {
|
||||
Sema_CheckTraitBounds(sema, sym.decl, expr.child1.genericTypeArg0, expr.child1.genericTypeArg1, expr.child1.genericTypeArgCount, expr.line, expr.column);
|
||||
}
|
||||
if sym.kind == skFunc && sym.decl != null as *Decl {
|
||||
if sym.decl.retType != null as *TypeExpr {
|
||||
return Sema_ResolveType(sema, sym.decl.retType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tyUnknown;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user