Skip to content

Reject a receiverless call to an instance method (#1201) - #1206

Merged
ehartford merged 1 commit into
mainfrom
fix-1201-static-call-of-instance-method
Sep 19, 2026
Merged

ehartford merged 1 commit into
mainfrom
fix-1201-static-call-of-instance-method

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Fixes #1201.

Inside an impl, fn new() -> P takes self. P.new() resolved the method, paired zero arguments with one parameter, and reached codegen, where LLVM verification failed ("Incorrect number of arguments passed to called function"). with analyze audit:all already reported it (argument/signature mismatch args=0 params=1); only Sema accepted it.

The static-receiver path now checks the resolved signature's receiver mode. A method that takes self, called with too few arguments for the receiver to be among them:

'P.new' takes self, and this call has no receiver; call it on a value, or declare it outside the impl as fn P.new(...) to make it a function of the type

Type.method(value, ...) with the receiver passed explicitly is untouched.

Test: err_static_call_of_instance_method.w.

Battery: queued behind #1196's on the same machine; not run yet. I will update this line.

…receiver

Inside an impl, `fn new() -> P` takes `self`. `P.new()` resolved the method,
paired zero arguments with one parameter, and reached codegen, where LLVM
verification failed ("Incorrect number of arguments passed to called
function"). `with analyze audit:all` already reported it (argument/signature
mismatch args=0 params=1); Sema did not.

The static-receiver path now checks the resolved signature's receiver mode:
a method that takes `self`, called with too few arguments for the receiver
to be among them, is an error that names the method and the two ways out.
`Type.method(value, ...)` with the receiver passed explicitly is untouched.

Fixes #1201
@ehartford
ehartford merged commit 49b4369 into main Sep 19, 2026
5 checks passed
@ehartford
ehartford deleted the fix-1201-static-call-of-instance-method branch September 24, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling an instance method as Type.method() passes Sema and fails in the LLVM verifier

1 participant