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

Error CS4007 is not visible in the editor #76779

Open
vsfeedback opened this issue Jan 16, 2025 · 1 comment
Open

Error CS4007 is not visible in the editor #76779

vsfeedback opened this issue Jan 16, 2025 · 1 comment
Labels
Area-Compilers Feature - Ref/Unsafe in Iterators/Async untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work]
with this code

namespace ConsoleApp3
{
	internal class Program
	{
		static void Main(string[] args)
		{
			Console.WriteLine(M(). Count(i => i == 0));
		}

static IEnumerable<int> M()
		{
			Span<int> ints = stackalloc int[5];
			foreach (var i in ints)
				yield return i;
		}
	}
}

you will not get a visible error on the foreach in the editor. The error also isn't in the error list. You'll be shown the error as late as when building, and it'll appear only in the error list.


Original Comments

Feedback Bot on 3/1/2025, 11:48 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 16, 2025
@jjonescz
Copy link
Member

jjonescz commented Jan 16, 2025

Yes, currently the error

error CS4007: Instance of type 'System.Span<int>' cannot be preserved across 'await' or 'yield' boundary.

is a "build-only diagnostic", i.e., it is reported during later stages of the compiler which don't run in the IDE, they run only during full builds.

I agree it's not an ideal development experience and we could think about changing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Feature - Ref/Unsafe in Iterators/Async untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

3 participants