mirror of
https://github.com/irmen/prog8.git
synced 2024-11-22 00:31:56 +00:00
give better error when using @split wrong
This commit is contained in:
parent
ac1d4b4a7a
commit
fda8e61be4
@ -844,6 +844,11 @@ internal class AstChecker(private val program: Program,
|
||||
if(compilerOptions.zeropage==ZeropageType.DONTUSE && decl.zeropage == ZeropageWish.REQUIRE_ZEROPAGE)
|
||||
err("zeropage usage has been disabled by options")
|
||||
|
||||
if(decl.splitArray) {
|
||||
if (decl.datatype !in arrayOf(DataType.ARRAY_W, DataType.ARRAY_UW, DataType.ARRAY_W_SPLIT, DataType.ARRAY_UW_SPLIT)) {
|
||||
errors.err("split can only be used on word arrays", decl.position)
|
||||
}
|
||||
}
|
||||
super.visit(decl)
|
||||
}
|
||||
|
||||
|
@ -688,7 +688,7 @@ private fun VardeclContext.toAst(type: VarDeclType, value: Expression?): VarDecl
|
||||
when(arrayDt) {
|
||||
DataType.ARRAY_UW -> DataType.ARRAY_UW_SPLIT
|
||||
DataType.ARRAY_W -> DataType.ARRAY_W_SPLIT
|
||||
else -> throw SyntaxError("split can only be used on word arrays", toPosition())
|
||||
else -> arrayDt // type error will be generated later in the ast check
|
||||
}
|
||||
} else arrayDt
|
||||
} else origDt
|
||||
|
@ -231,11 +231,6 @@ class VarDecl(val type: VarDeclType,
|
||||
override lateinit var parent: Node
|
||||
var allowInitializeWithZero = true
|
||||
|
||||
init {
|
||||
if(splitArray)
|
||||
require(datatype in ArrayDatatypes) { "array dt mismatch" }
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var autoHeapValueSequenceNumber = 0
|
||||
|
||||
|
@ -2,8 +2,14 @@
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
repeat cx16.r0 {
|
||||
cx16.r1L++
|
||||
}
|
||||
bool @split bb
|
||||
ubyte @split bt
|
||||
byte[200] @split ba
|
||||
float @split fl
|
||||
float[10] @split fla
|
||||
|
||||
bb=true
|
||||
bt++
|
||||
fl++
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user