parser: fix mod assign type check

pull/2687/head
Daren Liang 2019-11-07 09:49:40 -05:00 committed by Alexander Medvednikov
parent fbd71e1539
commit df6bdf59e6
1 changed files with 8 additions and 0 deletions

View File

@ -1296,6 +1296,14 @@ fn ($v.name mut $v.typ) $p.cur_fn.name (...) {
p.error_with_token_index( 'cannot use non-integer type `$expr_type` as shift argument', errtok) p.error_with_token_index( 'cannot use non-integer type `$expr_type` as shift argument', errtok)
} }
} }
else if tok == .mod_assign {
if !is_integer_type(p.assigned_type) {
p.error_with_token_index( 'cannot use modulo operator on non-integer type `$p.assigned_type`', errtok)
}
if !is_integer_type(expr_type) {
p.error_with_token_index( 'cannot use non-integer type `$expr_type` as modulo argument', errtok)
}
}
else if !p.builtin_mod && !p.check_types_no_throw(expr_type, p.assigned_type) { else if !p.builtin_mod && !p.check_types_no_throw(expr_type, p.assigned_type) {
p.error_with_token_index( 'cannot use type `$expr_type` as type `$p.assigned_type` in assignment', errtok) p.error_with_token_index( 'cannot use type `$expr_type` as type `$p.assigned_type` in assignment', errtok)
} }