Repository navigation
fix(join): declaration-of matches methods and function-local declarations - #971
Open
vignesh2027 wants to merge 1 commit into
Open
vignesh2027 wants to merge 1 commit into
vignesh2027 wants to merge 1 commit into
Conversation
…ions The declaration-of join point is documented to match top-level declarations, but it matched two other kinds of node. A FuncDecl was matched on its name alone, so a method called Foo satisfied declaration-of pkg.Foo even though it does not declare anything in the package scope. A ValueSpec was accepted whenever its parent was a GenDecl. A GenDecl also wraps the var and const declarations inside a function body, so a local variable that happened to share the name was matched too. Skip methods, and require the GenDecl of a ValueSpec to sit directly in the file.
This branch has not been deployed
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.
Why
The
declaration-ofjoin point is documented as matching top-level declarations, but it also matches two kinds of node that are not package-scope declarations.A
FuncDeclwas matched on its name alone, so a method calledFoosatisfieddeclaration-of: pkg.Foo. AValueSpecwas accepted whenever its parent was aGenDecl, and aGenDeclalso wraps thevarandconstdeclarations inside a function body. A local variable that shares the name was matched as well.What
Methods are skipped (
Recv != nil), and theGenDeclof aValueSpecmust have the*dst.Fileas its parent.TestDeclarationOfwalks a small package and checks which nodes each join point matches: top-level vars, consts and functions still match, while methods, locals in nested blocks and closures, and types do not. The method and local cases fail onmain.I looked for open issues and PRs about
declaration-ofand found none.