Skip to content
New issue

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

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

Already on GitHub? # to your account

No error when using nameof(collection[index]). Instead the compiler crashes on build #77228

Open
johanlovgrenumc opened this issue Feb 14, 2025 · 0 comments

Comments

@johanlovgrenumc
Copy link

Version Used: Visual studio 17.13.0, dotnet 9.0.100

Steps to Reproduce:

  1. In a C# project, Include the following code
using System;
using System.Collections.Generic;
					
public class Program
{
	public static void Main()
	{
		List<string> things = ["Hello ", "World"];
		var res = nameof(things[0]);
		Console.WriteLine(res);
	}
}
  1. Build the project.

Diagnostic Id:
MSB6006: "csc.exe" exited with code -2146232797.

Expected Behavior: I expect nameof to either work here, or for the compiler to give me an error before I build.

Actual Behavior: Compiler crashes on build with the above error message.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 14, 2025
@jaredpar jaredpar added Feature - Collection Expressions and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 18, 2025
@jaredpar jaredpar assigned cston and unassigned AlekseyTs Feb 18, 2025
@jaredpar jaredpar added this to the 17.14 milestone Feb 18, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants