Repository navigation
Conversation
When a method expression such as (*S).F(nil, context.Background()) is called, call.Args[0] is the method receiver and call.Args[1] corresponds to sig.Params().At(0). Inspect call.Args[1] when call.Fun resolves to a types.MethodExpr selection so nil receivers are not falsely flagged as nil contexts and nil contexts passed after the receiver are reported. Closes dominikh#1719
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.
When a method expression such as
(*S).F(nil, context.Background())is called,call.Args[0]is the method receiver andcall.Args[1]corresponds tosig.Params().At(0).SA1012previously inspectedcall.Args[0]unconditionally wheneversig.Params().Len() > 0, falsely flagging anilreceiver when the method's first parameter had typecontext.Contextand missing anilcontext passed ascall.Args[1].Detect
types.MethodExprselections oncall.Funand inspectcall.Args[1](with a matching pattern branch fornilin the second argument position) while continuing to inspectcall.Args[0]for ordinary function and bound method-value calls.Closes #1719