Global bug?

Archives Forums/BlitzMax Bug Reports/Global bug?

REDi(Posted 2009) [#1]
Global a%=1

Type test
	Global b%=a+10
EndType



BladeRunner(Posted 2009) [#2]
Using Superstrict it gives an Unknown identifier a, whereas it is no problem to use a in methods oder functions, so I would say it is a problem with the assignment of the value to the global type variable (field works, too).


Tommo(Posted 2009) [#3]
Try this code you'll see that the Code inside Type/EndType gets executed before Main block's execution.

superstrict
framework brl.standardio

global a% = sayHello("Main")

Type test
  global b% = sayHello("Test")
EndType


function sayHello(name$)
  print("Hello:	" + name)
End Function


That's why a% is not visibile in Type/EndType.


REDi(Posted 2009) [#4]
Yeah I can see why it happens, Just wondered if it could be worked around in the compiler, or if it was even intentional in the first place.


Tommo(Posted 2009) [#5]
No idea about the compiler side, should ask Marks.
This code is working, but it's not that clean... :)
framework brl.blitz
strict
 Global a% = 1

private
	function getA%()
		return a
	End Function
public

Type test
	Global b% = 10 + getA()
EndType

debuglog test.b