checker: skip checking for invalid fn return type (#8703)
parent
40066a5daa
commit
db609a0784
|
@ -5777,6 +5777,7 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if node.return_type != table.Type(0) {
|
||||||
return_sym := c.table.get_type_symbol(node.return_type)
|
return_sym := c.table.get_type_symbol(node.return_type)
|
||||||
if node.language == .v && return_sym.kind in [.placeholder, .int_literal, .float_literal]
|
if node.language == .v && return_sym.kind in [.placeholder, .int_literal, .float_literal]
|
||||||
&& return_sym.language == .v {
|
&& return_sym.language == .v {
|
||||||
|
@ -5790,7 +5791,8 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
|
||||||
c.error('.str() methods should have 0 arguments', node.pos)
|
c.error('.str() methods should have 0 arguments', node.pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if node.language == .v && node.is_method && node.name in ['+', '-', '*', '%', '/', '<', '=='] {
|
if node.language == .v && node.is_method
|
||||||
|
&& node.name in ['+', '-', '*', '%', '/', '<', '=='] {
|
||||||
if node.params.len != 2 {
|
if node.params.len != 2 {
|
||||||
c.error('operator methods should have exactly 1 argument', node.pos)
|
c.error('operator methods should have exactly 1 argument', node.pos)
|
||||||
} else {
|
} else {
|
||||||
|
@ -5817,6 +5819,7 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// TODO c.pref.is_vet
|
// TODO c.pref.is_vet
|
||||||
if node.language == .v && !node.is_method && node.params.len == 0
|
if node.language == .v && !node.is_method && node.params.len == 0
|
||||||
&& node.name.after('.').starts_with('test_') {
|
&& node.name.after('.').starts_with('test_') {
|
||||||
|
|
Loading…
Reference in New Issue