dotnet/roslyn

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

Aperta

#50.867 aperta il 28 gen 2021

 (0 commenti) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-InteractiveBugInteractive-Debugginghelp wanted

Metriche repository

Star
 (20.414 stelle)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

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.

Guida contributor