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

parser: do not allow 1 % 0

This commit is contained in:
Alexander Medvednikov 2019-08-11 14:47:34 +03:00
parent 02ea168f71
commit 72a7eb6e35

View File

@ -2226,7 +2226,7 @@ fn (p mut Parser) term() string {
p.next() p.next()
p.gen(tok.str())// + ' /*op2*/ ') p.gen(tok.str())// + ' /*op2*/ ')
p.fgen(' ' + tok.str() + ' ') p.fgen(' ' + tok.str() + ' ')
if is_div && p.tok == .number && p.lit == '0' { if (is_div || is_mod) && p.tok == .number && p.lit == '0' {
p.error('division by zero') p.error('division by zero')
} }
if is_mod && (is_float_type(typ) || !is_number_type(typ)) { if is_mod && (is_float_type(typ) || !is_number_type(typ)) {