Strange problem. Help!

BlitzMax Forums/BlitzMax Programming/Strange problem. Help!

Im having strange problems with my latest project.
Everything was working up until an hour ago where i only did a recompile without changing any major code (im 99% sure).

And suddenly it starts to skip method calls in Release mode, and throw memory exceptions in debug mode.

I havent been able to reproduce it with a smaller sample im afraid.

As far as i can tell, this is the offending code:
Method FindRule:TParserElement( name:String)
	Print "** FindRule()"
	For Local r:TParserElement = EachIn Rules
		Print "** comparing " + r.Name + " == " + name
		If r.IsRule And (r.Name = name) Then Return r
	Next
EndMethod
	
Method Generate( stream:TStream)
	Function GenerateCharSearch( r:TParserElement)
		Select r.Tag
			Case PE_RULE
				Print "** looking up " + r.Value
				Local rule:TParserElement = FindRule( r.Value)			<---------
				If rule Then
					Print "** found " + r.Value
					Return GenerateCharSearch(rule)
				Else
					Throw "ERROR: undefined rule '" + r.Value + "'"
				EndIf
	.....


** looking up XXX is printed but but nothing else, not even whats inside FindRule()
and the "return" is allways null

Any pointers? im going crazy soon :(

EDIT: is there a limit to how many functions inside a method? or how big they are?

I may have found the reason for it, it seems the method call from a function within a method returns bogus results.

could someone else test this plese?
Type TThing
	Field Index:Int
	
	Function Create:TThing( index:Int)
		Local t:TThing = New TThing
		t.Index = index
		Return t
	EndFunction
EndType

Type TTest
	Field List:TList = New TList
	
	Method Find:TThing( index:Int)
		For Local t:TThing = EachIn List
			If t.Index = index Then Return t
		Next
		Return Null
	EndMethod
	
	Method Test()
		Function Search()
			Local t:TThing = Find( 1)
			If t Then 
				Print t.Index
			Else
				Print "nope"
			EndIf
		EndFunction
		Search()
	EndMethod
EndType

Local test:TTest = New TTest
test.List.AddLast( TThing.Create(0))
test.List.AddLast( TThing.Create(1))
test.List.AddLast( TThing.Create(2))
test.Test()


it should print 1 but it prints 2 in release mode and throws a memory exception in debug mode.

Nesting functions do not maitain scope to self as far as I know and although it compiles I think its producing crap.

Doug Stastny

Bummer, i thougt that was the whole point of nested functions :/

Nesting functions do not maitain scope to self
YEah that's correct and it is a bummer too, you can do that in delphi you see...