mirror of
https://github.com/irmen/prog8.git
synced 2024-11-22 15:33:02 +00:00
@(..) argument must be of type UWORD
This commit is contained in:
parent
4cc0dfa10b
commit
e6b158bc97
@ -1384,6 +1384,32 @@ internal class AstChecker(private val program: Program,
|
||||
super.visit(containment)
|
||||
}
|
||||
|
||||
override fun visit(memread: DirectMemoryRead) {
|
||||
if(!memread.addressExpression.inferType(program).istype(DataType.UWORD)) {
|
||||
errors.err("address for memory access isn't uword", memread.position)
|
||||
}
|
||||
val tc = memread.addressExpression as? TypecastExpression
|
||||
if(tc!=null && tc.implicit) {
|
||||
if(!tc.expression.inferType(program).istype(DataType.UWORD)) {
|
||||
errors.err("address for memory access isn't uword", memread.position)
|
||||
}
|
||||
}
|
||||
super.visit(memread)
|
||||
}
|
||||
|
||||
override fun visit(memwrite: DirectMemoryWrite) {
|
||||
if(!memwrite.addressExpression.inferType(program).istype(DataType.UWORD)) {
|
||||
errors.err("address for memory access isn't uword", memwrite.position)
|
||||
}
|
||||
val tc = memwrite.addressExpression as? TypecastExpression
|
||||
if(tc!=null && tc.implicit) {
|
||||
if(!tc.expression.inferType(program).istype(DataType.UWORD)) {
|
||||
errors.err("address for memory access isn't uword", memwrite.position)
|
||||
}
|
||||
}
|
||||
super.visit(memwrite)
|
||||
}
|
||||
|
||||
private fun checkFunctionOrLabelExists(target: IdentifierReference, statement: Statement): Statement? {
|
||||
when (val targetStatement = target.targetStatement(program)) {
|
||||
is Label, is Subroutine, is BuiltinFunctionPlaceholder -> return targetStatement
|
||||
|
@ -143,8 +143,9 @@ main {
|
||||
}"""
|
||||
val errors = ErrorReporterForTests()
|
||||
compileText(C64Target(), false, text, writeAssembly = true, errors = errors)
|
||||
errors.errors.size shouldBe 1
|
||||
errors.errors[0] shouldContain "undefined symbol: doesnotexist"
|
||||
errors.errors.size shouldBe 2
|
||||
errors.errors[0] shouldContain "isn't uword"
|
||||
errors.errors[1] shouldContain "undefined symbol: doesnotexist"
|
||||
}
|
||||
|
||||
test("shifting by word value is ok") {
|
||||
|
Loading…
Reference in New Issue
Block a user