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

field access as part of a MemberAccessExpression on T[], List<T>, etc generates invalid IL #274

Closed
adrianoc opened this issue Mar 27, 2024 · 0 comments
Labels
🐛 bug Something isn't working
Milestone

Comments

@adrianoc
Copy link
Owner

using System.Collections.Generic;

var a = new Foo[1];
a[1] = new Foo { data = 42 };


System.Console.WriteLine(MFieldArray(a));

static int MFieldArray<T>(T[] b) where T : Foo => b[0].data; 
static int MList<T>(List<T> b) where T : Foo => b[0].data; 
static int MInlineArray<T>(Buffer<T> b) where T : Foo => b[0].data; 

class Foo
{
	public int data;
}

[System.Runtime.CompilerServices.InlineArray(2)]
struct Buffer<T>
{
	private T _data;
}

See expected generated code

@adrianoc adrianoc added the 🐛 bug Something isn't working label Mar 27, 2024
@adrianoc adrianoc changed the title field access as part of a MemberAccessExpression on arrays/inline arrays/lists of generic types generates invalid IL field access as part of a MemberAccessExpression on T[], List<T>, etc generates invalid IL Mar 27, 2024
@adrianoc adrianoc added this to the 2.11 milestone Mar 27, 2024
@adrianoc adrianoc closed this as completed Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant