checker: fix the alias check

pull/5483/head
Alexander Medvednikov 2020-06-24 16:52:23 +02:00
parent 9df29d0dd2
commit 4b0e606ae8
1 changed files with 5 additions and 2 deletions

View File

@ -344,8 +344,11 @@ pub fn (mut c Checker) struct_init(mut struct_init ast.StructInit) table.Type {
c.error('cannot instantiate interface `$type_sym.name`', struct_init.pos) c.error('cannot instantiate interface `$type_sym.name`', struct_init.pos)
} }
if type_sym.kind == .alias { if type_sym.kind == .alias {
c.error('cannot instantiate type alias `$type_sym.name`', struct_init.pos) info := type_sym.info as table.Alias
return table.void_type if info.parent_typ.is_number() {
c.error('cannot instantiate number type alias `$type_sym.name`', struct_init.pos)
return table.void_type
}
} }
if !type_sym.is_public && type_sym.kind != .placeholder && type_sym.mod != c.mod { if !type_sym.is_public && type_sym.kind != .placeholder && type_sym.mod != c.mod {
c.error('type `$type_sym.name` is private', struct_init.pos) c.error('type `$type_sym.name` is private', struct_init.pos)