Skip to content

Commit d4cc8a2

Browse files
committed
fix some little bug
1 parent 5cf2741 commit d4cc8a2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

contextcheck.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ func (r *runner) run(pass *analysis.Pass) {
136136
}
137137

138138
if entryType := r.checkIsEntry(f); entryType == EntryNormal {
139+
if _, ok := r.getValue(key, f); ok {
140+
continue
141+
}
139142
// record the result of nomal function
140143
checkingMap := make(map[string]bool)
141144
checkingMap[key] = true
@@ -587,7 +590,10 @@ func (r *runner) checkFuncWithoutCtx(f *ssa.Function, checkingMap map[string]boo
587590
checkingMap[key] = true
588591

589592
valid := r.checkFuncWithoutCtx(ff, checkingMap)
590-
r.setFact(orgKey, valid, ff.Name())
593+
r.setFact(key, valid, ff.Name())
594+
if res, ok := r.getValue(key, ff); ok {
595+
r.setFact(orgKey, valid, res.Funcs...)
596+
}
591597
if !valid {
592598
ret = false
593599
}
@@ -732,9 +738,13 @@ func (r *runner) getValue(key string, f *ssa.Function) (res resInfo, ok bool) {
732738
}
733739

734740
func (r *runner) setFact(key string, valid bool, funcs ...string) {
741+
var names []string
742+
if !valid {
743+
names = append(r.currentFact[key].Funcs, funcs...)
744+
}
735745
r.currentFact[key] = resInfo{
736746
Valid: valid,
737-
Funcs: append(r.currentFact[key].Funcs, funcs...),
747+
Funcs: names,
738748
}
739749
}
740750

0 commit comments

Comments
 (0)