parser: do not allow `1 % 0`

pull/1572/head
Alexander Medvednikov 2019-08-11 14:47:34 +03:00
parent 02ea168f71
commit 72a7eb6e35
1 changed files with 1 additions and 1 deletions

View File

@ -2226,7 +2226,7 @@ fn (p mut Parser) term() string {
p.next()
p.gen(tok.str())// + ' /*op2*/ ')
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')
}
if is_mod && (is_float_type(typ) || !is_number_type(typ)) {