BASIC compiler bug

Questions about the BASICtools and MakeItC
Post Reply
YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

BASIC compiler bug

Post by YahooArchive »

Greets,

I ran into something strange, the compiler reports ENDIF without a corresponding
IF error, though I am *certain* that IF's and ENDIF's are correctly paired. (I
fixed-up the syntax differences and ran it through the VBS interpreter, so yes,
absolutely certain.)

When I comment the ENDIF line it compiles but chokes with:

FaultISR 0xFFFFFFF9
Undefined instruction fault

when I try to run it.

The board is a SuperPro, ARMbasic Kernel[8.06], compiler version 8.06f.

I boiled it down to a short repro:

----------------


#include
#include

DIM OutBuf(255) AS String
DIM LoginPhase As Integer
Dim IsLoggingIn As integer

Sub SendSerial
End Sub

Sub CompilerError

If (LoginPhase = 1) then
IsLoggingIn = 1
Print "login phase 1"
OutBuf(0) = "login"
SendSerial
' compiler error if the line below isn't commented
'End If
End Sub

MAIN:

CompilerError

----------------

Weird, yeah? It's not a big deal, I accomplished what I was trying to do....
just thought you'd want to see this.


-MM



YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: BASIC compiler bug

Post by YahooArchive »

There is a bug in the compiler, but its in the error reporting

The line OutBuf(0) = "login"
should be OutBuf = "login"

You can't assign a string to a byte.

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: BASIC compiler bug

Post by YahooArchive »

D'oh! I knew that. :-) I took the time to isolate it to a few lines of code,
but didn't bother re-reading those few lines carefully... took the compiler at
it's word -- but to my credit, I did go the extra mile to make sure there was no
IF block structure problem.

Just thinking off the top of my head... a type mismatch error would've been
considerably more intuitive. :-)


-MM

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: BASIC compiler bug

Post by YahooArchive »

I appreciate the effort, it made it easy to find the error.

Version 8.08a of the compiler that fixes it has been uploaded to the files
section here. It will get into the standard release in a week or so.

Post Reply