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

This forum is meant for questions and discussions about the X# language and tools
Post Reply
Thomas
Posts: 93
Joined: Thu Oct 25, 2018 11:39 am

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

Post 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
Attachments
OptionalParameterTest.zip
(15.12 KiB) Downloaded 44 times
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

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

Post by Chris »

Thanks Thomas, problem confirmed, will look into it and will send you an update once it is fixed.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

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

Post by Chris »

Thomas, please check your mail!
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply