mirror of
https://github.com/irmen/prog8.git
synced 2024-09-09 02:54:28 +00:00
fix type error with returning an array from a subroutine returning uword
This commit is contained in:
parent
0db141eeac
commit
f570b70827
@ -114,6 +114,8 @@ internal class AstChecker(private val program: Program,
|
|||||||
if (returnValue == null || returnValue.type != DataType.UBYTE || (returnValue.number!=0.0 && returnValue.number!=1.0)) {
|
if (returnValue == null || returnValue.type != DataType.UBYTE || (returnValue.number!=0.0 && returnValue.number!=1.0)) {
|
||||||
errors.err("type $valueDt of return value doesn't match subroutine's return type ${expectedReturnValues[0]}",returnStmt.value!!.position)
|
errors.err("type $valueDt of return value doesn't match subroutine's return type ${expectedReturnValues[0]}",returnStmt.value!!.position)
|
||||||
}
|
}
|
||||||
|
} else if(valueDt.isIterable && expectedReturnValues[0]==DataType.UWORD) {
|
||||||
|
// you can return a string or array when a uword (pointer) is returned
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
errors.err("type $valueDt of return value doesn't match subroutine's return type ${expectedReturnValues[0]}",returnStmt.value!!.position)
|
errors.err("type $valueDt of return value doesn't match subroutine's return type ${expectedReturnValues[0]}",returnStmt.value!!.position)
|
||||||
|
@ -320,5 +320,19 @@ other {
|
|||||||
|
|
||||||
compileText(VMTarget(), optimize=false, src, writeAssembly=false) shouldNotBe null
|
compileText(VMTarget(), optimize=false, src, writeAssembly=false) shouldNotBe null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("returning array as uword") {
|
||||||
|
val src = """
|
||||||
|
main {
|
||||||
|
sub start() {
|
||||||
|
cx16.r0 = getarray()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub getarray() -> uword {
|
||||||
|
return [11,22,33]
|
||||||
|
}
|
||||||
|
}"""
|
||||||
|
compileText(VMTarget(), optimize=false, src, writeAssembly=false) shouldNotBe null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
- fix type error with returning an array literal from a subroutine returning uword
|
|
||||||
- fix IR loading of romsubs
|
- fix IR loading of romsubs
|
||||||
romsub $FFD2 = chrout(ubyte ch @ A)
|
romsub $FFD2 = chrout(ubyte ch @ A)
|
||||||
sub start() {
|
sub start() {
|
||||||
|
Loading…
Reference in New Issue
Block a user