type
OldStyleClass = public class
private
protected
public
method Test (anInt : Integer) : Integer;
method Bunny : String;
end;
implementation
method OldStyleClass.Test(anInt: Integer): Integer;
begin
result := 0;
end;
method OldStyleClass.Bunny: String;
begin
result := 0;
end;
end.
Elements 9.1.99.2151
VS 2017 (will not matter very likely)
.net target
I’m little confused, let’s say surprised. Why does this code compile? Talking about the Bunny method (don’t care about the names - it’s just little tinkering for test purposes).
It’s no surprise that the output with writeln returns an empty string.
Whilst I have no issue with the truth of a statement 0 = Integer(nil), it is (imho) only the presence of the cast that should make this true (or at least acceptably true to the compiler).
the big problem here is that we import the C headers for Toffee and Island, and in C 0 is used for null (#define NULL 0), so the compiler has to understand that when it encounters an integer 0 constant, it can translate it to nil, (this obviously only works for 0). it’s a bit of an edge case and I want to make it work for external constants only, but it’s one of those things that just has to work for pretty much all C headers to work.