mirror of
https://github.com/irmen/prog8.git
synced 2025-02-16 07:31:48 +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)
|
if(compilerOptions.zeropage==ZeropageType.DONTUSE && decl.zeropage == ZeropageWish.REQUIRE_ZEROPAGE)
|
||||||
err("zeropage usage has been disabled by options")
|
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)
|
super.visit(decl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,7 +688,7 @@ private fun VardeclContext.toAst(type: VarDeclType, value: Expression?): VarDecl
|
|||||||
when(arrayDt) {
|
when(arrayDt) {
|
||||||
DataType.ARRAY_UW -> DataType.ARRAY_UW_SPLIT
|
DataType.ARRAY_UW -> DataType.ARRAY_UW_SPLIT
|
||||||
DataType.ARRAY_W -> DataType.ARRAY_W_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 arrayDt
|
||||||
} else origDt
|
} else origDt
|
||||||
|
@ -231,11 +231,6 @@ class VarDecl(val type: VarDeclType,
|
|||||||
override lateinit var parent: Node
|
override lateinit var parent: Node
|
||||||
var allowInitializeWithZero = true
|
var allowInitializeWithZero = true
|
||||||
|
|
||||||
init {
|
|
||||||
if(splitArray)
|
|
||||||
require(datatype in ArrayDatatypes) { "array dt mismatch" }
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private var autoHeapValueSequenceNumber = 0
|
private var autoHeapValueSequenceNumber = 0
|
||||||
|
|
||||||
|
@ -2,8 +2,14 @@
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
repeat cx16.r0 {
|
bool @split bb
|
||||||
cx16.r1L++
|
ubyte @split bt
|
||||||
}
|
byte[200] @split ba
|
||||||
|
float @split fl
|
||||||
|
float[10] @split fla
|
||||||
|
|
||||||
|
bb=true
|
||||||
|
bt++
|
||||||
|
fl++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user