dotnet/roslyn

Internal error in the C# compiler when using "is" operator in VS 2019 watch window

Open

#50,867 opened on Jan 28, 2021

View on GitHub
 (0 comments) (0 reactions) (0 assignees)C# (4,257 forks)batch import
Area-InteractiveBugInteractive-Debugginghelp wanted

Repository metrics

Stars
 (20,414 stars)
PR merge metrics
 (Avg merge 6d 17h) (256 merged PRs in 30d)

Description

Version Used: .net 5.0 , VS 16.8.4

Steps to Reproduce: object ob = "Baseball"; var istype = ob is int dc ? "game" : "nothing";

  1. Hit the breakpoint at var istype
  2. Add "ob is int dc" to watch widow. It throws the following exception: ob is int dc | error CS0136: A local or parameter named 'dc' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter |   (I don't know why)
  3. In the same watch window, replace dc with any other token, say, marvel (ob is int marvel). This shows "Internal error in c# compiler" (you might have to hit enter twice)

Expected Behavior: show false. Actual Behavior: Shows above to errors.

Contributor guide