mirror of
https://github.com/irmen/prog8.git
synced 2024-11-18 19:12:44 +00:00
fixed compiler crash: when passing the name of a subroutine instead of an array or string to an UWORD parameter
now allows taking the address of a subroutine &routine
This commit is contained in:
parent
106fc5daa4
commit
8a504f8eee
@ -455,15 +455,12 @@ internal class AstChecker(private val program: Program,
|
||||
|
||||
override fun visit(addressOf: AddressOf) {
|
||||
val variable=addressOf.identifier.targetVarDecl(program.namespace)
|
||||
if(variable==null)
|
||||
errors.err("pointer-of operand must be the name of a heap variable", addressOf.position)
|
||||
else {
|
||||
if(variable.datatype !in ArrayDatatypes
|
||||
&& variable.type!=VarDeclType.MEMORY
|
||||
&& variable.struct == null
|
||||
&& variable.datatype != DataType.STR && variable.datatype!=DataType.STRUCT)
|
||||
if(variable!=null
|
||||
&& variable.datatype !in ArrayDatatypes
|
||||
&& variable.type!=VarDeclType.MEMORY
|
||||
&& variable.struct == null
|
||||
&& variable.datatype != DataType.STR && variable.datatype!=DataType.STRUCT)
|
||||
errors.err("invalid pointer-of operand type", addressOf.position)
|
||||
}
|
||||
super.visit(addressOf)
|
||||
}
|
||||
|
||||
|
@ -41,8 +41,9 @@ class VerifyFunctionArgTypes(val program: Program) : IAstVisitor {
|
||||
|
||||
fun checkTypes(call: IFunctionCall, scope: INameScope, program: Program): String? {
|
||||
val argITypes = call.args.map { it.inferType(program) }
|
||||
if(argITypes.any { !it.isKnown })
|
||||
throw FatalAstException("unknown dt")
|
||||
val firstUnknownDt = argITypes.indexOfFirst { it.isUnknown }
|
||||
if(firstUnknownDt>=0)
|
||||
return "argument ${firstUnknownDt+1} invalid argument type"
|
||||
val argtypes = argITypes.map { it.typeOrElse(DataType.STRUCT) }
|
||||
val target = call.target.targetStatement(scope)
|
||||
if (target is Subroutine) {
|
||||
|
@ -8,12 +8,6 @@
|
||||
errors {
|
||||
sub tofix() {
|
||||
|
||||
; TODO fix compiler crash: when passing the name of a subroutine instead of an array or string to an UWORD parameter
|
||||
|
||||
; TODO allow taking the address of a subroutine &routine
|
||||
|
||||
|
||||
|
||||
while c64.CHRIN() {
|
||||
; TODO: the loop condition isn't properly tested because a ldx is in the way before the beq
|
||||
}
|
||||
@ -46,7 +40,12 @@ errors {
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
|
||||
function(&start)
|
||||
test_stack.test()
|
||||
}
|
||||
|
||||
sub function(uword param) {
|
||||
txt.print_uwhex(param, 1)
|
||||
param++
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user