Beef
Beef copied to clipboard
[Bug] "Step into" skips class constructor
Version: Nightly (04/12/2021)
During debugging the "step into" command will only jump to TestClass' constructor if there is a breakpoint in it. Without it, the class constructor's instructions will be skipped altogether.
I tested it with a Debug build, so I assume no optimization took place that would cause this behaviour.
namespace beef_test
{
class TestClass {
public this {
int a = 0; // If no breakpoint set here, step into will skip this line
}
}
class Program
{
public static void Main(){
TestClass c = scope TestClass();
}
}
}
Looking back at this issue, I've just found out what caused the problem. The TestClass' constructor is missing the parentheses.
With this function signature: public this()
it works as expected (I don't have to set a breakpoint inside the constructor, to step into it with the debugger).
However, there is another strange behaviour. Without the parentheses, the constructor's protection level gets ignored, and behaves as if it were 'public'.
So with these following two declaration, it compiles and works fine (although the original debugger issue remains).
// Without specifying the protection level, 'private' is implied,
// which should cause compiler error when trying to initialize the class
this {}
// The constructor gets called even with an explicit 'private' protection level
// (without any compiler warning or error)
private this {}
Just noticed one more thing:
Without the constructor parentheses, the method signature gets displayed as
beef_test.TestClass.__BfInit()
instead of beef_test.TestClass.this()
in the IDE's method list: