event: make nil available#34915
Open
cuiweixie wants to merge 1 commit into
Open
Conversation
Contributor
|
Please give justification for this change! |
Contributor
Author
Done |
fjl
reviewed
May 21, 2026
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.
Description
Problem
When FeedOf is instantiated with an interface-shaped type argument (notably any / interface{}) and callers use Send(nil), the logical value is nil carried inside an interface box. Taking reflect.ValueOf(value) in that situation yields an invalid reflect.Value, because the boxed value does not expose a concrete type the way reflect expects.
That invalidated value was then plugged into reflective send helpers (reflect.SelectCase, reflect.Value.TrySend). The old behaviour was wrong in practice: Send(nil) could panic or fail to deliver, instead of broadcasting nil to subscribers like any other payload.
Fix
Build the reflect.Value used for sending from reflect.ValueOf(&value).Elem(), so the holder of T is reflected correctly and the send path sees a valid value (including “nil interface” cases).
Testing
Add TestFeedOfSendNilAnySucceeds, which subscribes two buffered channels on a FeedOf[any], calls Send(nil), and asserts nsent == 2 and that both subscribers receive nil. This locks in the fixed behaviour and documents the previous failure mode.