mirror of
https://github.com/irmen/prog8.git
synced 2024-07-09 17:29:46 +00:00
improve error message
This commit is contained in:
parent
ee5c94f6db
commit
5407429ec0
@ -1318,14 +1318,15 @@ internal class AstChecker(private val program: Program,
|
||||
val whenStmt = whenChoice.parent as When
|
||||
if(whenChoice.values!=null) {
|
||||
val conditionType = whenStmt.condition.inferType(program)
|
||||
if(!conditionType.isKnown)
|
||||
throw FatalAstException("can't determine when choice datatype $whenChoice")
|
||||
val constvalues = whenChoice.values!!.map { it.constValue(program) }
|
||||
for(constvalue in constvalues) {
|
||||
when {
|
||||
constvalue == null -> errors.err("choice value must be a constant", whenChoice.position)
|
||||
constvalue.type !in IntegerDatatypes -> errors.err("choice value must be a byte or word", whenChoice.position)
|
||||
conditionType isnot constvalue.type -> errors.err("choice value datatype differs from condition value", whenChoice.position)
|
||||
conditionType isnot constvalue.type -> {
|
||||
if(conditionType.isKnown)
|
||||
errors.err("choice value datatype differs from condition value", whenChoice.position)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user