Skip to content

access violation when calling the method if the record is returned by reference

If the record has fields, then an Access Violation exception is raised when the method is called if the record is returned by reference.

MODULE TestSelf;

TYPE
	R = RECORD
		x := SIZE(100500);

		PROCEDURE P(): VAR R;
		BEGIN
			TRACE("P");
			RETURN SELF;
		END P;

		PROCEDURE Q(): VAR R;
		BEGIN
			TRACE("Q");
			RETURN SELF;
		END Q;
	END;

PROCEDURE Do*;
VAR r: R;
BEGIN
	r := r.P().P();
(*	r := r.P().Q().P();*)
END Do;

END TestSelf.

System.Free TestSelf ~
TestSelf.Do ~