From 05e7d10bc19c48abaf97a4fc7bf72aeb946697ee Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 25 Mar 2026 16:42:18 +0300 Subject: [PATCH] checker: fix select chan timeout (fixes #15269) --- vlib/v/checker/checker.v | 4 ++-- vlib/v/tests/concurrency/select_auto_sync_test.v | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 4b617d5d7..6e5eccb16 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -6215,8 +6215,8 @@ fn (mut c Checker) select_expr(mut node ast.SelectExpr) ast.Type { match mut branch.stmt { ast.ExprStmt { if branch.is_timeout { - if !branch.stmt.typ.is_int() { - tsym := c.table.sym(branch.stmt.typ) + tsym := c.table.final_sym(c.unwrap_generic(branch.stmt.typ)) + if !tsym.is_int() { c.error('invalid type `${tsym.name}` for timeout - expected integer number of nanoseconds aka `time.Duration`', branch.stmt.pos) } diff --git a/vlib/v/tests/concurrency/select_auto_sync_test.v b/vlib/v/tests/concurrency/select_auto_sync_test.v index 10aa5f4ea..8c155336d 100644 --- a/vlib/v/tests/concurrency/select_auto_sync_test.v +++ b/vlib/v/tests/concurrency/select_auto_sync_test.v @@ -6,3 +6,12 @@ fn test_main() { } assert true } + +fn test_select_accepts_duration_timeout() { + v := chan int{} + select { + _ := <-v {} + time.millisecond {} + } + assert true +} -- 2.39.5