From 4270c048562e5afa5e6752cb88dfba095f0c2b2b Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 6 Nov 2021 18:06:01 +0100 Subject: [PATCH] don't crash but give proper error on "-X" expression where X is not a signed type --- compiler/src/prog8/compiler/astprocessing/AstChecker.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index 1feda02f3..31aa9172e 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -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)