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

Don't optimize unused variables in Debug configuration #13328

Open
ssrmm opened this issue Dec 7, 2016 · 2 comments
Open

Don't optimize unused variables in Debug configuration #13328

ssrmm opened this issue Dec 7, 2016 · 2 comments

Comments

@ssrmm
Copy link

ssrmm commented Dec 7, 2016

In the below program foo is optimized away even in Debug-mode. For debugging purposes it would be useful to be able to inspect the values of unused local variables. As such they should not be optimized away in the Debug configuration.

using System.Console;

namespace Test
{
  public module Main
  {
    public Main() : void
    {
      def foo = 42;
      
      WriteLine("Whatever");
    }
  }
}
@VladD2
Copy link
Member

VladD2 commented Dec 9, 2016

Use this trick:

      def foo = 42;
      WriteLine("Whatever");
      _ = foo;

@ssrmm
Copy link
Author

ssrmm commented Dec 13, 2016

Thanks! I came up with Debug.WriteLine, but using the underscore is certainly more elegant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants