mirror of
https://github.com/irmen/prog8.git
synced 2024-11-18 19:12:44 +00:00
better error checking for wrong pop()
This commit is contained in:
parent
68b75fd558
commit
1b07637cc4
@ -994,9 +994,16 @@ internal class AstChecker(private val program: Program,
|
||||
}
|
||||
else if(funcName[0] in arrayOf("pop", "popw")) {
|
||||
// can only pop into a variable, that has to have the correct type
|
||||
val idref = functionCallStatement.args.singleOrNull() as? IdentifierReference
|
||||
if(idref==null)
|
||||
errors.err("invalid argument to pop, must be a variable with the correct type: ${functionCallStatement.args.first()}", functionCallStatement.args.first().position)
|
||||
val idref = functionCallStatement.args[0]
|
||||
if(idref !is IdentifierReference) {
|
||||
if(idref is TypecastExpression) {
|
||||
val passByRef = idref.expression.inferType(program).isPassByReference
|
||||
if(idref.type!=DataType.UWORD || !passByRef)
|
||||
errors.err("invalid argument to pop, must be a variable with the correct type: ${functionCallStatement.args.first()}", functionCallStatement.args.first().position)
|
||||
} else {
|
||||
errors.err("invalid argument to pop, must be a variable with the correct type: ${functionCallStatement.args.first()}", functionCallStatement.args.first().position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(funcName[0] in arrayOf("rol", "ror", "rol2", "ror2", "swap", "sort", "reverse")) {
|
||||
|
@ -1,14 +1,18 @@
|
||||
%import textio
|
||||
%import string
|
||||
%import test_stack
|
||||
|
||||
main {
|
||||
|
||||
ubyte[23] savedata
|
||||
ubyte[17] cargohold = 0
|
||||
uword filenameptr = $c000
|
||||
|
||||
sub start() {
|
||||
test_stack.test()
|
||||
|
||||
c64.SETNAM(string.length(filenameptr), filenameptr)
|
||||
|
||||
sys.memcopy(&savedata + 2, cargohold, len(cargohold))
|
||||
sys.memcopy(cargohold, &savedata + 2, len(cargohold))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user