Repository navigation
feat(where): Support stored closure - #15697
Merged
Merged
Conversation
Bahex
commented
May 6, 2025
- Only variables and cell-path accesses on variables are allowed as closures. These can't be `$it` or a path on `$it` - Any other expression falls back to the usual RowCondition expression
cptpiepmatz
approved these changes
May 6, 2025
This was referenced Jun 1, 2025
blindFS
reviewed
Jul 10, 2025
Comment on lines
+38
to
+41
| SyntaxShape::OneOf(vec![ | ||
| SyntaxShape::RowCondition, | ||
| SyntaxShape::Closure(Some(vec![SyntaxShape::Any])), | ||
| ]), |
Contributor
There was a problem hiding this comment.
Regarding #16129 ,
Do we need the Closure here if we already manually override the expression type to make it compatible?
Member
Author
There was a problem hiding this comment.
@blindFS Hey thanks for pointing this out, I just got around to fixing it.
Closure is not actually needed to make it work, just added for documentation.
And removing the it solves the problem without any further work, but I'll try to solve the issue without removing it if I can.
Bahex
added a commit
that referenced
this pull request
Jul 22, 2025
…e text (#16192) - fixes #16129 # Description ## Problem Parsing a multi span value as RowCondition always produces a RowCondition expression that covers all the spans. Which is problematic inside OneOf and can produce multiple expressions with overlapping spans. Which results in funky highlighting that duplicates text. ## Solution Only reason for including `SyntaxShape::Closure` in the signature (#15697) was for documentation purposes, making it clear in `help` texts that a closure can be used as the argument. As our current parser is shape directed, simplifying the command signature means simplifies the parsing, so using a RowCondition on its own, and instead making it always look like a union with `closure(any)` solves the issue without any changes in the parser. Also, RowCondition always accepts closure values anyway, so its textual representation should indicate that without the need to wrap it in OneOf. Co-authored-by: Bahex <[email protected]>
hardfau1t
pushed a commit
to hardfau1t/nushell
that referenced
this pull request
Aug 25, 2025
…e text (nushell#16192) - fixes nushell#16129 # Description ## Problem Parsing a multi span value as RowCondition always produces a RowCondition expression that covers all the spans. Which is problematic inside OneOf and can produce multiple expressions with overlapping spans. Which results in funky highlighting that duplicates text. ## Solution Only reason for including `SyntaxShape::Closure` in the signature (nushell#15697) was for documentation purposes, making it clear in `help` texts that a closure can be used as the argument. As our current parser is shape directed, simplifying the command signature means simplifies the parsing, so using a RowCondition on its own, and instead making it always look like a union with `closure(any)` solves the issue without any changes in the parser. Also, RowCondition always accepts closure values anyway, so its textual representation should indicate that without the need to wrap it in OneOf. Co-authored-by: Bahex <[email protected]>
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.
Description
whereused to be able to filter using stored closures at some point using a flag.filtercommand added to cover the use case.This PR once again allows using
wherewith closures stored in variables.This does not interfere with using
$itor one of its fields as the condition.This change obsoletes
filter, deprecate it in the future?User-Facing Changes
Tests + Formatting
Added examples and tests.
After Submitting