Skip to content

validate-all is silent on a direct call to an unresolvable CK_FN symbol with the source arguments dropped (#1635's MIR passed as ok) #1639

Closed

Description

@ehartford

Filed from the #1635 hunt (CLAUDE.md: a tool that stayed silent is a bug).

The MIR that #1635 produced for

fn go(c: &Corp) -> i32:
    let r = c.run
    r(21)

was

fn sym13355(go) {
  bb0: { StorageLive(_1); call const fn sym13356() -> [return: _2, next: bb1]; }

— a TK_CALL whose callee is a CK_FN const for symbol r, a symbol with no signature, no MIR body and no generic declaration, with the source call's ONE argument dropped (call_arg_counts == 0). with check --validate-all reported validate-all: ok; only codegen failed (FATAL: unhandled MirIntrinsic.GENERIC_CALL sym=r).

validate_typed_mir_body (src/MirCore.w) has mir_validate_indirect_call_arity for fn-typed callee operands, but a direct CK_FN callee is checked against nothing: not that the symbol has a signature or a body in the module, not that the argument count matches the source call (call_ast_node is recorded and the AST arity is known). The builtin branch in MirLower's NK_CALL dispatch ("Unresolved bare function — route through gen_call", the bu_ branch near src/MirLower.w:15106) is what emits these zero-argument calls for embed_file/src/etc., which is why a naive "every CK_FN callee has a signature" rule can't land without either (a) MirLower tagging that branch's calls with a distinct intrinsic/marker the validator can allow-list, or (b) the codegen builtin table being consultable from the validator.

Ask: make --validate-all (and analyze audit:mir) reject a TK_CALL to a CK_FN symbol that the module cannot resolve (no sig, no body, no generic node, not a tagged builtin), and reject a direct call whose call_arg_counts is smaller than the recorded call AST node's argument count when the callee is not variadic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions