Page 1 of 1

objb crashes because of syntax error

PostPosted: Sat Nov 06, 2010 10:24 am
by udo.killermann

while typing in the evening the compiler greeted me with the following message (no it was actually crash reporter):
objbCrash.jpg (26.86 KiB) Viewed 744 times

Here comes the offending code (I have marked the misbehaving statement).
Code: Select all
Declare Class "NSPredicate"
Declare Function "NSPredicate" - (NSString *)predicateFormat
Declare Function "NSPredicate" - (BOOL)evaluateWithObject:(id)object
Declare Function "NSPredicate" + (NSPredicate *)predicateWithFormat:(NSString *)predicateFormat
Declare Function "NSPredicate" + (NSPredicate *)predicateWithValue:(BOOL)value

Declare Function "NSMutableArray" - (NSArray *)filteredArrayUsingPredicate:(NSPredicate *)predicate

Dim tick As String(Character(39))
Dim myPred As NSPredicate = Nil
Dim predStr As String

Function filterArray(theArray As Array, Filter As String) As Array   
    predStr = Concat("SELF LIKE ", tick, Filter, tick)
    myPred = NSPredicate.predicateWithFormat( predStr)
End Function

Event AwakeFromNib()
   Dim myArray As NSMutableArray
   Dim resultArray As NSMutableArray
   myArray = Array("fest.o","","heike.o","")
   Alert(filterArray(myArray),"*.mm") ' this crashes the compiler
End Event

By just omitting an argument to a function the compiler gets in an unstable state. I didn't strip the example down, but hope you can spot the glitch.

I had to sleep over this in order to understand the root cause. It occurred before but I couldn't pin the problem.