Behavior of "Initialize Local Variables" setting
Posted: Tue Dec 26, 2023 3:41 pm
Hi to all,
I'm trying to remove warnings from my VO imported code.
To remove the "XS0165 Use of unassigned local variable" warning, I checked the "Initialize Local Variables" setting in the project properties.
But I get strange result comparing to the VO behavior. The "local variable initialization" seems to be done in the constructor of the parent class, and all the variables already initialized in a child class before super() or in the PreInit() method are reinitialized durng the super().
For example :
CLASS MyClass
PROTECT oBmp1 AS Bitmap
PROTECT oBmp2 AS Bitmap
END CLASS
CLASS MySubClass INHERIT MyClass
CTOR()
SELF:oBmp1 := Bitmap{ ResourceID{ "MyLogo1", _GetInst() } }
SUPER() // Step by step debugger stops on every line of the MyClass declaration
? SELF:oBmp1, oBmp2 // = null when "Initialize Local Variables is checked" in the project properties
RETURN
METHOD PreInit()
SELF:oBmp2 := Bitmap{ ResourceID{ "MyLogo2", _GetInst() } }
RETURN SELF
END CLASS
Have I misunderstood how this setting works?
Thanks
Thierry
I'm trying to remove warnings from my VO imported code.
To remove the "XS0165 Use of unassigned local variable" warning, I checked the "Initialize Local Variables" setting in the project properties.
But I get strange result comparing to the VO behavior. The "local variable initialization" seems to be done in the constructor of the parent class, and all the variables already initialized in a child class before super() or in the PreInit() method are reinitialized durng the super().
For example :
CLASS MyClass
PROTECT oBmp1 AS Bitmap
PROTECT oBmp2 AS Bitmap
END CLASS
CLASS MySubClass INHERIT MyClass
CTOR()
SELF:oBmp1 := Bitmap{ ResourceID{ "MyLogo1", _GetInst() } }
SUPER() // Step by step debugger stops on every line of the MyClass declaration
? SELF:oBmp1, oBmp2 // = null when "Initialize Local Variables is checked" in the project properties
RETURN
METHOD PreInit()
SELF:oBmp2 := Bitmap{ ResourceID{ "MyLogo2", _GetInst() } }
RETURN SELF
END CLASS
Have I misunderstood how this setting works?
Thanks
Thierry