parser: fix mod type check

pull/2665/head
Alexander Medvednikov 2019-11-06 17:52:35 +03:00
parent ca259331e4
commit 6afd7d50a6
1 changed files with 7 additions and 4 deletions

View File

@ -2522,9 +2522,12 @@ fn (p mut Parser) term() string {
p.error('division or modulo by zero')
}
expr_type := p.unary()
if is_mod {
if !(is_integer_type(expr_type) && is_integer_type(typ)) {
p.error('operator `mod` requires integer types')
}
} else {
p.check_types(expr_type, typ)
if is_mod && (!is_integer_type(expr_type) || !is_integer_type(typ)) {
p.error('operator % requires integer types')
}
}
return typ