Skip to content

cl compileFuncOrMethod: remove clsName; ctx.genAsMethod: self as recv - #950

Merged
xushiwei merged 1 commit into
goplus:mainfrom
xushiwei:lcls
Oct 6, 2026
Merged

xushiwei merged 1 commit into
goplus:mainfrom
xushiwei:lcls

Conversation

@xushiwei

@xushiwei xushiwei commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

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

Review summary

Clean refactor of the C-to-method logical-class handling plus a test-fixture addition. The changes are small and well-scoped:

  • cl/func.go — removes the clsName local and passes typName directly to funcName(). Verified behavior-preserving: when a function resolves to a logical class distinct from its receiver (cls != "" && cls != typName), typName is already reassigned to cls at line 154 before fnName is computed at line 165, so the value handed to funcName is identical across every path.
  • cl/logical.go — renames the generated As<Class> receiver from o to the shared c2goMethodRecvName ("self") and references the resolved param via .Val(recv) instead of the string-keyed .VarVal("o"). More robust (no name-drift risk) and consistent with the generated output.
  • test fixtures — PyList_SetItem (void, 3 params) correctly maps to func (self *List) SetItem(index, value *Object) with the matching //llgo:link directive, mirroring the existing PyList_GetItem -> Item pattern.

Security (unsafe.Pointer reinterpret in AsList) is layout-safe via first-field struct embedding, nil-safe, and operates only on opaque FFI handles. No performance concerns.

One stale doc comment flagged inline.

Minor (optional)

The synthesized As<Class> receiver in genAsMethod is unconditionally named self, while tryToMethod (cl/func.go:255,271) only applies c2goMethodRecvName when ctx.stdRecvName is true. This asymmetry is pre-existing (the old code hardcoded o the same way) and not introduced by this PR — noting only in case uniform receiver naming under stdRecvName=false is desired.

Findings without inline locations

  • cl/logical.go:43: Stale receiver name here. This PR renamed the generated As<Class> receiver from o to self (updating the genAsMethod doc at line 108 and the inline comment at line 133), but this package-level example still shows o:

@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.97%. Comparing base (b00c3ec) to head (f536b6b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #950      +/-   ##
==========================================
+ Coverage   87.95%   87.97%   +0.01%     
==========================================
  Files          23       23              
  Lines        2665     2661       -4     
==========================================
- Hits         2344     2341       -3     
+ Misses        321      320       -1     
Flag Coverage Δ
llgo-tests 87.97% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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 f59d02d into goplus:main Oct 6, 2026
4 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