Repository navigation
Reject a receiverless call to an instance method (#1201) - #1206
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1201.
Inside an impl,
fn new() -> Ptakesself.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:allalready 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: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.