XSharpPublic icon indicating copy to clipboard operation
XSharpPublic copied to clipboard

No compiler error when assigning OBJECT to typed var, with /vo7+ enabled

Open cpyrgas opened this issue 1 year ago • 1 comments

When /vo7 is disabled, the following code results to a compiler error for all assignments from OBJECT to a typed var. VO does the same.

When /vo7 is enabled, only the LOGIC,DATE,Char->OBJECT assignments produce a compiler error.

FUNCTION Start() AS VOID
LOCAL o := NULL AS OBJECT

// following report an error no matter the state of /vo7
LOCAL l := o AS LOGIC // error XS0266: Cannot implicitly convert type 'object' to 'int'
LOCAL d := o AS DATE  // error XS0266
LOCAL c := o AS Char  // error XS0266

// following report error only when /vo7 is enabled
LOCAL n := o AS INT
LOCAL dw := o AS DWORD
LOCAL b := o AS BYTE
LOCAL s := o AS STRING
LOCAL sym := o AS SYMBOL
LOCAL p := o AS PTR
LOCAL obj := o AS TestClass

CLASS TestClass
END CLASS

cpyrgas avatar May 30 '24 07:05 cpyrgas

In the final 2.20 version, now none of the lines report an error, but also do not throw a runtime error either (anymore), locals get their default value. Only the NULL->PTR assignment does throw an exception.

Still the behavior is not right, but since there's existing code depending on it, let's put this on hold.

cpyrgas avatar May 30 '24 15:05 cpyrgas