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

Binary addition of interpolated strings mangles the string #55461

Closed
rolfbjarne opened this issue Aug 6, 2021 · 3 comments · Fixed by #55494
Closed

Binary addition of interpolated strings mangles the string #55461

rolfbjarne opened this issue Aug 6, 2021 · 3 comments · Fixed by #55494
Assignees
Milestone

Comments

@rolfbjarne
Copy link
Member

rolfbjarne commented Aug 6, 2021

Version Used:

.NET 6.0.100-rc.1.21405.1 (6.0.100-rc.1.21403.66 works fine)

Steps to Reproduce:

Test code:

using System;

class App {
	public static void Main (string[] args)
	{
		var t = new T ();
		Console.WriteLine (t.A ());
		Console.WriteLine ();
		Console.WriteLine (t.B ());
	}
}

class T {
	public float R0C0 = 1;
	public float R1C0 = 2;
	public float R0C1 = 3;
	public float R1C1 = 4;

	public string A ()
	{
		return
			$"({R0C0}, {R0C1})\n" +
			$"({R1C0}, {R1C1})";
	}

	public string B ()
	{
		return
@$"({R0C0}, {R0C1})
({R1C0}, {R1C1})";
	}
}

csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>
</Project>

Save & run with dotnet run

Expected Behavior:

Output should be:

(1, 3)
(2, 4)

(1, 3)
(2, 4)

The first interpolated string is badly mangled.

Actual Behavior:

)
3, 1()4, 2(

(1, 3)
(2, 4)

This is a regression in this range: 3a06c12...38582c4

From the PR description, this seems like a likely culprit: #55059

@Youssef1313
Copy link
Member

cc @333fred

@333fred
Copy link
Member

333fred commented Aug 6, 2021

@jaredpar to assign this out, since I'm on vacation. There's probably an arraybuilder.reverse missing in the local rewriter somewhere.

@jaredpar jaredpar added Bug Feature - Interpolated String Improvements Interpolated string improvements and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 6, 2021
@jaredpar jaredpar added this to the 17.0 milestone Aug 6, 2021
@jcouv
Copy link
Member

jcouv commented Aug 10, 2021

Fixed by #55494 in 17.0p4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants