fix(golang): mark GlobalVar dependencies as IsInvoked when directly c…#190
Merged
Merged
Conversation
…alled
When a package-scope variable holds a function value (e.g. `var Foo = func() {...}`)
and is invoked from another function body via `Foo()`, the parser previously only
recorded `Foo` as a plain GlobalVar dependency. Extend the existing directCalls
matching in parseFunc to also stamp Extra[IsInvoked]=true on GlobalVars, mirroring
the behavior already in place for FunctionCalls and MethodCalls.
b3dcdd2 to
ed6a588
Compare
Duslia
approved these changes
May 12, 2026
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.
What type of PR is this?
fix
Check the PR title.
(Optional) Translate the PR title into Chinese.
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:
zh(optional):
在 golang parser 中,当一个包级变量持有函数值(如
var Foo = func() {...}),并在另一个函数体内通过Foo()直接调用时,abcoder 之前只会把Foo记为普通的GlobalVar依赖。函数/方法调用依赖已经通过directCalls匹配获得了Extra["IsInvoked"]=true标记,但同样的逻辑没有应用到GlobalVars上。下游消费者因此无法区分"引用一个全局变量"和"把全局变量作为可调用对象调用"。Example
Input source (
pkg/util.go):Before this PR — 两个函数的
GlobalVars条目完全一样,无法区分"引用"和"调用":After this PR — 直接调用点会带上
Extra: { "IsInvoked": true },纯引用点保持原样:(Optional) Which issue(s) this PR fixes:
(optional) The PR that updates user documentation: