expecting compile error or correct value

Archives Forums/BlitzMax Bug Reports/expecting compile error or correct value

col(Posted 2014) [#1]
I know you shouldn't really use variables that are declared further down in your code but this should either flag up as an unknown variable, or if not then give the correct value.

Myself... I think and unknown variable error should be flagged during compilation.

Strict

Type test
	Field x = z
	Field y
	Field z = 10
EndType

Local t:test = New test
Print t.x



GfK(Posted 2014) [#2]
Yes, it probably should. This works perfectly.

Strict

Type test
	Field z = 10
	Field x = z
	Field y
EndType

Local t:test = New test

Print t.x


That said, it's pretty bad practice - you'd normally want to be doing that kind of stuff in a constructor.


col(Posted 2014) [#3]
you'd normally want to be doing that kind of stuff in a constructor


For sure.

Features of the language are features - variable initialisers should and do work correctly and as expected in all other cases ( including erroring out on unknown variables that are declared further down ).

Cheers for confirming the error.