mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fix
This commit is contained in:
parent
100f441e3f
commit
b00c8047e7
@ -553,6 +553,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 {
|
||||
c.ensure_type_exists(arg.typ, arg.type_pos) or { return }
|
||||
arg_sym := c.table.sym(arg.typ)
|
||||
|
@ -137,9 +137,13 @@ fn (mut c Checker) struct_decl(mut node ast.StructDecl) {
|
||||
}
|
||||
if sym.kind == .function {
|
||||
fn_info := sym.info as ast.FnType
|
||||
if !field.typ.has_flag(.option) && fn_info.is_anon {
|
||||
c.warn('direct function declaration is not recommended, use Option instead (?fn ...)',
|
||||
field.type_pos)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user