parser: nothing can be cast to bool
parent
07e3699700
commit
5306c14d78
|
@ -516,9 +516,13 @@ fn (p mut Parser) cast(typ string) {
|
||||||
p.cgen.set_placeholder(pos, '*($typ*)(')
|
p.cgen.set_placeholder(pos, '*($typ*)(')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (is_number_type(expr_typ) || is_float_type(expr_typ)) && typ == 'bool' {
|
// Nothing can be cast to bool
|
||||||
p.error('cannot cast a number to `bool`')
|
if typ == 'bool' {
|
||||||
}
|
if is_number_type(expr_typ) || is_float_type(expr_typ) {
|
||||||
|
p.error('cannot cast a number to `bool`')
|
||||||
|
}
|
||||||
|
p.error('cannot cast `$expr_typ` to `bool`')
|
||||||
|
}
|
||||||
p.cgen.set_placeholder(pos, '($typ)(')
|
p.cgen.set_placeholder(pos, '($typ)(')
|
||||||
}
|
}
|
||||||
p.check(.rpar)
|
p.check(.rpar)
|
||||||
|
|
Loading…
Reference in New Issue