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. |
|
Looks like the tests are still failing on this... |
|
Yes, the |
… wasip1 The guard was on runtime.GOOS == "wasip1", so under wasip2 the three cases that rely on recover ran anyway. recover does not work on wasm yet, so the panic escaped and trapped the test binary — which is the tinygo-test-wasip2-fast failure on this PR. Checked on runtime.GOARCH instead, since the limitation is wasm's rather than any one platform's. wasip1, wasip2 and js/wasm all set the tinygo.wasm build tag, and arch_tinygowasm.go defines GOARCH as wasm for it, so one condition covers all three of the wasm test targets. Worth noting for anyone reading targets/wasip2.json: the goarch there is arm, but that is what is handed to the Go toolchain for package selection — runtime.GOARCH is the one above.
|
Fixed, and it turned out to be the CI failure rather than a cosmetic gap — thanks for spotting it.
I checked on One thing worth flagging for anyone reading along, because it briefly convinced me I had it wrong: Happy to switch to the explicit |
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.