XSharpPublic: The code that hangs the program

The following code hangs the program:

FUNCTION Start() AS VOID STRICT

	LOCAL o AS TestClass
	o := TestClass{}
	o:Start()
	
	RETURN

CLASS TestClass

	CONSTRUCTOR() STRICT
		RETURN
	
	PROTECT METHOD BadMethod(oParam AS OBJECT, dwParam AS DWORD, uParam AS USUAL /* Intentional mistake (typo): uParam must be REF or OUT */) AS VOID STRICT
		uParam := oParam
		RETURN

	METHOD DoSomething(lCallBadMethod AS LOGIC) AS LOGIC STRICT
		
		LOCAL uValue AS USUAL
		LOCAL lOk := FALSE AS LOGIC
		
		BEGIN SEQUENCE
			
			uValue := "Some string value"
			IF lCallBadMethod
				SELF:BadMethod(NULL, 0, @uValue)
			ENDIF
			
			lOk := TRUE // Here the program hangs!
			
		END SEQUENCE
		
		RETURN lOk

	METHOD Start() AS VOID STRICT
		SELF:DoSomething(FALSE)
		RETURN

END CLASS

The hang is reproducible when the method has a parameter of type USUAL, which, due to a typo, is declared as AS, instead of REF or OUT. At the same time, in the code, when this method is called, the parameter is passed by reference, as intended by the algorithm. A hang occurs when before exiting a TRY block (BEGIN SEQUENCE). When the program is executed, the problematic method is not called, but simply present in the code.

P.S. X# compiler ver. 2.9

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 44 (16 by maintainers)

Commits related to this issue

Most upvoted comments

The X# 2.9 compiler now throws an error on the line that calls BadMethod(@u)

error XS1615: Argument 1 may not be passed with the 'ref' keyword