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

fix: unconditional-recursion false positive when the function is called right after its declaration (#1212) #1214

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

chavacava
Copy link
Collaborator

@chavacava chavacava commented Jan 29, 2025

The root cause of the bug was that the analyzer (AST walker) was not reinitialized at the end of function bodies. Thus, if the function was called outside the body (like in the example below) the analyzer raised a failure.

func foo() int {
	return 0
}

var f = foo()

The fix is: iterate over global declarations of the file and create an analyzer for each function declaration (instead of create a single analyzer for the whole file) Like that, each analyzer is scoped within a single function body.

Closes #1212

@chavacava chavacava merged commit 4bd6fba into master Jan 29, 2025
10 checks passed
@chavacava chavacava deleted the fix/1212 branch February 4, 2025 11:06
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.

unconditional-recursive warn where no any reasone
3 participants