1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: disallow interfaces inside sum types (#6232)

This commit is contained in:
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

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)
} }
} }
} }