Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong TupleElementIndex on underlying field for Item1 in long tuple #58499

Open
jcouv opened this issue Dec 26, 2021 · 0 comments
Open

Wrong TupleElementIndex on underlying field for Item1 in long tuple #58499

jcouv opened this issue Dec 26, 2021 · 0 comments

Comments

@jcouv
Copy link
Member

jcouv commented Dec 26, 2021

Either the TupleElementIndex should be zero in the following test (commented line) or possibly we should not have a TupleElementFieldSymbol wrapping a SubstitutedFieldSymbol (the SubstitutedFieldSymbol should store the extra information, such as element name and location to be a tuple element by itself).

        [Fact]
        public void IndexOfUnderlyingFieldsInTuple9()
        {
            string source = @"
class C
{
    (int, int, int, int, int, int, int, int, int) M() => throw null;
}
";
            var comp = CreateCompilation(source);
            var m = (MethodSymbol)comp.GetMember("C.M");
            var tuple = m.ReturnType;
            Assert.Equal("(System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32)",
                tuple.ToTestDisplayString());
            Assert.IsType<ConstructedNamedTypeSymbol>(tuple);

            var item1 = tuple.GetMember<TupleElementFieldSymbol>("Item1");
            Assert.Equal("System.Int32 (System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32).Item1",
                item1.ToTestDisplayString());
            Assert.Equal(0, item1.TupleElementIndex);

            var item1Underlying = item1.TupleUnderlyingField;
            Assert.Equal("System.Int32 (System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32).Item1",
                item1Underlying.ToTestDisplayString());
            Assert.IsType<SubstitutedFieldSymbol>(item1Underlying);
            Assert.Equal(-1, item1Underlying.TupleElementIndex); // should be zero
...
        }
@jcouv jcouv added this to the Backlog milestone Dec 26, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Dec 26, 2021
@jcouv jcouv removed the untriaged Issues and PRs which have not yet been triaged by a lead label Dec 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant