parser: disable generic type aliases (#10917)

pull/10939/head
shadow 2021-07-22 18:17:16 -04:00 committed by GitHub
parent 2c0c211c79
commit fe5e3c452f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View File

@ -3107,6 +3107,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
}
mut sum_variants := []ast.TypeNode{}
generic_types := p.parse_generic_type_list()
decl_pos_with_generics := decl_pos.extend(p.prev_tok.position())
p.check(.assign)
mut type_pos := p.tok.position()
mut comments := []ast.Comment{}
@ -3179,6 +3180,10 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
}
}
// type MyType = int
if generic_types.len > 0 {
p.error_with_pos('generic type aliases are not yet implemented', decl_pos_with_generics)
return ast.AliasTypeDecl{}
}
parent_type := first_type
parent_sym := p.table.get_type_symbol(parent_type)
pidx := parent_type.idx()

View File

@ -0,0 +1,3 @@
vlib/v/parser/tests/generic_type_alias_decl.vv:1:1: error: generic type aliases are not yet implemented
1 | type Pointer<T> = &T
| ~~~~~~~~~~~~~~~

View File

@ -0,0 +1 @@
type Pointer<T> = &T