Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 44bc6d5525
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
44bc6d5 to
06c3c66
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi made 1 comment.
Reviewable status: 0 of 9 files reviewed, 1 unresolved discussion (waiting on @TomerStarkware).
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 9 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @orizi).
orizi
left a comment
There was a problem hiding this comment.
@orizi resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @orizi).
…_consumption_of_ref_self_of_tempraries

Summary
Added support for calling
ref selfmethods on temporary expressions, allowing code likemake_counter().increment()whereincrementtakesref self. This enables method chaining on temporary values that modify self.Type of change
Please check one:
Why is this change needed?
Previously, methods that take
ref selfcould only be called on variables, not on temporary expressions. This limitation prevented method chaining for methods that modify self, requiring users to create intermediate variables. This change allows for more fluent API design where methods can modify state and return self for chaining.What was the behavior or documentation before?
Code like
make_counter().increment()would fail to compile ifincrementtookref self, with an error message indicating that ref arguments must be variables. This forced developers to use intermediate variables even for simple method chains.What is the behavior or documentation after?
Methods that take
ref selfcan now be called on temporary expressions, enabling patterns like:This works by introducing a new
TempReferencevariant for function call arguments that handles passing temporary expressions by reference.Additional context
The implementation:
TempReferencevariant toExprFunctionCallArgNamedArgto track when temporary references are allowedThis change only applies to
ref selfparameters in method calls, not to regularrefparameters in function calls, which still require variables.