Compiler behaves strange when there is return statement within class constructor.
Example:
class Gee:
public x as string
def constructor():
x = "foo"
return
x = "bar"
a = Gee()
print a.x
Results in:
bootest.boo(8,9): BCE0055: Internal compiler error: Object reference not set to an instance of an object.
1 error(s).
In some other case, compiler haven't crashed, but the code had infinite loop in that place starting constructor from the beginning over and over again (despite what Linus says, it takes quite long to execute)
I can live without "return" in constructor, but error should be properly signalled. C# just skips the rest of constructor and returns new object, which IMHO makes sense. Here is C# sample:
class Gee
{
public string x;
public Gee()
{
x = "foo";
return;
x = "bar";
}
}
class HelloWorld
{
static void Main(string[] args)
{
Gee a = new Gee();
System.Console.WriteLine(a.x);
}
}
It compiles with warning about unreachable code and prints "foo"