Skip to content

Commit

Permalink
solver: FindRef should return ok=false if ref is invalid
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Chadwell <[email protected]>
  • Loading branch information
jedevc committed Apr 18, 2023
1 parent dd651bd commit d4090c6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions solver/result/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func (r *Result[T]) FindRef(key string) (T, bool) {
r.mu.Lock()
defer r.mu.Unlock()

var zero T

if r.Refs != nil {
if ref, ok := r.Refs[key]; ok {
return ref, true
Expand All @@ -70,10 +72,12 @@ func (r *Result[T]) FindRef(key string) (T, bool) {
return ref, true
}
}
var t T
return t, false
return zero, false
}
if r.Ref != zero {
return r.Ref, true
}
return r.Ref, true
return zero, false
}

func (r *Result[T]) EachRef(fn func(T) error) (err error) {
Expand Down

0 comments on commit d4090c6

Please sign in to comment.