Skip to content

rm unboundType, unboundMapElemType; rm cb.NewAutoVar - #628

Merged
xushiwei merged 1 commit into
goplus:mainfrom
xushiwei:q
Jun 18, 2026
Merged

rm unboundType, unboundMapElemType; rm cb.NewAutoVar#628
xushiwei merged 1 commit into
goplus:mainfrom
xushiwei:q

Conversation

@xushiwei

Copy link
Copy Markdown
Member

No description provided.

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

Copy link
Copy Markdown
Contributor

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 removes the unboundType and unboundMapElemType types, along with the NewAutoVar function and all associated logic across the codebase. This cleanup simplifies type handling, particularly in ast.go, builtin.go, codebuild.go, and util_gengo.go, and updates the test suite to reflect these removals. I have no additional feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.58%. Comparing base (785b7c5) to head (b2745fb).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #628      +/-   ##
==========================================
+ Coverage   93.20%   93.58%   +0.38%     
==========================================
  Files          29       29              
  Lines        7195     7113      -82     
==========================================
- Hits         6706     6657      -49     
+ Misses        415      388      -27     
+ Partials       74       68       -6     

☔ View full report in Codecov by Harness.
📢 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 86c09b6 into goplus:main Jun 18, 2026
20 checks passed

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

This PR cleanly removes the unboundType/unboundMapElemType deferred-type-resolution mechanism and replaces NewAutoVar with explicit NewVar + string-based VarRef/VarVal. The structural deletions are thorough and consistent. Two correctness issues need attention before merge.

Confirmed issues:

  1. zeroCompositeLit typ0 out-parameter is silently dead — the caller (codebuild.go:770) reads typ0 as the Type of the returned Element, but the new implementation never writes to *typ0. This is a latent correctness bug: the returned element's type may be stale/wrong for named/aliased types where typ0 was supposed to be updated (previously the unboundType branch wrote *typ0 = t.tBound). The typ0 parameter should either be removed from the signature (if genuinely unused in all paths) or the implementation should assign *typ0 = typ before returning.

  2. Dropped test coverage for generic-function-result assignment (typeparams_test.go) — the case exercising fn1 = foo.Loader[*int, int] / fn1(nil, 1) is deleted rather than migrated. The scenario (generic instantiation result stored in a typed variable and then called) is distinct from the other NewVarStart-based cases and should be re-expressed with NewVar(tySig, "fn1") + VarRef("fn1").

Minor / informational:

  1. Redeclaration test removed without replacement (error_msg_test.go) — the foo redeclared in this block sub-test in TestErrNewVar is dropped. Recommend re-adding an equivalent case using NewVar/NewVarStart so the previous declaration at ... error path stays covered.

  2. realType can be simplified (type_ext.go) — with one case remaining, a plain if type-assertion is clearer than a type switch.

  3. VarRef/VarVal use position-insensitive LookupParent — position is token.NoPos, so shadowing semantics differ from a positioned lookup. Worth a one-line doc note.

Comment thread util_gengo.go
default:
ret.Type = toType(p, typ)
return &ast.CompositeLit{
Type: toType(p, typ),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

typ0 is passed by the caller to receive the resolved type (codebuild.go uses it as Element.Type), but this implementation never writes to *typ0. Remove the parameter if it is truly dead, or add *typ0 = typ before returning to preserve the caller's expectation.

Comment thread typeparams_test.go
@@ -523,8 +522,6 @@ var MyInts = Int{1,2,3,4}
NewVarStart(tyInt, "n7").Val(fnAdd).Typ(tyString).Typ(tyInt).Index(2, 0).Val("hello").Val(1).Val(2).Val(3).SliceLit(tyIntSlice, 3).CallWith(2, 0, gogen.InstrFlagEllipsis).EndInit(1).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fn1 case (generic instantiation result assigned to a typed variable and then called) was testing a distinct code-gen path. Please re-express it with NewVar(tySig, "fn1") + VarRef("fn1") rather than dropping the coverage entirely.

Comment thread error_msg_test.go
@@ -321,14 +321,6 @@ func TestErrConst(t *testing.T) {
}

func TestErrNewVar(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The redeclaration sub-test (foo redeclared in this block ... previous declaration at ...) is removed with no equivalent replacement. Consider re-adding it using NewVar/NewVarStart so this error path and its position formatting stay tested.

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