Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle assignments to global variables from the init function #4

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

lizard-boy
Copy link
Collaborator

Original PR: uber-go/nilaway#253

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR adds new detection logic for assignments to global variables from init functions, enhancing how NilAway initializes and processes global variables.

  • In /assertion/global/analyzer.go, getInitFuncDecls now collects init functions with a visited set to avoid infinite recursion; duplicate entries may occur across init functions.
  • In /assertion/global/globalvarinit.go, analyzeValueSpec and getGlobalConsumers now accept init declarations, and hasGlobalVarAssignInInitFunc is added to detect global assignments.
  • Consider caching repeated calls to hasGlobalVarAssignInInitFunc to improve efficiency and ensure proper logging using logger.error for failures.

💡 (2/5) Greptile learns from your feedback when you react with 👍/👎!

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants