Skip to content

ASTYPE problem #1715

@cpyrgas

Description

@cpyrgas

Based on the documentation sample for ASTYPE (I will correct it):

FUNCTION Start() AS VOID
Test("abc")

FUNCTION Test(oVar AS OBJECT) AS VOID
LOCAL oChild := oVar ASTYPE STRING // error XS0266: Cannot implicitly convert type 'object' to 'string'

this reports error XS0266: Cannot implicitly convert type 'object' to 'string', which is a bogus error message.

I think also the sample code is incorrect, as the LOCAL is not given explicitly a type with an AS clause, so I think the compiler should report a "Type expected" error in core dialect (or any dialect if /vo15 is not enabled).

The correct working code would be

LOCAL oChild := oVar ASTYPE STRING AS STRING

Truth is this looks a bit redundant, so maybe it was on purpose that this syntax

LOCAL oChild := oVar ASTYPE STRING

is also supposed to strongly type oVar AS STRING, as if the "AS" clause was actually supplied?

If that's the case, then it's currently working as it's reporting a compiler error as mentioned above.

Robert, of course this is not high priority :)

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions