checker: forbid aliasing an alias (#6118)
parent
bf065674cc
commit
a02593204f
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
| ~~~~~~~~~~~~
|
|
@ -0,0 +1,2 @@
|
|||
type MyInt = int
|
||||
type MyMyInt = MyInt
|
Loading…
Reference in New Issue