mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
Merge b00c8047e7
into 10df697d32
This commit is contained in:
commit
520a86dc95
@ -564,6 +564,9 @@ fn (mut c Checker) fn_type_decl(node ast.FnTypeDecl) {
|
||||
if ret_sym.kind == .placeholder {
|
||||
c.error('unknown type `${ret_sym.name}`', fn_info.return_type_pos)
|
||||
}
|
||||
if !node.typ.has_flag(.option) {
|
||||
c.warn('you should declare it as Option instead', node.type_pos)
|
||||
}
|
||||
for arg in fn_info.params {
|
||||
if !c.ensure_type_exists(arg.typ, arg.type_pos) {
|
||||
return
|
||||
|
@ -152,6 +152,17 @@ fn (mut c Checker) struct_decl(mut node ast.StructDecl) {
|
||||
c.error('cannot use Result type as map value type', field.type_pos)
|
||||
}
|
||||
}
|
||||
if sym.kind == .function {
|
||||
fn_info := sym.info as ast.FnType
|
||||
if !field.typ.has_flag(.option) {
|
||||
if fn_info.is_anon {
|
||||
c.warn('you should declare it as Option instead (?fn ...)', field.type_pos)
|
||||
} else {
|
||||
c.warn('this is not recommended, you should use Option function instead',
|
||||
field.type_pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if field.has_default_expr {
|
||||
c.expected_type = field.typ
|
||||
|
Loading…
Reference in New Issue
Block a user