Skip to content

with check accepts method calls with the wrong argument count; fails late at LLVM verification #1973

Closed

Description

@ehartford

with check accepts a method call with the wrong number of arguments. The program fails only at LLVM verification when it is built, or not at all under the comptime evaluator. A free-function call is checked correctly.

Spec: §3.8 (parameters), §20 (diagnostics). A call that does not match its callee's parameter list is a type error.

Minimal repro (main 9307016, stage1; the pinned seed behaves the same):

type Ev { n: i32 }
impl Ev:
    mut fn make(a: i32, b: i64) -> i32: a + b as i32
    mut fn run() -> i32: self.make(3)
fn main:
    var e = Ev { n: 0 }
    print(e.run())
  • with check repro.w prints ok, rc 0.
  • with run repro.w fails with Incorrect number of arguments passed to called function! %1 = call i32 @Ev.make(ptr %0, i32 3) ===== INVALID LLVM FUNCTION Ev.run =====.

Matrix (all print ok from check):

call callee
self.make(3) mut fn make(a, b)
self.peek(3) fn peek(a, b)
e.make(3) mut fn make(a, b)
e.peek(3) fn peek(a, b)
e.make(3, 4, 5) too many arguments, same result

The free-function control, fn make(a: i32, b: i64) called as make(3), is rejected: error: function 'make' expects 2 argument(s), found 1.

Found during #1944. Changing an evaluator helper's signature left seven stale one-argument call sites. with check src/main.w passed; the :dev stage1 compile then died in the LLVM verifier for ComptimeEvaluator.eval_fn_symbol_call_values_with_resolved_type_args. Per D65, Sema owns acceptance. Today the wrong-arity call reaches MIR and codegen. audit:resolution should also have flagged the argument-count disagreement.

Expected: Sema rejects a method call whose argument count (receiver excluded, defaults applied) does not match the declaration, with the same diagnostic shape as the free-function case.

Workaround: none needed. The #1944 call sites were fixed by hand.

Activity

  1. ehartford commented on Oct 3, 2026

    @ehartford
    ContributorAuthor

    Another row of the same class, found while working #1457 (main 9307016, installed compiler): a static dotted function called through a value.

    pub type Item { x: i64 }
    pub fn Item.tag() -> str: "a"
    fn main:
        let i = Item { x: 1 }
        print(i.tag())
    

    with run: Incorrect number of arguments passed to called function! %1 = call %str @Item.tag(%Item ...) ===== INVALID LLVM FUNCTION main =====. Item.tag() runs and prints a. with analyze ... audit:all reports it as resolution: MIR passes 1 argument(s) to Item.tag, Sema's signature takes 0 (D65; #1639's silent case), so audit:resolution sees it and Sema accepts it.

  2. ehartford commented on Oct 3, 2026

    @ehartford
    ContributorAuthor

    Fixed on main in c884c1c (stack #2001 → #2010, seed-driven battery GREEN on b932ef6, tree identical to main). Fixture coverage is in the stack's commits.

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