xsharp.eu • X#-Runtime problem with optional parameters (bandol 2.0.0.9)
Page 1 of 1

X#-Runtime problem with optional parameters (bandol 2.0.0.9)

Posted: Thu Mar 14, 2019 5:31 pm
by Thomas
Hi All,

X# version 2.0.0.9
Dialect Vulcan.NET

There seems to be a problem with optional parameters in the X#-Runtime. The value for an optional parameter is not set if you call a method from an untyped object.

Example:

Code: Select all

BEGIN NAMESPACE XSharpTests
        
FUNCTION Start() AS VOID STRICT
	TestDefault()
	TestDefaultCorrect()

FUNCTION TestDefault()  AS VOID STRICT
	LOCAL oTest := Test{}
	oTest:TestMethod("Test")    // wrong - 'optParam' is null	

FUNCTION TestDefaultCorrect()  AS VOID STRICT
	LOCAL oTest := Test{}  AS Test
	oTest:TestMethod("Test")    // ok - 'optParam' is empty string
            
CLASS Test
PUBLIC METHOD TestMethod(param AS STRING, optParam := "" AS STRING) AS LOGIC
        IF optParam == ""
            return .T.
        ELSE
            return .F.
        ENDIF
END CLASS

END NAMESPACE	
With X#-Runtime the optional parameter 'optParam' is null when called from function TestDefault(). 'optParam' is an empty string if called from function TestDefaultCorrect(). With Vulcan-Runtime this works as excepcted, both calls result in 'optParam' as empty string.

You will also find attached a simple console exe to reproduce this.

Regards
Thomas

X#-Runtime problem with optional parameters (bandol 2.0.0.9)

Posted: Thu Mar 14, 2019 5:52 pm
by Chris
Thanks Thomas, problem confirmed, will look into it and will send you an update once it is fixed.

X#-Runtime problem with optional parameters (bandol 2.0.0.9)

Posted: Fri Mar 15, 2019 3:38 pm
by Chris
Thomas, please check your mail!