checker: disallow interfaces inside sum types (#6232)

pull/6234/head
Xavier B 2020-08-27 02:33:59 -04:00 committed by GitHub
parent 8dcc73993e
commit 3e9dc578de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -293,6 +293,8 @@ pub fn (mut c Checker) type_decl(node ast.TypeDecl) {
typ_sym := c.table.get_type_symbol(typ) typ_sym := c.table.get_type_symbol(typ)
if typ_sym.kind == .placeholder { if typ_sym.kind == .placeholder {
c.error("type `$typ_sym.source_name` doesn't exist", node.pos) c.error("type `$typ_sym.source_name` doesn't exist", node.pos)
} else if typ_sym.kind == .interface_ {
c.error("sum type cannot hold an interface", node.pos)
} }
} }
} }