mirror of
https://github.com/irmen/prog8.git
synced 2024-11-18 19:12:44 +00:00
don't crash but give proper error on "-X" expression where X is not a signed type
This commit is contained in:
parent
74456d1135
commit
4270c04856
@ -793,11 +793,10 @@ internal class AstChecker(private val program: Program,
|
||||
}
|
||||
|
||||
override fun visit(expr: PrefixExpression) {
|
||||
val idt = expr.inferType(program)
|
||||
if(!idt.isKnown)
|
||||
val dt = expr.expression.inferType(program).getOr(DataType.UNDEFINED)
|
||||
if(dt==DataType.UNDEFINED)
|
||||
return // any error should be reported elsewhere
|
||||
|
||||
val dt = idt.getOr(DataType.UNDEFINED)
|
||||
if(expr.operator=="-") {
|
||||
if (dt != DataType.BYTE && dt != DataType.WORD && dt != DataType.FLOAT) {
|
||||
errors.err("can only take negative of a signed number type", expr.position)
|
||||
|
Loading…
Reference in New Issue
Block a user