Skip to content

with analyze audit:resolution says ok over a call whose MIR argument count differs from Sema's resolution (the #3335 program) #3343

Closed

Description

@ehartford

A tool that stayed silent while the bug existed (#3335, fixed in #3342).

On the compiler before #3342 (main cc82e4d):

trait P:
    fn a(x: &str) -> Option[Self]
    fn must(x: &str) -> Self:
        let got = Self.a(x)
        got.unwrap()
impl P for i32:
    fn a(x: &str) -> Option[i32]: if x == "1": Some(1) else: None

fn main:
    print(i32.must("1"))

with build emits call @i32.P.a(%str zeroinitializer, %str …), two arguments to a one-parameter function, and LLVM refuses it. with analyze dl.w audit:resolution on the same program ends resolution-audit: facts=… violations=0 ok.

Sema's fact is right (select:kind=call,name~P.a shows resolved-call sig=… args=1). The default method's body does not appear in --dump-mir or in the MIR facts (select:stage=mir,name~must lists only the call of must from main), so the audit never compares that body's calls with Sema's.

Expected: the audit covers the bodies of default trait methods instantiated for an impl (they are lowered and emitted, so they have MIR), and --dump-mir prints them; an uninstrumented body is an audit failure, not a blind spot.

To reproduce today: check out cc82e4d, or revert the three static_receiver_calls reads in MirLower.lower_method_call.

Activity

  1. ehartford commented on Nov 15, 2026

    @ehartford
    ContributorAuthor

    Exact place: Codegen.generate_default_trait_method_for_impl (src/CodegenTraits.w, "MIR-based default trait method body compilation") creates a MirBuilder and lowers the default body itself, during code generation. That body is never a member of the MIR module, so --dump-mir, --validate-all, the drop and ownership validators and every with analyze audit never see it: the resolution audit could not have compared the call in #3335's program, and nothing validates a default method's drops either.

    Fix: default method bodies instantiated for an impl are lowered in the MIR phase with every other body (the impl's own copy of the body, AstPool.impl_default_body, under the impl method's signature) and codegen emits them from the module like any function. Then the audit's "an uninstrumented body is a failure" covers them with no special case. D65: codegen decides how; it does not lower.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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