parser: do not allow number => bool casts
parent
883041fbcc
commit
07e3699700
|
@ -516,6 +516,9 @@ fn (p mut Parser) cast(typ string) {
|
|||
p.cgen.set_placeholder(pos, '*($typ*)(')
|
||||
}
|
||||
else {
|
||||
if (is_number_type(expr_typ) || is_float_type(expr_typ)) && typ == 'bool' {
|
||||
p.error('cannot cast a number to `bool`')
|
||||
}
|
||||
p.cgen.set_placeholder(pos, '($typ)(')
|
||||
}
|
||||
p.check(.rpar)
|
||||
|
|
Loading…
Reference in New Issue