mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: add check for multi level fn aliases (#16361)
This commit is contained in:
parent
ce79c9c876
commit
7830597b66
@ -440,6 +440,10 @@ pub fn (mut c Checker) alias_type_decl(node ast.AliasTypeDecl) {
|
||||
node.type_pos)
|
||||
} else if typ_sym.kind == .chan {
|
||||
c.error('aliases of `chan` types are not allowed.', node.type_pos)
|
||||
} else if typ_sym.kind == .function {
|
||||
orig_sym := c.table.type_to_str(node.parent_type)
|
||||
c.error('type `$typ_sym.str()` is an alias, use the original alias type `$orig_sym` instead',
|
||||
node.type_pos)
|
||||
}
|
||||
}
|
||||
|
||||
|
4
vlib/v/checker/tests/nested_fn_alias_err.out
Normal file
4
vlib/v/checker/tests/nested_fn_alias_err.out
Normal file
@ -0,0 +1,4 @@
|
||||
vlib/v/checker/tests/nested_fn_alias_err.vv:2:12: error: type `Fn1` is an alias, use the original alias type `fn ()` instead
|
||||
1 | type Fn1 = fn ()
|
||||
2 | type Fn2 = Fn1
|
||||
| ~~~
|
2
vlib/v/checker/tests/nested_fn_alias_err.vv
Normal file
2
vlib/v/checker/tests/nested_fn_alias_err.vv
Normal file
@ -0,0 +1,2 @@
|
||||
type Fn1 = fn ()
|
||||
type Fn2 = Fn1
|
Loading…
Reference in New Issue
Block a user