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

parser: fix mod type check

This commit is contained in:
Alexander Medvednikov 2019-11-06 17:52:35 +03:00
parent ca259331e4
commit 6afd7d50a6

View File

@ -2522,10 +2522,13 @@ fn (p mut Parser) term() string {
p.error('division or modulo by zero')
}
expr_type := p.unary()
p.check_types(expr_type, typ)
if is_mod && (!is_integer_type(expr_type) || !is_integer_type(typ)) {
p.error('operator % requires integer types')
}
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)
}
}
return typ
}