Skip to content

fix(cl): scope.lookupFuncDecl doesn't support overloads - #1108

Merged
xushiwei merged 2 commits into
goplus:mainfrom
xushiwei:q
Oct 26, 2026
Merged

xushiwei merged 2 commits into
goplus:mainfrom
xushiwei:q

Conversation

@xushiwei

Copy link
Copy Markdown
Member

No description provided.

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

The code change is sound: restricting lookupFuncDecl to resolve only non-overloaded (single-declaration) names fixes the case where the macro generator previously bound a macro's reference to an arbitrary "first" overload. The len(ovs.items) == 1 guard also makes the ovs.items[0] index provably safe, and addOverloadObj never creates an empty group, so there's no bounds or nil risk. No performance or security concerns.

The findings below are about keeping the surrounding documentation and the caller's error message honest after this behavioral narrowing — the doc comment and the == 1 rationale are the two worth addressing; the error message is an optional follow-up.

Additional (no inline diff location): In cl/macrofunc.go:49, when lookupFuncDecl now returns ok == false for a reference name that is actually present but overloaded, compileMacroFunc reports macroFunc %s: reference function %s not found. For this newly-reachable path the function is found — it's just overloaded/unsupported — so the "not found" wording can send users chasing a nonexistent symbol. Consider a distinct message (e.g. reference function %s is overloaded; not supported) when the name exists with multiple overload items. This file isn't in the diff, so it's noted here rather than inline.

Comment thread cl/preload.go
Comment thread cl/preload.go
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.26%. Comparing base (37923b1) to head (a1fcd47).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1108      +/-   ##
==========================================
- Coverage   90.27%   90.26%   -0.01%     
==========================================
  Files          26       26              
  Lines        3279     3278       -1     
==========================================
- Hits         2960     2959       -1     
  Misses        319      319              
Flag Coverage Δ
llgo-tests 90.26% <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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xushiwei
xushiwei merged commit eeb7e96 into goplus:main Oct 26, 2026
2 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