Skip to content

Parse-Error: new-line in string interpolation expressions #50742

@bernd5

Description

@bernd5

Version Used: 16.9.0 Preview 3

Sample Code:

Link

using System;

struct Point
{
    public int X;
    public int Y;
    
    public override string ToString() => $"({X}, {Y})";
}

public class App
{

    public static void Main()
    {
        Console.WriteLine($"A Point: {new Point{ 
              X = 1, 
              Y = 2 
        }}");
    }
}

Expected Behavior:
According to csharplang every expression is allowed in an interpolation. So expressions with New-Line trivia should compile.

Actual Behavior:
Code does not compile, just with removing the new lines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CompilersuntriagedIssues and PRs which have not yet been triaged by a lead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions