From 00b68174eef6ec19c8bf5e09ac92db91cb7e8d23 Mon Sep 17 00:00:00 2001 From: Hedgegod Date: Sat, 14 Feb 2026 21:54:54 +0300 Subject: [PATCH] checker: avoid panic on unresolved infix operand types in -check (fixes #26458) (#26607) --- vlib/v/checker/infix.v | 12 ++++++++++++ .../tests/infix_is_unknown_module_no_panic.out | 7 +++++++ .../tests/infix_is_unknown_module_no_panic.vv | 12 ++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 vlib/v/checker/tests/infix_is_unknown_module_no_panic.out create mode 100644 vlib/v/checker/tests/infix_is_unknown_module_no_panic.vv diff --git a/vlib/v/checker/infix.v b/vlib/v/checker/infix.v index 6e245312d..960967c53 100644 --- a/vlib/v/checker/infix.v +++ b/vlib/v/checker/infix.v @@ -9,6 +9,10 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type { c.expected_type = former_expected_type } mut left_type := c.expr(mut node.left) + if left_type == ast.no_type { + node.left_type = left_type + return ast.void_type + } mut left_sym := c.table.sym(left_type) node.left_type = left_type c.expected_type = left_type @@ -81,6 +85,14 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type { } } mut right_type := c.expr(mut node.right) + if right_type == ast.no_type { + node.right_type = right_type + if node.op in [.key_is, .not_is] { + node.promoted_type = ast.bool_type + return ast.bool_type + } + return ast.void_type + } if node.op == .key_is { c.inside_x_is_type = false } diff --git a/vlib/v/checker/tests/infix_is_unknown_module_no_panic.out b/vlib/v/checker/tests/infix_is_unknown_module_no_panic.out new file mode 100644 index 000000000..4c3a8f655 --- /dev/null +++ b/vlib/v/checker/tests/infix_is_unknown_module_no_panic.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/infix_is_unknown_module_no_panic.vv:7:13: error: unknown module `io` + 5 | fn main() { + 6 | _ := sample() or { + 7 | if err is io.Eof { + | ~~ + 8 | return + 9 | } diff --git a/vlib/v/checker/tests/infix_is_unknown_module_no_panic.vv b/vlib/v/checker/tests/infix_is_unknown_module_no_panic.vv new file mode 100644 index 000000000..3f4f30c7f --- /dev/null +++ b/vlib/v/checker/tests/infix_is_unknown_module_no_panic.vv @@ -0,0 +1,12 @@ +fn sample() !int { + return error('x') +} + +fn main() { + _ := sample() or { + if err is io.Eof { + return + } + return + } +} -- 2.39.5