Skip to content

const results in error CS0648: '' is a type not supported by the language #955

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

Closed
staff0rd opened this issue Sep 27, 2015 · 7 comments
Closed
Labels
External This is an issue in a component not contained in this repository. It is open for tracking purposes.

Comments

@staff0rd
Copy link
Contributor

REPRO

  1. Open VS2015 (Windows 10, ASP.NET 5 Beta 7)
  2. Click File > New > Project > Web > Console Application (Package) > Ok
  3. Edit Program.cs to reflect code snippet below.
  4. Add a breakkpoint just after Console.WriteLine(a);
  5. Run the project
  6. Right-click variables a and b click Add Watch

CODE

public void Main(string[] args)
{
    const int a = 3;
    int b = 4;
    Console.WriteLine(a);
}

EXPECTED
Watch window displays values for variables a and b

ACTUAL
Watch window Value column for variables a and b displays:

error CS0648: '' is a type not supported by the language

NOTES

  1. The value of a is written correctly to Console
  2. Removing const from the snippet reverts to EXPECTED bevahiour
@staff0rd staff0rd changed the title const results in error CS0648: '' is a type not supported by the language const results in error CS0648: '' is a type not supported by the language Sep 27, 2015
@Sharpiro
Copy link

+1
Just discovered this is occuring in Xunit tests as well.
Cannot view any local variables in scope while debugging if "const" is involved

@Eilon
Copy link
Member

Eilon commented Sep 28, 2015

@barrytang looks like maybe something with the debugger or Roslyn is changed? Do you know a contact there?

@dandago
Copy link

dandago commented Sep 30, 2015

I ran into this a few weeks ago, and wrote a blog post with some detail yesterday: http://gigi.nullneuron.net/gigilabs/nasty-const-bug-in-asp-net-5/

@Eilon
Copy link
Member

Eilon commented Sep 30, 2015

I contacted the Roslyn team to have them take a look at this.

@KevinH-MS
Copy link

Since constants aren't actually locals (they're just inline values in the emitted IL), we have to retrieve their name/value/type from the .pdb. It seems that the low-level API we use for doing this (ISymUnmanagedConstant.GetSignature) is always returning a zero-length array on CoreClr.

I should be able to make the watch for b work despite this, but we'll need a fix from the core debugger to show the value of a. I'll follow up with the folks who own the symreader and post back when I know more.

@KevinH-MS
Copy link

I have a PR out to ignore the const local in this case (enables you to at least inspect the other locals in that scope): dotnet/roslyn#5658

I've also opened an internal bug for the core debugger to figure out why reading the signature of a const isn't supported here.

@Eilon
Copy link
Member

Eilon commented Oct 3, 2015

This is now being tracked on the Roslyn GitHub org and also in an internal MSFT bug database, so I'm closing this out. Thanks, everyone!

@Eilon Eilon closed this as completed Oct 3, 2015
@Eilon Eilon added the External This is an issue in a component not contained in this repository. It is open for tracking purposes. label Oct 3, 2015
natemcmaster pushed a commit that referenced this issue Dec 1, 2018
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
External This is an issue in a component not contained in this repository. It is open for tracking purposes.
Projects
None yet
Development

No branches or pull requests

5 participants