reflect: implement MakeChan - #5588
Conversation
|
Please add a test for this new function. For reflect, this can either be in |
|
Added It covers buffered and unbuffered creation (kind, On verification: CI has not run on this PR, so I checked the test's expectations against the host |
13e03e0 to
31537f7
Compare
31537f7 to
18a08f0
Compare
|
Took the second option, since #5550 is still open with review discussion on it and I would rather not have this wait on an unknown. The three panic cases now skip on wasip1, with a TODO pointing at #5550 so the skip goes when that lands. The buffered and unbuffered cases — which are the substance, covering If you would rather hold this until #5550 is in, that last commit is the only thing to drop; the rest is unchanged from your LGTM. |
|
|
TinyGo had MakeMap/MakeSlice but not MakeChan. Implement it via the runtime chanMake primitive (mirroring MakeMap), so packages that call reflect.MakeChan (e.g. github.com/ugorji/go/codec used by gin) compile and work.
18a08f0 to
f43bc68
Compare
|
Swapped for The two substantive cases, buffered and unbuffered, still run everywhere; only the three panic cases return early on wasip1, with the TODO still pointing at #5550 so they come back when it lands. |
reflect.MakeChancurrently panics with "unimplemented". This implements it.It completes a small gap:
MakeSlice,MakeMapandNeware all supported, so code that builds a channel reflectively is the odd one out — and it is reached by generic container and codec libraries that construct channel types from areflect.Type.Verified by building TinyGo and running the compiler test suite.