Skip to content

Binary addition of interpolated strings mangles the string #55461

@rolfbjarne

Description

@rolfbjarne

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

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Active/Investigating

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions