mirror of
https://github.com/irmen/prog8.git
synced 2025-01-12 04:30:03 +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)) {
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
====
|
||||
|
||||
- fix type error with returning an array literal from a subroutine returning uword
|
||||
- fix IR loading of romsubs
|
||||
romsub $FFD2 = chrout(ubyte ch @ A)
|
||||
sub start() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user