Skip to content

Incorrect IDE0004 in iterator #37473

@impworks

Description

@impworks

Version Used:
VS 15.9.11.

Steps to Reproduce:

public class Foo
{
    public IEnumerable<object> Bar()
    {
        yield return ("test", (decimal?)1.23);
    }
}

Expected Behavior:
No suggestions.

Actual Behavior:
Roslyn suggests a fix:

image

This fix breaks the program's semantics, since the actual returned value's type changes from ValueTuple<string, Nullable<decimal>> to ValueTuple<string, double>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEBugIDE-CodeStyleBuilt-in analyzers, fixes, and refactoringshelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions