Skip to content

Commit d442b7c

Browse files
committed
fix: don't report issue related to invalid position
1 parent 9dd73ac commit d442b7c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

contextcheck.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,21 @@ func (r *runner) collectCtxRef(f *ssa.Function, isHttpHandler bool) (refMap map[
455455
}
456456

457457
for instr := range storeInstrs {
458+
if !instr.Pos().IsValid() {
459+
continue
460+
}
461+
458462
if !checkedRefMap[instr.Val] {
459463
r.pass.Reportf(instr.Pos(), "Non-inherited new context, use function like `context.WithXXX` instead")
460464
ok = false
461465
}
462466
}
463467

464468
for instr := range phiInstrs {
469+
if !instr.Pos().IsValid() {
470+
continue
471+
}
472+
465473
for _, v := range instr.Edges {
466474
if !checkedRefMap[v] {
467475
r.pass.Reportf(instr.Pos(), "Non-inherited new context, use function like `context.WithXXX` instead")
@@ -551,6 +559,10 @@ func (r *runner) checkFuncWithCtx(f *ssa.Function, tp entryType) {
551559

552560
for _, b := range f.Blocks {
553561
for _, instr := range b.Instrs {
562+
if !instr.Pos().IsValid() {
563+
continue
564+
}
565+
554566
tp, ok := r.getCtxType(instr)
555567
if !ok {
556568
continue

0 commit comments

Comments
 (0)