rm support for obj.XGo_Enum(func(...)) - #644
Conversation
xushiwei
commented
Aug 16, 2026
- Proposal: for..range and for..in Iteration xgo#2841
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #644 +/- ##
==========================================
- Coverage 93.67% 93.66% -0.02%
==========================================
Files 29 29
Lines 7262 7217 -45
==========================================
- Hits 6803 6760 -43
+ Misses 391 389 -2
Partials 68 68 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Review: remove callback-style XGo_Enum for-range iteration
The core deletion is correct and self-consistent: checkUdt now rejects any nonzero-parameter XGo_Enum signature (returns nil, false), which fails closed to a normal cannot range over ... compile error. The removed internal/foo fixtures (Foo..Foo4) leave no dangling references, and the affected tests pass. go build/go vet are clean.
The one gap is incomplete cleanup: the checker half of the callback feature was removed, but the emitter half is left behind as dead code. Nothing now assigns a negative p.udt or p.kvt, so the else branch in emitForRangeStmt, the kvt field, and the cantUseFlowsInForRange constant are all unreachable. Removing them completes the PR's intent and should recover the coverage drop (the deleted tests were the only ones exercising that branch). Security and performance passes found nothing.
Additional findings
/workspace/gogen/util_gengo.go:1228: [P2] Dead code: negative-udt callback branch is now unreachable: Thiselsebranch handlesp.udt < 0(theX.XGo_Enum(func(k, v){...})callback form,n = -nat 1199). After this PR,p.udtis only ever set to a positive value (2/3) atstmt.go:726; the sole producer of a negativeudt(p.udt = -nincheckUdt case 1) was deleted. This branch and itsp.kvtreads are therefore dead code. Removing it completes the feature removal and, per the PR note, should recover the coverage drop since the deleted tests were the only ones exercising it. ThecantUseFlowsInForRangeconstant (below, ~line 1232) is referenced only from here and becomes unused once this branch is gone.stmt.go:487: [P3] Vestigialkvtfield after callback path removal:kvtis now never assigned anywhere in the codebase; it is read only from the now-dead negative-udtbranch inemitForRangeStmt. It can be removed fromforRangeStmtas part of completing the removal.