mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: forbid aliasing an alias (#6118)
This commit is contained in:
parent
bf065674cc
commit
a02593204f
vlib/v/checker
@ -266,6 +266,10 @@ pub fn (mut c Checker) type_decl(node ast.TypeDecl) {
|
||||
typ_sym := c.table.get_type_symbol(node.parent_type)
|
||||
if typ_sym.kind == .placeholder {
|
||||
c.error("type `$typ_sym.name` doesn't exist", node.pos)
|
||||
} else if typ_sym.kind == .alias {
|
||||
orig_sym := c.table.get_type_symbol((typ_sym.info as table.Alias).parent_type)
|
||||
c.error('type `$typ_sym.name` is an alias, use the original alias type `$orig_sym.name` instead',
|
||||
node.pos)
|
||||
}
|
||||
}
|
||||
ast.FnTypeDecl {
|
||||
|
4
vlib/v/checker/tests/nested_aliases.out
Normal file
4
vlib/v/checker/tests/nested_aliases.out
Normal file
@ -0,0 +1,4 @@
|
||||
vlib/v/checker/tests/nested_aliases.v:2:1: error: type `MyInt` is an alias, use the original alias type `int` instead
|
||||
1 | type MyInt = int
|
||||
2 | type MyMyInt = MyInt
|
||||
| ~~~~~~~~~~~~
|
2
vlib/v/checker/tests/nested_aliases.vv
Normal file
2
vlib/v/checker/tests/nested_aliases.vv
Normal file
@ -0,0 +1,2 @@
|
||||
type MyInt = int
|
||||
type MyMyInt = MyInt
|
Loading…
Reference in New Issue
Block a user