better error message

This commit is contained in:
Irmen de Jong 2020-08-22 17:12:09 +02:00
parent 20cdcc673b
commit c6e13ae2a3
3 changed files with 9 additions and 21 deletions

View File

@ -1039,7 +1039,10 @@ internal class AstChecker(private val program: Program,
val targetStatement = target.targetStatement(program.namespace)
if(targetStatement is Label || targetStatement is Subroutine || targetStatement is BuiltinFunctionStatementPlaceholder)
return targetStatement
errors.err("undefined function or subroutine: ${target.nameInSource.joinToString(".")}", statement.position)
else if(targetStatement==null)
errors.err("undefined function or subroutine: ${target.nameInSource.joinToString(".")}", statement.position)
else
errors.err("cannot call that: ${target.nameInSource.joinToString(".")}", statement.position)
return null
}

View File

@ -22,6 +22,9 @@ internal class AstIdentifiersChecker(private val program: Program, private val e
}
override fun visit(block: Block) {
if(block.name in CompilationTarget.machine.opcodeNames)
errors.err("can't use a cpu opcode name as a symbol: '${block.name}'", block.position)
val existing = blocks[block.name]
if(existing!=null)
nameError(block.name, block.position, existing)

View File

@ -10,28 +10,10 @@ main {
sub start() {
byte nop2
nop2=4
nop2++
foo.xxx()
derp:
goto main.nop2
main.nop2()
}
sub nop2 () {
c64.CHROUT('\n')
; nop2() ; better error
nop2()
}
}
foo {
sub xxx() {
bar:
goto bar
}
}