You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Closures of a second function init() or _() happens to merge with the closures of the first #75
Describe the bug
I found this in #55. When a file has two or more init() functions (or _() anon functions) in the same file that never binds to a name, they get signatures <pkg>.init.2 because of uniqueFunctionSignature method. But the symbol table add this suffix only after it calls buildCallable first. As a result, the closures of init.2 keep the the signatures of <pkg>.init.closure_N (i.e., the same as that of the first init init).
The closure's ids are different. They get …/init/closure_1 and …/init:2/closure_1, because the id comes from the parent id. Everything downstream that is keyed on the signature merges: the L3 unit, the L2 call-graph edge and the signature index.
init:2/closure_1 has the cfg of the first closure. Its body has a node at line 6, which is outside its span (line 11).
Both closures have a duplicate 6:16→@exit edge.
The edge from init/closure_1 to fmt.Println is missing.
degraded is empty, so nothing tells the user.
Additional context
The location of the bug seems to be internal/syntactic_analysis/symbol_table.go:273. The suffix is set after buildCallable, which calls buildInnerCallables(pkg, sig, …) with the plain signature (line 640).
The fix is to compute the unique signature before buildCallable and pass it in, so the closures get <pkg>.init:2.closure_N.
Activity
fix(symbol-table): give a repeated init or _ its suffix before its cl…