The code that should not compile, but does

Archives Forums/BlitzMax Bug Reports/The code that should not compile, but does

JoshK(Posted 2009) [#1]
The thing[] array should be inaccessible outside of the if statement.
Local a=1

If a=1
	Local thing:String[4]
	thing[0]="sometext"
	Print "OK..."
EndIf

Print thing[0]+"!"



plash(Posted 2009) [#2]
Incorrect. That is the behavior of non-Strict/non-SuperStrict.

Try this, for example:
SuperStrict ' Or Strict

Local a:Int = 1

If a=1
	Local thing:String[4]
	thing[0]="sometext"
	Print "OK..."
End If

Print thing[0]+"!"



Brucey(Posted 2009) [#3]
Tut tut... who's still not using (at least) Strict ? :-p


_Skully(Posted 2009) [#4]
Leadwerks,

I didn't run did it?


Warpy(Posted 2009) [#5]
I never ever use Strict.


plash(Posted 2009) [#6]
I never ever use Strict or non strict ;)


JoshK(Posted 2009) [#7]
Nevermind, I found a separate error; my variable was declared twice.


Ked(Posted 2009) [#8]
Regardless, you should be using Strict, if not SuperStrict.


Brucey(Posted 2009) [#9]
Nevermind, I found a separate error; my variable was declared twice.

Interestingly, you can't do that in NON-strict, but can in Strict :-)

Good :
SuperStrict

Local a:Int

For Local i:Int = 0 To 10

	Local a:Int

Next


Bad :
Local a:Int

For Local i:Int = 0 To 10

	Local a:Int

Next

... because in non-strict, there's no "local scope", as such.

:-p