mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +00:00
compiler,runtime: check for channel size limits
This patch is a combination of two related changes:
1. The compiler now allows other types than `int` when specifying the
size of a channel in a make(chan ..., size) call.
2. The compiler now checks for maximum allowed channel sizes. Such
checks are trivially optimized out in the vast majority of cases as
channel sizes are usually constant.
I discovered this issue when trying out channels on AVR.
This commit is contained in:
committed by
Ron Evans
parent
1a7369af6e
commit
79dae62c78
Vendored
+10
@@ -54,6 +54,16 @@ func main() {
|
||||
n, ok = <-ch
|
||||
println("recv from closed channel:", n, ok)
|
||||
|
||||
// Test various channel size types.
|
||||
_ = make(chan int, int8(2))
|
||||
_ = make(chan int, int16(2))
|
||||
_ = make(chan int, int32(2))
|
||||
_ = make(chan int, int64(2))
|
||||
_ = make(chan int, uint8(2))
|
||||
_ = make(chan int, uint16(2))
|
||||
_ = make(chan int, uint32(2))
|
||||
_ = make(chan int, uint64(2))
|
||||
|
||||
// Test bigger values
|
||||
ch2 := make(chan complex128)
|
||||
wg.add(1)
|
||||
|
||||
Reference in New Issue
Block a user