mirror of
https://github.com/irmen/prog8.git
synced 2024-09-07 19:54:26 +00:00
fix compiler crash: if uwordvar > label
This commit is contained in:
parent
0d0ce6eec1
commit
d8409a9d2b
@ -509,7 +509,7 @@ internal class AstChecker(private val program: Program,
|
|||||||
val sourceDatatype = assignment.value.inferType(program)
|
val sourceDatatype = assignment.value.inferType(program)
|
||||||
if (sourceDatatype.isUnknown) {
|
if (sourceDatatype.isUnknown) {
|
||||||
if (assignment.value !is FunctionCallExpression)
|
if (assignment.value !is FunctionCallExpression)
|
||||||
errors.err("assignment value is invalid or has no proper datatype, maybe forgot '&' (address-of)", assignment.value.position)
|
errors.err("invalid assignment value, maybe forgot '&' (address-of)", assignment.value.position)
|
||||||
} else {
|
} else {
|
||||||
checkAssignmentCompatible(targetDatatype.getOr(DataType.UNDEFINED),
|
checkAssignmentCompatible(targetDatatype.getOr(DataType.UNDEFINED),
|
||||||
sourceDatatype.getOr(DataType.UNDEFINED), assignment.value)
|
sourceDatatype.getOr(DataType.UNDEFINED), assignment.value)
|
||||||
@ -843,8 +843,15 @@ internal class AstChecker(private val program: Program,
|
|||||||
|
|
||||||
val leftIDt = expr.left.inferType(program)
|
val leftIDt = expr.left.inferType(program)
|
||||||
val rightIDt = expr.right.inferType(program)
|
val rightIDt = expr.right.inferType(program)
|
||||||
if(!leftIDt.isKnown || !rightIDt.isKnown)
|
if(!leftIDt.isKnown || !rightIDt.isKnown) {
|
||||||
|
// check if maybe one of the operands is a label, this would need a '&'
|
||||||
|
if (!leftIDt.isKnown && expr.left !is FunctionCallExpression)
|
||||||
|
errors.err("invalid operand, maybe forgot '&' (address-of)", expr.left.position)
|
||||||
|
if (!rightIDt.isKnown && expr.right !is FunctionCallExpression)
|
||||||
|
errors.err("invalid operand, maybe forgot '&' (address-of)", expr.right.position)
|
||||||
|
|
||||||
return // hopefully this error will be detected elsewhere
|
return // hopefully this error will be detected elsewhere
|
||||||
|
}
|
||||||
|
|
||||||
val leftDt = leftIDt.getOr(DataType.UNDEFINED)
|
val leftDt = leftIDt.getOr(DataType.UNDEFINED)
|
||||||
val rightDt = rightIDt.getOr(DataType.UNDEFINED)
|
val rightDt = rightIDt.getOr(DataType.UNDEFINED)
|
||||||
|
@ -52,8 +52,8 @@ class TestAstChecks: FunSpec({
|
|||||||
compileText(C64Target(), true, text, writeAssembly = true, errors=errors) shouldBe null
|
compileText(C64Target(), true, text, writeAssembly = true, errors=errors) shouldBe null
|
||||||
errors.errors.size shouldBe 2
|
errors.errors.size shouldBe 2
|
||||||
errors.warnings.size shouldBe 0
|
errors.warnings.size shouldBe 0
|
||||||
errors.errors[0] shouldContain ":7:28: assignment value is invalid"
|
errors.errors[0] shouldContain ":7:28: invalid assignment value, maybe forgot '&'"
|
||||||
errors.errors[1] shouldContain ":8:28: assignment value is invalid"
|
errors.errors[1] shouldContain ":8:28: invalid assignment value, maybe forgot '&'"
|
||||||
}
|
}
|
||||||
|
|
||||||
test("can't do str or array expression without using address-of") {
|
test("can't do str or array expression without using address-of") {
|
||||||
|
Loading…
Reference in New Issue
Block a user