Skip to content

fix(on): split panic by nil / top-level / closure (#36)#47

Merged
joaomdsg merged 2 commits into
mainfrom
fix/on-panic-classify
May 28, 2026
Merged

fix(on): split panic by nil / top-level / closure (#36)#47
joaomdsg merged 2 commits into
mainfrom
fix/on-panic-classify

Conversation

@joaomdsg

Copy link
Copy Markdown
Member

Closes #36.

Summary

  • on.* previously panicked with a single lumped message ("got a closure, top-level function, or nil") regardless of which mistake the caller actually made.
  • Added notMethodPanic(event, fn) in on/on.go that uses reflect + runtime.FuncForPC to classify the bad input as nil, a closure, or a top-level function; both panic sites (the event fast path and the optioned render path) route through it.
  • Closures are detected via the .func segment in the runtime function name; -fm-suffixed bound methods are already handled upstream by spec.MethodName.

Test plan

  • go test -race ./...
  • New tests cover all three classifications via on.Click (event fast path) and a closure via on.Key (render path).

@joaomdsg
joaomdsg merged commit 65e8c87 into main May 28, 2026
4 checks passed
@joaomdsg
joaomdsg deleted the fix/on-panic-classify branch May 28, 2026 16:49
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.

on.Click(...) panic message lumps three failure modes together

1 participant