Skip to content

Commit

Permalink
Bugfix: avoid spurious tautology pruning when dealing with certain re…
Browse files Browse the repository at this point in the history
…cursive messages (#142)
  • Loading branch information
rodaine authored Aug 29, 2024
1 parent 91e202b commit fc11a84
Show file tree
Hide file tree
Showing 5 changed files with 480 additions and 41 deletions.
2 changes: 1 addition & 1 deletion internal/evaluator/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (bldr *Builder) load(desc protoreflect.MessageDescriptor) MessageEvaluator
}

// loadOrBuild either returns a memoized MessageEvaluator for the given
// descriptor, or lazily constructs a new one. This method is thread-safe via
// descriptor or lazily constructs a new one. This method is thread-safe via
// locking.
func (bldr *Builder) loadOrBuild(desc protoreflect.MessageDescriptor) MessageEvaluator {
if eval, ok := (*bldr.cache.Load())[desc]; ok {
Expand Down
7 changes: 6 additions & 1 deletion internal/evaluator/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ func (m *message) EvaluateMessage(msg protoreflect.Message, failFast bool) error
}

func (m *message) Tautology() bool {
return m.Err == nil && m.evaluators.Tautology()
// returning false for now to avoid recursive messages causing false positives
// on tautology detection.
//
// TODO: use a more sophisticated method to detect recursions so we can
// continue to detect tautologies on message evaluators.
return false
}

func (m *message) Append(eval MessageEvaluator) {
Expand Down
Loading

0 comments on commit fc11a84

Please sign in to comment.