Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@aofei
Copy link
Member

@aofei aofei commented Jan 12, 2026

This also adapts compileReturnStmt to use defer for calling Return, ensuring return statements are recorded in AST even when argument compilation fails, preventing spurious "missing return" errors.

Updates goplus/gogen#557

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @aofei, 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 primarily focuses on updating the github.com/goplus/gogen dependency and addressing a critical compilation issue related to return statement handling. By leveraging a defer statement, the change ensures consistent AST recording for return statements, which is vital for accurate control flow analysis. Additionally, it includes minor adjustments to test cases and enhances error handling in a demo application, contributing to overall stability and correctness.

Highlights

  • Dependency Update: The github.com/goplus/gogen dependency has been updated from v1.19.6 to v1.19.8.
  • Temporary Fork Usage: A replace directive has been added to go.mod to temporarily use a fork (github.com/aofei/fork.goplus.gogen) for the goplus/gogen dependency.
  • Improved Return Statement Handling: The compileReturnStmt function in cl/stmt.go now utilizes a defer statement to ensure that the ctx.cb.Return method is always called. This guarantees that return statements are correctly recorded in the Abstract Syntax Tree (AST) even if argument compilation fails, thereby preventing spurious 'missing return' errors during control flow analysis.
  • Test Case Adjustments: Minor modifications were made in cl/compile_test.go to ensure Gop_Enum methods return fooIter{} and test functions return 0, likely to align with updated gogen behavior or stricter compilation.
  • Demo Code Robustness: Error handling in demo/xgo-calc/calc.xgo has been improved by adding panic statements for unknown binary operators, functions, and unary operators, making the demo more robust.

🧠 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 updates the github.com/goplus/gogen dependency and adapts compileReturnStmt to use a defer statement. This is a solid improvement that ensures Return is always called, preventing spurious 'missing return' errors. I've found a critical bug in the xgo-calc demo where division was incorrectly implemented as addition. Please see the specific comment for details.

@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.98%. Comparing base (806dd33) to head (8a0728d).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2532   +/-   ##
=======================================
  Coverage   93.98%   93.98%           
=======================================
  Files          34       34           
  Lines        9631     9631           
=======================================
  Hits         9052     9052           
  Misses        414      414           
  Partials      165      165           

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

…60114155758-01b7b91c31d1

This also adapts `compileReturnStmt` to use defer for calling `Return`,
ensuring return statements are recorded in AST even when argument
compilation fails, preventing spurious "missing return" errors.

Updates goplus/gogen#557

Signed-off-by: Aofei Sheng <[email protected]>
@aofei aofei changed the title chore(deps): bump github.com/goplus/gogen from 1.19.6 to 1.19.9 chore(deps): bump github.com/goplus/gogen from 1.19.6 to 1.19.9-0.20260114155758-01b7b91c31d1 Jan 15, 2026
@aofei aofei marked this pull request as ready for review January 15, 2026 02:01
Copilot AI review requested due to automatic review settings January 15, 2026 02:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the github.com/goplus/gogen dependency from version 1.19.6 to 1.19.9-0.20260114155758-01b7b91c31d1 and fixes a compiler bug where "missing return" errors were incorrectly reported when return statement argument compilation failed. The fix uses a deferred call to ensure return statements are always recorded in the AST for control flow analysis, and includes test updates to add missing return statements that were previously not caught due to the bug.

Changes:

  • Bumps github.com/goplus/gogen dependency to version 1.19.9-0.20260114155758-01b7b91c31d1
  • Refactors compileReturnStmt to use defer for calling ctx.cb.Return, ensuring return statements are recorded even when argument compilation fails
  • Fixes a bug in the calculator demo where division was using addition operator
  • Adds panic statements for unreachable code paths in the calculator demo
  • Updates test fixtures to include return statements that were previously missing but uncaught

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
go.mod Updates gogen dependency version
go.sum Updates checksums for new gogen version
cl/stmt.go Refactors compileReturnStmt to use defer for Return call, ensuring AST recording even on compilation failure
demo/xgo-calc/calc.xgo Fixes division operator bug and adds panic statements for error handling
cl/compile_test.go Adds return statements to test fixtures that were previously missing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@xgopilot
Copy link

xgopilot bot commented Jan 15, 2026

Code Review Summary

This PR correctly addresses gogen#557 by using defer to ensure Return is registered in the AST before argument compilation, preventing spurious "missing return" errors when return statements have type mismatches.

The implementation is sound - the defer pattern matches similar cleanup patterns used elsewhere in stmt.go (e.g., compileForStmt, compileIfStmt). The demo bug fix (+/ for token.QUO) and added panic statements for unhandled cases are also appropriate improvements.

All tests pass. LGTM.

@xushiwei xushiwei merged commit ffb7b08 into goplus:main Jan 15, 2026
34 of 35 checks passed
@aofei aofei deleted the deps branch January 15, 2026 06:10
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.

3 participants