Declaring Local and Global in a function

BlitzMax Forums/BlitzMax Programming/Declaring Local and Global in a function

What mark means is that this is a bug:

Type TTest
   field name:String

   method myName:string()
      return name
   end method

   function Test()
      print myName()
   end function
end Type

local test:TTest = new TTest
test.Test()


Reason: Function has no self, so calling myName is done on Null which logically can't work, but currently does due to a compiler error.
The correct code that is not bugged would look like this:


Type TTest
   field name:String

   method myName:string()
      return name
   end method

   function Test(obj:TTest)
      print obj.myName()
   end function
end Type

local test:TTest = new TTest
TTest.Test(test)


Currently you could even use:

test.Test(test) instead of TTest. But I think such a usage (function on type instance) is extremely missleading and confusing.