zoekt
zoekt copied to clipboard
`case:` does not have any effect within nested expressions
Here are some input query strings and the results of parsing them. case:
seems to not have any effect on the parsed query unless it's in the top-level expression.
foo bar -> (and substr:"foo" substr:"bar")
foo bar case:yes -> (and case_substr:"foo" case_substr:"bar")
foo bar case:no -> (and substr:"foo" substr:"bar")
foo or bar -> (or substr:"foo" substr:"bar")
foo or bar case:yes -> (or case_substr:"foo" case_substr:"bar")
foo or bar case:no -> (or substr:"foo" substr:"bar")
# `case:` does nothing if not at the top level.
(foo case:yes) bar -> (and substr:"foo" substr:"bar")
(case:yes foo) bar -> (and substr:"foo" substr:"bar")
(case:yes foo (bar)) -> (and substr:"foo" substr:"bar")
case:
has special "application" logic (as it only modifies other expressions instead of doing anything on its own) and I suspect there is something wrong with it in that regard:
https://github.com/sourcegraph/zoekt/blob/2560773778893ff9f43ebb403ca97f85ffdae8d3/query/parse.go#L322-L339
I believe the problem is that the logic to identify caseQ
expressions in that for-loop only iterates over top-level expressions. It needs to iterate the entire tree of expressions, with lower caseQ
s overriding higher ones.
(By that reasoning it may be that Type
expressions have the same problem, but I don't really understand what those are supposed to do even normally 🌞.)