Skip to content

cb.Member: support map type#580

Merged
xushiwei merged 4 commits intogoplus:mainfrom
xushiwei:q
Jan 27, 2026
Merged

cb.Member: support map type#580
xushiwei merged 4 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 enhances the code builder's capability to correctly interpret and generate code for map member access. It shifts the mechanism for handling map operations from a generic built-in method approach to a more specific implementation that directly supports indexing into map elements, thereby improving the accuracy and expressiveness of generated code involving maps.

Highlights

  • Map Type Handling Refactor: Refactored the internal handling of map types, moving away from treating map methods like Len as generic built-in methods.
  • Direct Map Element Access: Introduced explicit support for direct element access on map types (e.g., myMap["key"]) within the cb.Member logic, generating an ast.IndexExpr.
  • Removal of Redundant Built-in Map Type Definitions: Removed the tyMap global variable and its associated entries from the initBuiltinTIs and getBuiltinTI functions in builtin.go, as map operations are now handled more specifically.

🧠 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 adds support for accessing map elements using dot notation, e.g., myMap.key. This is a nice syntactic sugar. The implementation correctly generates an index expression for this access. However, it misses a crucial check: it doesn't verify that the map's key type is a string. This could lead to generating invalid Go code for maps with non-string keys. I've added a comment with a suggestion to fix this.

@xgopilot
Copy link
Contributor

xgopilot bot commented Jan 27, 2026

Code Review Summary

This PR introduces map member access as syntactic sugar (map.fieldmap["field"]), which is well-implemented but has critical issues:

Critical:

  • TestBTIMethod fails - breaking change removes map.Len() support
  • ⚠️ No key type validation - only works correctly with string-keyed maps

Required:

  • Add documentation explaining the new map handling behavior
  • Fix or update the failing test
  • Validate map key type or document string-key requirement

Positive:

  • ✅ Clean implementation with proper type safety for string keys
  • ✅ Performance improvement from eliminating BuiltinTI lookups
  • ✅ Correct handling of reference flags

@xgopilot
Copy link
Contributor

xgopilot bot commented Jan 27, 2026

Code Review Summary

Critical Issues:

  1. Test Failure: Removing map.Len() breaks TestBTIMethod - needs immediate attention
  2. Missing Type Validation: No check that map keys are strings before generating m["field"] index access

Recommendations:

  • Add map key type validation to ensure only string-keyed maps support field-style access
  • Either fix the test or implement hybrid behavior for builtin methods like Len()
  • Add explanatory comment for the map case in findMember()

Positive Notes:
Performance analysis shows this is a net improvement - eliminates indirection and hash lookups during code generation.

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.04%. Comparing base (9e15882) to head (2e863b4).
⚠️ Report is 23 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #580   +/-   ##
=======================================
  Coverage   96.04%   96.04%           
=======================================
  Files          25       25           
  Lines        6819     6833   +14     
=======================================
+ Hits         6549     6563   +14     
  Misses        202      202           
  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 fabd75a into goplus:main Jan 27, 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