Skip to content

Codegen: a static Type.fn (no self) called through an instance, b.make(p), emits a call with the receiver as an extra argument (invalid LLVM function) #1617

Closed

Description

@ehartford

Found while probing null-argument contexts for the SQLite facade (D51 stage 12); pre-existing on the stage-9 stage1 (same output with a typed local, so not the stage 12 null change).

type B2 { n: i32 }
fn B2.make(p: *mut *mut i8) -> B2: B2 { n: if p == null: 7 else: 0 }
fn main:
    let b = B2 { n: 1 }
    let q: *mut *mut i8 = null
    let a = b.make(q).n       // B2.make(q) is fine
    print(f"{a}")
Incorrect number of arguments passed to called function!
  %4 = call %B2 @B2.make(ptr %3, ptr null)
===== INVALID LLVM FUNCTION main =====
error: code generation failed

Sema accepts b.make(q) (a static fn reached through a value) and MirLower/codegen pass the receiver as a first argument the callee does not take. Either Sema rejects the spelling (a static fn has no receiver; B2.make(q) is the call) or lowering drops the receiver — the spec should decide which; today it is a silent codegen failure, which is neither.

Activity

  1. ehartford commented on Sep 26, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by #1702 (55739d4); battery green, pinned by the behavior tests named in the PR.

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