Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VB: User-defined conversion rejected when its "in" conversion is narrowing and its "out" is widening #19269

Open
jcouv opened this issue May 4, 2017 · 0 comments

Comments

@jcouv
Copy link
Member

jcouv commented May 4, 2017

Conversions fail (but are expected to succeed) when they involve:

  • narrowing as "in" conversion (such as int to byte, or a narrowing tuple conversion (int, object) to (int, string))
  • user-defined conversion
  • widening conversion (such as widening nullable conversion

This issue exists in Roslyn and the native compiler.

Structure C
    Shared Sub Main()
        'Dim x As C = (1, Nothing)
        'Dim y As C? = (2, Nothing)

        Dim a As Integer = 1
        Dim b As Integer? = 1
        Dim x1 As C = a
        Dim y1 As C? = a
        Dim z1 As C? = b

    End Sub
    'Public Shared Widening Operator CType(ByVal d As (Integer, String)) As C
    '    Return New C()
    'End Operator


    Public Shared Widening Operator CType(ByVal d As Byte) As C
        Return New C()
    End Operator

End Structure

The issue was discovered in testing this PR: #18416 (comment)

@jaredpar jaredpar added the Bug label Jun 16, 2017
@jaredpar jaredpar added this to the 16.0 milestone Jun 16, 2017
@jinujoseph jinujoseph modified the milestones: 16.0, 16.3 Jun 9, 2019
@jcouv jcouv modified the milestones: 16.3, Compiler.Next Jul 11, 2019
@jaredpar jaredpar modified the milestones: Compiler.Next, Backlog Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants