Macrocompiler-Bug

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ecos
Posts: 103
Joined: Tue Nov 10, 2015 6:49 am
Location: Germany

Macrocompiler-Bug

Post by ecos »

Hi Chris, Robert,

I experienced a (for us) serious bug in the macrocompiler. When I call a method with three parameters by reference an error occurs. This causes crashes in several scripts (VOSCRIPT) that run in the production environment of our customers.
Here is an example which shows the problem:

Code: Select all

FUNCTION Start() AS VOID STRICT
PRIVATE oa
PRIVATE ca
PRIVATE cb
PRIVATE cc
LOCAL cCmd	AS STRING

TRY

	oa := a{}

	? "Direct call 2 parameters:"	
	ca	:= ""
	cb	:= NULL_DATE
	oa:CallByRef2(@ca,@cb,@cc)
	? ca
	? cb
	?

	? "Direct call 3 parameters:"	
	ca	:= ""
	cb	:= NULL_DATE
	cc	:= NULL_DATE
	oa:CallByRef3(@ca,@cb,@cc)
	? ca
	? cb
	? cc
	?

	? "Indirect call 2 parameters:"	
	ca	:= ""
	cb	:= NULL_DATE
	cCmd := "oa:CallByRef2(@ca,@cb)"
	eval(&("{||"+cCmd+"}"))
	? ca
	? cb
	?
	
	? "Indirect call 3 parameters, third by value:"	
	ca	:= ""
	cb	:= NULL_DATE
	cc	:= NULL_DATE
	cCmd := "oa:CallByRef3a(@ca,@cb,cc)"
	eval(&("{||"+cCmd+"}"))
	? ca
	? cb
	? cc
	?
	
	? "Indirect call 3 parameters, third by ref:"	
	ca	:= ""
	cb	:= NULL_DATE
	cc	:= NULL_DATE
	cCmd := "oa:CallByRef3(@ca,@cb,@cc)"
	eval(&("{||"+cCmd+"}"))
	? ca
	? cb
	? cc
	?
	
CATCH e AS exception
	? e:Message
END TRY

WAIT

RETURN

CLASS a

METHOD CallByRef2(a REF STRING,b REF DATE) AS LOGIC
LOCAL lOk	AS LOGIC

a := "OK"
b	:= Today()
lOk := TRUE

RETURN lOk

METHOD CallByRef3(a REF STRING,b REF DATE,c REF DATE) AS LOGIC
LOCAL lOk	AS LOGIC

a := "OK"
b	:= Today()
c := Today()+1
lOk := TRUE

RETURN lOk

METHOD CallByRef3a(a REF STRING,b REF DATE,c AS DATE) AS LOGIC
LOCAL lOk	AS LOGIC

a := "OK"
b	:= Today()
c := Today()+1
lOk := TRUE

RETURN lOk

END CLASS
The output is:

Direct call 2 parameters:
OK
20.03.2024

Direct call 3 parameters:
OK
20.03.2024
21.03.2024

Indirect call 2 parameters:
OK
20.03.2024

Indirect call 3 parameters, third by value:
OK
20.03.2024
. .

Indirect call 3 parameters, third by ref:
Die Liste hatte eine feste Größe.
Press any key to continue...


TIA Karl
User avatar
Chris
Posts: 4898
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Macrocompiler-Bug

Post by Chris »

Hi Karl,

Indeed, it looks like there's a problem calling a method with 3 or more arguments passed by reference. Thanks for reporting, will open a bug report for Nikos/Robert to look into it.

Btw, strangely enough, VO has trouble also with the 2 parameters call, which X# handles fine.
Chris Pyrgas

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