Skip to content

fix/query: preserve fields in parenthesized atoms#1078

Draft
keegancsmith wants to merge 1 commit into
mainfrom
k/fix-parenthesized-fields
Draft

fix/query: preserve fields in parenthesized atoms#1078
keegancsmith wants to merge 1 commit into
mainfrom
k/fix-parenthesized-fields

Conversation

@keegancsmith

Copy link
Copy Markdown
Member

This fixes a parser ambiguity where no-space parenthesized field atoms like (sym:foo) were treated as plain content text instead of as grouped field queries. The tokenizer now recognizes parenthesized atoms that begin with query field syntax as grouping, so field semantics are preserved for cases like (sym:foo), (file:README), and negated forms like -(file:test). Bare regex-style parenthesized text such as (foo) and (foo)(bar) remains on the existing path to avoid broad compatibility churn.\n\nThe query syntax and design docs now call out that parenthesized field expressions preserve their field semantics.\n\nFixes #1074.\n\n## Test Plan\n\ngo test ./query passes.\n\ngo test ./... -short was run; it failed in github.com/sourcegraph/zoekt/gitindex at TestCatfileReader_Excluded with Next large.bin: EOF. Rerunning just go test ./gitindex -short -run TestCatfileReader_Excluded -count=1 -v reproduced the same failure, which appears unrelated to this parser-only change.

Users reasonably expect wrapping a field query in parentheses to preserve its semantics, but the parser's regex/grouping ambiguity caused no-space forms like (sym:foo) to be treated as plain content text. Recognize field-looking parenthesized atoms as grouping so generated and hand-written field queries behave consistently while leaving bare regex grouping such as (foo) and (foo|bar) alone.

Amp-Thread-ID: https://ampcode.com/threads/T-019ef884-75bf-736d-b3b7-e19a7855d882
Co-authored-by: Amp <amp@ampcode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant