mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: reject method that have multi-value type receiver (#8696)
This commit is contained in:
parent
70a30374b9
commit
2911f03627
@ -5753,6 +5753,8 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
|
|||||||
c.error('method overrides built-in array method', node.pos)
|
c.error('method overrides built-in array method', node.pos)
|
||||||
} else if sym.kind == .sum_type && node.name == 'type_name' {
|
} else if sym.kind == .sum_type && node.name == 'type_name' {
|
||||||
c.error('method overrides built-in sum type method', node.pos)
|
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 {
|
if sym.name.len == 1 {
|
||||||
// One letter types are reserved for generics.
|
// One letter types are reserved for generics.
|
||||||
|
3
vlib/v/checker/tests/multi_value_method_err.out
Normal file
3
vlib/v/checker/tests/multi_value_method_err.out
Normal file
@ -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() {}
|
||||||
|
| ~~~~~~~~~~
|
1
vlib/v/checker/tests/multi_value_method_err.vv
Normal file
1
vlib/v/checker/tests/multi_value_method_err.vv
Normal file
@ -0,0 +1 @@
|
|||||||
|
fn (v (int, int)) f() {}
|
Loading…
Reference in New Issue
Block a user