mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix % type check
This commit is contained in:
@ -2521,10 +2521,11 @@ fn (p mut Parser) term() string {
|
|||||||
if (is_div || is_mod) && p.tok == .number && p.lit == '0' {
|
if (is_div || is_mod) && p.tok == .number && p.lit == '0' {
|
||||||
p.error('division or modulo by zero')
|
p.error('division or modulo by zero')
|
||||||
}
|
}
|
||||||
if is_mod && (is_float_type(typ) || !is_number_type(typ)) {
|
expr_type := p.unary()
|
||||||
p.error('operator .mod requires integer types')
|
p.check_types(expr_type, typ)
|
||||||
|
if is_mod && (!is_integer_type(expr_type) || !is_integer_type(typ)) {
|
||||||
|
p.error('operator % requires integer types')
|
||||||
}
|
}
|
||||||
p.check_types(p.unary(), typ)
|
|
||||||
}
|
}
|
||||||
return typ
|
return typ
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user