- 
                Notifications
    You must be signed in to change notification settings 
- Fork 17
Implement module expression optional fragments #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Implement module expression optional fragments #228
Conversation
| CodSpeed Instrumentation Performance ReportMerging #228 will not alter performanceComparing  Summary
 | 
06498b6    to
    3bdcec8      
    Compare
  
    | return Err(GrimpError::InvalidModuleExpression(expression.to_owned())); | ||
| let mut patterns = Vec::new(); | ||
| for expanded in &expanded_expressions { | ||
| // Validate each expanded expression | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here is that after expanding the module expression, all of the expanded expressions should be valid by the old rules. E.g. a.b[.**] expands to a.b and a.b.**, both of which are valid expressions.
| Interesting to see how AI performs, but I'm not sure about the change itself. If someone is doing this in, say, a forbidden contract, can't they just remove  | 
| 
 @seddonym Yes they could - but  | 
| I see what you mean. I think of  I'm inclined to say that if someone is needing to use  Let's leave this PR open for now - there are a few new contracts in the offing which may make it unnecessary, and plenty of other things that I'd like to concentrate on - in particular speeding up the linter. Thanks for the idea though. | 
| 
 Okay sounds good to me - I'll put the PR back to draft for now then and we can revisit this if we see a need for it. | 
I've noticed some uses of module expressions in import linter contacts like this:
We currently need two entries here, since
domain.**does not includedomainitself.This observation motivates the change in this PR, which introduces a syntax for optional fragments within module expressions.
After this PR the above could be reduced to:
We didn't really discuss this before @seddonym so feel free to reject this or suggest alternatives!
I wanted to try out a agentic AI, which is the main personal reason for this PR. This PR was generated almost entirely by Claude 3.7 using Zed agentic AI.
Interestingly a module expression
domain[.**]now behaves the same asdomainwithas_package=True.