Skip to content

tuple unpack: twoValue => multiValue#575

Merged
xushiwei merged 2 commits intogoplus:mainfrom
xushiwei:q
Jan 22, 2026
Merged

tuple unpack: twoValue => multiValue#575
xushiwei merged 2 commits intogoplus:mainfrom
xushiwei:q

Conversation

@xushiwei
Copy link
Member

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 introduces a significant refactoring in how the system handles multiple return values, moving from a binary 'two-value' flag to a more explicit integer parameter (lhs) that specifies the exact number of left-hand side values expected. This change enhances the flexibility and clarity of function calls, type assertions, and indexing operations, allowing for better support of tuple unpacking and multi-value assignments throughout the codebase.

Highlights

  • Refactored Multi-Value Handling: Replaced the boolean InstrFlagTwoValue with a more flexible lhs int parameter across several core functions (matchFuncCall, matchTypeCast, matchRcast, matchFuncType) to explicitly indicate the number of left-hand side values expected from an operation.
  • API Changes in CodeBuilder: The CodeBuilder methods CallWith, CallWithEx, Index, UnaryOp, and TypeAssert have been updated to accept the new lhs int parameter, providing more granular control over multi-value assignments and expressions.
  • Simplified Instruction Flags: Removed InstrFlagTwoValue and instrFlagOpFunc from InstrFlags as their functionality is now covered by the new lhs parameter, streamlining the instruction flag set.
  • Test Suite Updates: All relevant test files (builtin_test.go, codebuild.go, error_msg_test.go, package_test.go, template.go, typeparams_test.go, unsafe_test.go, xgo_test.go) have been updated to align with the new function signatures and parameter usage.

🧠 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.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the handling of multi-value returns by replacing the twoValue boolean flag with a more general lhs integer, representing the number of variables on the left-hand side of an assignment. This is a good direction for improving support for tuple unpacking.

My review has identified a couple of critical bugs where the new lhs parameter is not correctly propagated, and a high-severity issue where a check was not generalized to handle more than two return values. Addressing these will be important for the correctness and completeness of this feature.

@xgopilot
Copy link
Contributor

xgopilot bot commented Jan 22, 2026

Code Review Summary

This refactoring improves code clarity by replacing the InstrFlagTwoValue flag with an explicit lhs parameter. However, two critical bugs prevent this PR from working correctly.

Critical Issues

  1. codebuild.go:2313 - lhs not forwarded to doUnaryOp (causes TestRecv failure)
  2. codebuild.go:537 - lhs not forwarded to matchFuncCall

Both bugs pass hardcoded 0 instead of the lhs parameter, breaking multi-value operations like elem, ok := <-channel.

Recommendations

  • Fix the two parameter forwarding bugs
  • Run full test suite to verify all tests pass
  • Consider updating remaining "twoValue" references in comments for consistency

The refactoring approach is sound—explicit parameters are clearer than flags—but the implementation needs completion.

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

❌ Patch coverage is 97.01493% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.10%. Comparing base (697e433) to head (e68614e).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
codebuild.go 92.59% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #575      +/-   ##
==========================================
- Coverage   96.10%   96.10%   -0.01%     
==========================================
  Files          25       25              
  Lines        6837     6831       -6     
==========================================
- Hits         6571     6565       -6     
  Misses        198      198              
  Partials       68       68              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xushiwei xushiwei merged commit d51828c into goplus:main Jan 22, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant