mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: add check for unknown generic types in type alias decl (#16377)
This commit is contained in:
parent
2634b99769
commit
bbd0603b41
|
@ -444,6 +444,16 @@ pub fn (mut c Checker) alias_type_decl(node ast.AliasTypeDecl) {
|
|||
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)
|
||||
} else if typ_sym.kind == .struct_ {
|
||||
if mut typ_sym.info is ast.Struct {
|
||||
// check if the generic param types have been defined
|
||||
for ct in typ_sym.info.concrete_types {
|
||||
ct_sym := c.table.sym(ct)
|
||||
if ct_sym.kind == .placeholder {
|
||||
c.error('unknown type `$ct_sym.name`', node.type_pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
vlib/v/checker/tests/type_alias_struct_generic_unknown_name_err.vv:7:16: error: unknown type `UnknownType`
|
||||
5 | }
|
||||
6 |
|
||||
7 | type NewType = Foo<UnknownType>
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
8 |
|
||||
9 | fn main() {
|
|
@ -0,0 +1,10 @@
|
|||
module main
|
||||
|
||||
struct Foo<T> {
|
||||
value T
|
||||
}
|
||||
|
||||
type NewType = Foo<UnknownType>
|
||||
|
||||
fn main() {
|
||||
}
|
Loading…
Reference in New Issue
Block a user