Skip to content

Commit d4f7242

Browse files
authored
Merge pull request #10 from Warashi/feature/fail-case
fix: 一旦変数に入るケースをカバー
2 parents beda4d2 + c4dd100 commit d4f7242

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

testdata/src/a/define.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
type a struct {
88
ct ct
9-
ict interface{ Err(context.Context) error }
9+
ict ict
1010
}
1111

1212
func g() error {
@@ -51,5 +51,6 @@ func (r) r(context.Context) []*ct {
5151

5252
type ict interface {
5353
Err(context.Context) error
54+
Result() (struct{}, error)
5455
}
5556
type mmu []ict

testdata/src/a/struct-field.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,11 @@ func (a *a) A(ctx context.Context) {
7575
if err := a.ict.Err(ctx); err != nil {
7676
_ = fmt.Errorf("a.ict.Err: %w", err)
7777
}
78+
_, err := a.ict.Result()
79+
if err != nil {
80+
_ = fmt.Errorf("hoge: %w", err) // want `the error-wrapping message should be "a\.ict\.Result: %w"`
81+
}
82+
if err != nil {
83+
_ = fmt.Errorf("a.ict.Result: %w", err)
84+
}
7885
}

testdata/src/a/struct-field.go.golden

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,11 @@ func (a *a) A(ctx context.Context) {
7575
if err := a.ict.Err(ctx); err != nil {
7676
_ = fmt.Errorf("a.ict.Err: %w", err)
7777
}
78+
_, err := a.ict.Result()
79+
if err != nil {
80+
_ = fmt.Errorf("a.ict.Result: %w", err) // want `the error-wrapping message should be "a\.ict\.Result: %w"`
81+
}
82+
if err != nil {
83+
_ = fmt.Errorf("a.ict.Result: %w", err)
84+
}
7885
}

walk.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ func (w *walker) walk(ctx context.Context, depth int, v poser) ([]string, bool)
6363
return w.walkOperands(ctx, depth+1, v)
6464
case *ssa.ChangeInterface:
6565
return w.walkOperands(ctx, depth+1, v)
66+
case *ssa.Extract:
67+
return w.walkOperands(ctx, depth+1, v)
6668
case *ssa.Call:
6769
return formatCall(ctx, v)
6870
}

0 commit comments

Comments
 (0)