Skip to content

Unexpected warning CS0649: Field '(T1, T2).F1' is never assigned to #43588

@AlekseyTs

Description

@AlekseyTs
namespace System
{
    // struct with two values
    public struct ValueTuple<T1, T2>
    {
        private static int F1 = 123;
        public T1 Item1;
        public T2 Item2;

        public ValueTuple(T1 item1, T2 item2)
        {
            this.Item1 = item1;
            this.Item2 = item2;
        }

        public override string ToString()
        {
            return F1.ToString();
        }
    }
}

Observed:

(6,28): warning CS0649: Field '(T1, T2).F1' is never assigned to, and will always have its default value 0

Expected:
No warning, there is an initializer for the field.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions