Skip to content

Commit

Permalink
fixed name collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidanio committed Jul 27, 2024
1 parent 4e98b63 commit ba8e1ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/linter/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,10 +841,10 @@ func (b *blockWalker) handleTry(s *ir.TryStmt) bool {
})
}

for nm, types := range varTypes {
for nm, typs := range varTypes {
var flags meta.VarFlags
flags.SetAlwaysDefined(defCounts[nm] == linksCount)
b.ctx.sc.AddVarName(nm, types, "all branches try catch", flags)
b.ctx.sc.AddVarName(nm, typs, "all branches try catch", flags)
}

if finallyCtx != nil {
Expand Down Expand Up @@ -1927,10 +1927,10 @@ func (b *blockWalker) handleSwitch(s *ir.SwitchStmt) bool {
})
}

for nm, types := range varTypes {
for nm, typs := range varTypes {
var flags meta.VarFlags
flags.SetAlwaysDefined(defCounts[nm] == linksCount)
b.ctx.sc.AddVarName(nm, types, "all cases", flags)
b.ctx.sc.AddVarName(nm, typs, "all cases", flags)
}

return false
Expand Down
18 changes: 9 additions & 9 deletions src/linter/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -1194,8 +1194,8 @@ func DiffReports(gitRepo string, diffArgs []string, changesList []git.Change, ch
}
}

old := reportListToMap(oldList)
new := reportListToMap(newList)
oldReportMap := reportListToMap(oldList)
newReportMap := reportListToMap(newList)
changes := gitChangesToMap(changesList)

var mu sync.Mutex
Expand All @@ -1205,7 +1205,7 @@ func DiffReports(gitRepo string, diffArgs []string, changesList []git.Change, ch

limitCh := make(chan struct{}, maxConcurrency)

for filename, list := range new {
for filename, list := range newReportMap {
wg.Add(1)
go func(filename string, list []*Report) {
limitCh <- struct{}{}
Expand All @@ -1221,7 +1221,7 @@ func DiffReports(gitRepo string, diffArgs []string, changesList []git.Change, ch
oldName = filename // full diff mode
}

reports, err := diffReportsList(gitRepo, ignoreCommits, diffArgs, filename, c, old[oldName], list)
reports, err := diffReportsList(gitRepo, ignoreCommits, diffArgs, filename, c, oldReportMap[oldName], list)
if err != nil {
mu.Lock()
resErr = err
Expand Down Expand Up @@ -1275,8 +1275,8 @@ func diffReportsList(gitRepo string, ignoreCommits map[string]struct{}, diffArgs
}
}

old, oldMaxLine := reportListToPerLineMap(oldList)
new, newMaxLine := reportListToPerLineMap(newList)
oldReportMap, oldMaxLine := reportListToPerLineMap(oldList)
newReportMap, newMaxLine := reportListToPerLineMap(newList)

var maxLine = oldMaxLine
if newMaxLine > maxLine {
Expand All @@ -1293,17 +1293,17 @@ func diffReportsList(gitRepo string, ignoreCommits map[string]struct{}, diffArgs
// just deletion
if ok && ch.new.HaveRange && ch.new.Range == 0 {
oldLine = ch.old.To
newLine-- // cancel the increment of newLine, because code was deleted, no new lines added
newLine-- // cancel the increment of newLine, because code was deleted, no newReportMap lines added
continue
}

res = maybeAppendReports(res, new, old, newLine, oldLine, blame, ignoreCommits)
res = maybeAppendReports(res, newReportMap, oldReportMap, newLine, oldLine, blame, ignoreCommits)

if ok {
oldLine = 0 // all changes and additions must be checked
for j := newLine + 1; j <= ch.new.To; j++ {
newLine = j
res = maybeAppendReports(res, new, old, newLine, oldLine, blame, ignoreCommits)
res = maybeAppendReports(res, newReportMap, oldReportMap, newLine, oldLine, blame, ignoreCommits)
}
oldLine = ch.old.To
}
Expand Down

0 comments on commit ba8e1ad

Please sign in to comment.