From ca259331e4e75dda3b93b7d8d46844707825f751 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 6 Nov 2019 17:35:32 +0300 Subject: [PATCH] parser: fix % type check --- vlib/compiler/parser.v | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vlib/compiler/parser.v b/vlib/compiler/parser.v index 4337dd3231..d22c31fff3 100644 --- a/vlib/compiler/parser.v +++ b/vlib/compiler/parser.v @@ -2521,10 +2521,11 @@ fn (p mut Parser) term() string { if (is_div || is_mod) && p.tok == .number && p.lit == '0' { p.error('division or modulo by zero') } - if is_mod && (is_float_type(typ) || !is_number_type(typ)) { - p.error('operator .mod requires integer types') + 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') } - p.check_types(p.unary(), typ) } return typ }