checker: fix false positives for sumtype kind of matches

pull/4422/head
Delyan Angelov 2020-04-16 00:32:56 +03:00
parent 6a186e8f11
commit 92129d760d
1 changed files with 3 additions and 0 deletions

View File

@ -1353,6 +1353,9 @@ pub fn (c mut Checker) match_expr(node mut ast.MatchExpr) table.Type {
c.error('match 0 cond type', node.pos)
}
type_sym := c.table.get_type_symbol(cond_type)
if type_sym.kind != .sum_type {
node.is_sum_type = false
}
// all_possible_left_subtypes is a histogram of
// type => how many times it was used in the match
mut all_possible_left_subtypes := map[string]int