compiler: Require successful resolution before ownership checks

380a8376e811101ad4b5c9761ff23de2a0f11a64c217e2eca1dbd52876060eed
Run linear ownership analysis only after resolution completes without diagnostics.
Ownership checking depends on resolved types and call metadata. This keeps an
invalid program on its primary diagnostic path instead of reporting failures
from incomplete semantic data.
Alexis Sellier committed ago 1 parent 59f09239
lib/std/lang/resolver.rad +4 -1
3585 3585
    let retTy = *fnType.returnType;
3586 3586
    let bodyTy = try checkAssignable(self, body, Type::Void);
3587 3587
    if retTy <> Type::Void and bodyTy <> Type::Never {
3588 3588
        return true;
3589 3589
    }
3590 -
    try checkLinearFn(self, receiverName, params, body);
3590 +
    // Ownership checks require complete type and call metadata.
3591 +
    if self.errors.len == 0 {
3592 +
        try checkLinearFn(self, receiverName, params, body);
3593 +
    }
3591 3594
    return false;
3592 3595
}
3593 3596
3594 3597
/// Analyze a function parameter and bind its identifier.
3595 3598
unsafe fn resolveFnParam(self: &mut Resolver, node: *ast::Node, param: ast::FnParam) -> Type