Skip to content

search: hoist or-expressions heuristic

Administrator requested to merge rvt/hoist-or-heuristic into master

Created by: rvantonder

This PR introduces a transformer to convert ambiguous queries like

repo:foo a or b to repo:foo (a or b) instead of the grammar spec (repo:foo a) or b. You may be familiar with the related slack thread.

In addition to arguments that this feels more natural to some (perhaps majority), what's far more important is the human view of visual consistency that this imposes (as opposed to grammatical consistency). Here's why: we will currently parse

repo:foo a and b as (repo:foo a) and b

but because we treat whitespace between certain expressions implicitly as and, the interpretation here is rather:

repo:foo a and b == repo:foo and a and b == (repo:foo a) and b == repo:foo (a and b), so there is no ambiguity (rather, it is the case that syntactically (repo:foo a) and b is kind of bogus, but we don't enforce that yet and just overlook it). Hence, as a user, you may experience:

repo:foo a and b => "hey this works" repo:foo a or b => "?? why do I get an error?"

So, the above or-expression will be rewritten in simple cases, see comment description of heuristic.

This PR does not apply the heuristic anywhere. The decision to apply it rests in other logic, that comes in follow up PR: #9761

Merge request reports

Loading