diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index a83119c3db..a384ca369a 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -5753,6 +5753,8 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) { c.error('method overrides built-in array method', node.pos) } else if sym.kind == .sum_type && node.name == 'type_name' { c.error('method overrides built-in sum type method', node.pos) + } else if sym.kind == .multi_return { + c.error('cannot define method on multi-value', node.method_type_pos) } if sym.name.len == 1 { // One letter types are reserved for generics. diff --git a/vlib/v/checker/tests/multi_value_method_err.out b/vlib/v/checker/tests/multi_value_method_err.out new file mode 100644 index 0000000000..f5be76a119 --- /dev/null +++ b/vlib/v/checker/tests/multi_value_method_err.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/multi_value_method_err.vv:1:7: error: cannot define method on multi-value + 1 | fn (v (int, int)) f() {} + | ~~~~~~~~~~ diff --git a/vlib/v/checker/tests/multi_value_method_err.vv b/vlib/v/checker/tests/multi_value_method_err.vv new file mode 100644 index 0000000000..a84f0b654d --- /dev/null +++ b/vlib/v/checker/tests/multi_value_method_err.vv @@ -0,0 +1 @@ +fn (v (int, int)) f() {}