query: resolve type lifting after OR parsing#1023
Open
keegancsmith wants to merge 1 commit intomainfrom
Open
Conversation
The parser used to lift `type:` directives before converting `or` placeholders into real boolean nodes. That let parse-time `orOp` sentinels leak into `Type` children for unparenthesized queries and allowed malformed inputs like `type:repo or` to parse successfully until runtime. Resolve operator placeholders before wrapping with `Type` so unparenthesized `or` inside a type scope produces a valid `Or` subtree and malformed `or` placement is rejected during parsing. The docs now clarify that `type:` applies to the whole expression in its current scope, including `or` clauses. Test Plan: - go test ./query - go test ./... -short Amp-Thread-ID: https://ampcode.com/threads/T-019d0be7-4c9d-76fd-b556-103420d14be9 Co-authored-by: Amp <amp@ampcode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change fixes a parser ordering bug where
type:lifting happened beforeorplaceholder resolution. In unparenthesized queries such astype:repo foo or bar, the parser could previously leave internalorOpsentinels inside aTypechild instead of producing a validOrsubtree. That also let malformed queries liketype:repo orandor type:repoget accepted in parsing even though they should fail early.The fix resolves operators first for typed scopes and then wraps the resulting expression in
Type, preserving existing top-level type lifting semantics while ensuringoris validated and represented correctly. I also added parser regressions that cover the previously brokentype+orcase and malformed edge cases.The query syntax docs now explicitly describe
type:scope withorto match parser behavior and reduce ambiguity.