cl: support range over function types (Go 1.23) #587
Conversation
Add support for Go 1.23 iterator functions that can be used with the range statement. This enables custom iterators with signatures: - func(yield func() bool) - 0 values - func(yield func(V) bool) - 1 value - func(yield func(K, V) bool) - 2 values The checkIteratorFunc function detects these signatures and returns appropriate key/value types for the range statement. Fixes goplus/xgo#2607 Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: xushiwei <396972+xushiwei@users.noreply.github.com>
Add three test cases for Go 1.23 iterator function support:
- TestForRangeFunc0: 0-value iterator (for range foo {})
- TestForRangeFunc1: 1-value iterator (for v := range bar {})
- TestForRangeFunc2: 2-value iterator (for k, v := range weekdays {})
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: xushiwei <396972+xushiwei@users.noreply.github.com>
Summary of ChangesHello @xushiwei, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates support for the upcoming Go 1.23 feature that enables Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #587 +/- ##
==========================================
+ Coverage 96.06% 96.07% +0.01%
==========================================
Files 25 25
Lines 6855 6879 +24
==========================================
+ Hits 6585 6609 +24
Misses 202 202
Partials 68 68 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request adds support for range over function types, a new feature in Go 1.23. The implementation correctly handles the new case *types.Signature in getKeyValTypes and adds a checkIteratorFunc to validate iterator function signatures. The accompanying tests in package_test.go are well-written and cover the new functionality. However, I've identified a few areas for improvement: the tests for checkIteratorFunc are missing positive cases, there's a misleading comment in checkIteratorFunc, and more importantly, the existing logic for handling for range variables doesn't seem to correctly validate against the number of values produced by function iterators, which could lead to a panic.
Code Review SummaryGreat work implementing Go 1.23's range over function types! The implementation is clean and follows existing codebase patterns. Found three noteworthy issues:
The integration tests are comprehensive, but the unit test should directly verify valid signatures return correct types. |
No description provided.