fix multiple type parameters

pull/3173/head
joe-conigliaro 2019-12-21 17:54:43 +11:00 committed by Alexander Medvednikov
parent f7c1b78ec2
commit 6763a92834
1 changed files with 4 additions and 9 deletions

View File

@ -44,20 +44,15 @@ fn (p mut Parser) struct_decl(generic_param_types []string) {
mut is_generic := false mut is_generic := false
if p.tok == .lt { if p.tok == .lt {
p.check(.lt) p.check(.lt)
mut i := 0 for i := 0; ; i++ {
for { if generic_param_types.len > 0 && i > generic_param_types.len-1 {
if generic_param_types.len > 0 && i != generic_param_types.len-1 {
p.error('mismatched generic type params') p.error('mismatched generic type params')
} }
type_param := p.check_name() type_param := p.check_name()
if generic_param_types.len > 0 { generic_types[type_param] = if generic_param_types.len > 0 {
generic_types[type_param] = generic_param_types[i] generic_param_types[i] } else { '' }
} else {
generic_types[type_param] = ''
}
if p.tok != .comma { break } if p.tok != .comma { break }
p.check(.comma) p.check(.comma)
i++
} }
p.check(.gt) p.check(.gt)
is_generic = true is_generic = true