1
0
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:
zakuro 2021-02-16 00:55:54 +09:00 committed by GitHub
parent 70a30374b9
commit 2911f03627
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

View File

@ -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.

View 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() {}
| ~~~~~~~~~~

View File

@ -0,0 +1 @@
fn (v (int, int)) f() {}