nemerle icon indicating copy to clipboard operation
nemerle copied to clipboard

Don't optimize unused variables in Debug configuration

Open ssrmm opened this issue 8 years ago • 2 comments

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");
    }
  }
}

ssrmm avatar Dec 07 '16 16:12 ssrmm

Use this trick:

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

VladD2 avatar Dec 09 '16 21:12 VladD2

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

ssrmm avatar Dec 13 '16 11:12 ssrmm