Skip to content

tool doesn't truely keep track of all scope stacks #3

@ctII

Description

@ctII

currently defermodafterreturn uses ast.Inspect, but doesn't really keep track of the stack of scopes a defer is in when running the analysis. this could lead to false positives where a defer 3 levels deep could potentially ignore variables 2 levels deep

package main

import "fmt"

func run() error {
        var err error
        defer func() {
                defer func() {
                        var err error
                        defer func() {
                                err = nil
                        }()
                        fmt.Println(err)
                }()
        }()
        return err
}
main.go:10:10 function literal in defer assigns to (err) a non-named return in parent function
defer func() {
        err = nil
}()

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions