Repository navigation
fix: match bound method values by package path, not bare type name - #40
Merged
Merged
Conversation
ID, IDTarget and RenderTarget.Is matched a bound method value (p.List)
to its page by the receiver's bare type name, dropping the package. With
same-named page types in two packages, as with a Page type per package,
a bound value errored as ambiguous with no current page, and silently
took the current page's id when that was the other package's type. The
htmx and method render targets had the same confusion in Is.
boundReceiverFromFuncName now keeps the package path from the function
name, unescaping its last element ("yaml%2ev3"), and methodInfo.receiverIs
matches bound values on package path and type name, so they resolve as
exactly as method expressions. A generic value receiver "Gen[...].M-fm"
now parses to "Gen[...]" rather than "Gen[". Not-found errors name the
type by package path for both forms.
A function counted as a bound method value whenever its name contained
"-fm", so a standalone function in a package path such as "go-fmt..."
failed. Only the "-fm" suffix counts now.
Fixes #39
Claude-Session: https://claude.ai/code/session_01NpjJeP32ycvAHNFXRgTviG
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #40 +/- ##
==========================================
+ Coverage 95.22% 95.45% +0.22%
==========================================
Files 17 18 +1
Lines 1761 1759 -2
==========================================
+ Hits 1677 1679 +2
+ Misses 50 48 -2
+ Partials 34 32 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
joeblew999
added a commit
to joeblew999/structpages
that referenced
this pull request
Oct 28, 2026
TinyGo branch: catch up with jackielii/main (jackielii#40), fix what it exposed, skill and CI for TinyGo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #39.
Problem
ID,IDTargetandRenderTarget.Ismatched a bound method value (p.List) to its page by the receiver's bare type name. The package path was dropped fromruntime.FuncForPC. With same-named page types in different packages, such as aPagetype per package:The issue names
ID/IDTarget. The same name-only match was in two more places:methodRenderTarget.Is:Is(b.List)was true for the other package'sWidget.List.htmxUnmatchedTarget.Is: a request targeting the other package's same-named region never matched.Fix
boundReceiverFromFuncNamereturns the package path along with the type name. Go writes a.in the last path element as%2e(sub%2ev2, confirmed against a real module), so the path is unescaped before comparing.methodInfo.receiverIs(t)replacessameTypeNameat all four call sites. Bound values match on package path and type name, ignoring type arguments. Method expressions compare exactly as before.Gen[...].M-fmnow parses toGen[...], notGen[. This doesn't change any match, becausegenericBasealready cut the name at[; only the stored name and messages are now right.isBoundwasstrings.Contains(name, "-fm"), so a standalone function in a package path containing-fm(go-fmt…) failed with "cannot extract receiver type". It'sHasSuffixnow, with aninternal/fn-fmtfixture to cover it.Not done: the issue's step 3 (accepting pages that embed the type). A promoted bound value names the embedded type that declares the method, and structpages already skips promoted methods as components. So exact matching keeps today's behavior.
Tests
id_bound_cross_package_test.go:IDandIDTarget, with no current page and with eachWidgetas the current page;methodRenderTarget.IsandhtmxUnmatchedTarget.Isacross packages;-fmpackage path case.All of these fail on
main.TestBoundReceiverFromFuncName: adds the package path to every case, plus the escaped dot, a dot earlier in the path, generic types and a malformed escape.TestID_BoundMethodAmbiguous: it asserted the bug, a boundidconflicta.Widgetvalue being ambiguous withidconflictb.Widget. It now covers the real ambiguity: one type mounted under two parents.An independent review checked the
FuncForPCname forms on go1.27.1:main(under bothgo runandgo test) and external_testpackages;It found no correctness bugs. Interface method values now never match a page; before, they matched any page type with the same name.
go test ./...passes and golangci-lint is clean.https://claude.ai/code/session_01NpjJeP32ycvAHNFXRgTviG