Skip to content

Argument conversion: Change handling Any in union so that conversion to other types is attempted #5571

@pekkaklarck

Description

@pekkaklarck

Any got an explicit argument converter that accepts any value in RF 6.1 (#4647). At the moment when Any is used in an union like arg: int | Any, no argument conversion is done. The reason is that Any accepts anything without conversion and a union accepts values without conversion if any of its nested types accepts them. This behavior isn't very useful, because it would be simpler to just use arg: Any if that would be the desired behavior. Instead we should try conversion to other types, from left to right, and return the value of the first conversion that succeeds. If no other conversion would succeed, at least Any conversion would. Because Any accepts any value, types after any if used like arg: int | Any | float would in practice be ignored.

We had the same situation with object that got an explicit no-op converter in RF 7.4 (#5529). It initially worked like Any currently does when used in an union, but the behavior was changed just before the final release. The decision back then was not to change any because it would change existing functionality and RF 7.4 was already in the release candidate phase. We could do the change already in RF 7.5, but it is probably better to wait for a major version before making this backwards incompatible change.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions