dotnet/roslyn

Assert failures handling DynamicObjectCreationExpression in GetValEscape() and CheckValEscape()

Open

#67,518 opened on Mar 28, 2023

View on GitHub
 (0 comments) (0 reactions) (0 assignees)C# (4,257 forks)batch import
Area-CompilersBughelp wanted

Repository metrics

Stars
 (20,414 stars)
PR merge metrics
 (Avg merge 6d 17h) (256 merged PRs in 30d)

Description

Version Used: release/dev17.4: https://github.com/dotnet/roslyn/commit/528676cdbf0bfcfdb9372dc57a047dd0edc6d4db main: https://github.com/dotnet/roslyn/commit/3dee0a96cd8b5478390c47ddb0545875bf6b4c18

Steps to Reproduce:

Compile with DEBUG build:

static class Program
{
    static void Main()
    {
        dynamic d = 0;
        R x = new R(d);
        R y;
        y = new R(default(R), d);
    }
}

readonly ref struct R
{
    public R(int i) { }
    public R(R r, int i) { }
}

Expected Behavior: (8,19): error CS1978: Cannot use an expression of type 'R' as an argument to a dynamically dispatched operation.

Actual Behavior: Assert failures with message "DynamicObjectCreationExpression expression of R type" in GetValEscape() and CheckValEscape().

(8,19): error CS1978: Cannot use an expression of type 'R' as an argument to a dynamically dispatched operation. (8,13): error CS8751: Internal error in the C# compiler.

Contributor guide