diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 7d8a8eea89..10ae77d37a 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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 { diff --git a/vlib/v/checker/tests/nested_aliases.out b/vlib/v/checker/tests/nested_aliases.out new file mode 100644 index 0000000000..de0853b916 --- /dev/null +++ b/vlib/v/checker/tests/nested_aliases.out @@ -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 + | ~~~~~~~~~~~~ diff --git a/vlib/v/checker/tests/nested_aliases.vv b/vlib/v/checker/tests/nested_aliases.vv new file mode 100644 index 0000000000..a21d0d365e --- /dev/null +++ b/vlib/v/checker/tests/nested_aliases.vv @@ -0,0 +1,2 @@ +type MyInt = int +type MyMyInt = MyInt