mirror of
https://github.com/irmen/prog8.git
synced 2024-10-17 10:24:55 +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
|
val whenStmt = whenChoice.parent as When
|
||||||
if(whenChoice.values!=null) {
|
if(whenChoice.values!=null) {
|
||||||
val conditionType = whenStmt.condition.inferType(program)
|
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) }
|
val constvalues = whenChoice.values!!.map { it.constValue(program) }
|
||||||
for(constvalue in constvalues) {
|
for(constvalue in constvalues) {
|
||||||
when {
|
when {
|
||||||
constvalue == null -> errors.err("choice value must be a constant", whenChoice.position)
|
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)
|
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 {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user