Repository navigation
fix(cl): scope.lookupFuncDecl doesn't support overloads - #1108
Conversation
There was a problem hiding this comment.
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
No description provided.