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 -> C#: Chr() not converted correctly #331

Closed
mrmonday opened this issue Jul 18, 2019 · 1 comment

Comments

@mrmonday
Copy link
Contributor

commented Jul 18, 2019

Input code

Friend Class Program
    Public Shared Sub Main(ByVal args As String())
        Dim x As Integer = 4
        Dim s As String = ""
        Dim i As Integer = 3
        s = Chr(x + i)
    End Sub
End Class

IL:

	.locals init (
		[0] int32,
		[1] string,
		[2] int32
	)

	IL_0000: nop
	IL_0001: ldc.i4.4
	IL_0002: stloc.0
	IL_0003: ldstr ""
	IL_0008: stloc.1
	IL_0009: ldc.i4.3
	IL_000a: stloc.2
	IL_000b: ldloc.0
	IL_000c: ldloc.2
	IL_000d: add.ovf
	IL_000e: call char [Microsoft.VisualBasic]Microsoft.VisualBasic.Strings::Chr(int32)
	IL_0013: call string [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.Conversions::ToString(char)
	IL_0018: stloc.1
	IL_0019: ret

Erroneous output

namespace ConsoleApp4
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int x = 4;
            string s = "";
            int i = 3;
            s = (char)x + i;
        }
    }
}

Error:

error CS0029: Cannot implicitly convert type 'int' to 'string'

Expected output

namespace ConsoleApp4
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int x = 4;
            string s = "";
            int i = 3;
            s = Microsoft.VisualBasic.CompilerServices.Conversions.ToString(Microsoft.VisualBasic.Strings.Chr(x + i));
        }
    }
}

Details

Product in use: VS extension

Version in use: 6.9.0.0

@GrahamTheCoder

This comment has been minimized.

Copy link
Member

commented Aug 2, 2019

Consolidating

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.