That is right ?That doesn't look right. In the second case, Test1 is nested in Test2 just as it is in the first case.
Looks like a bug to me but, it will be nice to have one of the developers confirm that.I also think it's a bug. Why is this allowed only in {$MODE DELPHI} mode, but not in {$MODE OBJFPC} mode.
I also think it's a bug.
procedure TForm1.Test1;
begin
beep;
end;
procedure TForm1.Test2;
procedure Test1;
begin
beep;
end;
begin
Test1; //the neseted one
Self.Test1; //the fom1.Test1
end;
That is right ?That doesn't look right. In the second case, Test1 is nested in Test2 just as it is in the first case.
Looks like a bug to me but, it will be nice to have one of the developers confirm that.
Maybe the directive {$modeswitch duplicatelocals} can help somehow?I cannot help feeling uneasy about "artifices" to create exceptions to languages rules.
For consistency, wouldn't a warning make more sense? But that said, I can sure see how having multiple procedures with the same name might cause pain for someone trying to maintain a program.
Maybe the directive {$modeswitch duplicatelocals} can help somehow?
Maybe the directive {$modeswitch duplicatelocals} can help somehow?I cannot help feeling uneasy about "artifices" to create exceptions to languages rules.
I think there should not be exceptions to the scoping rules. Their presence opens the door to inconsistencies and confusing situations (e,g. why does it accept "this or that" in "this case" and not in "that case" when the two cases are essentially identical ?)
This functionality is not a bug and it won't be changed.Since from what you're saying it's by design then it may not be a bug but, bug or not, it is an inconsistency in the language's scoping rules. Inconsistencies are not desirable.
I agree with 440bx. Anyway if it is by design, in my view, also the first code fragment should rise the same warning/error.
But in {$MODE OBJFPC} the error appears, regardless of {$MODESWITCH DUPLICATELOCALS}:Maybe the directive {$modeswitch duplicatelocals} can help somehow?Yes, that modeswitch controls that and is enabled by default in mode Delphi.
But in {$MODE OBJFPC} the error appears, regardless of {$MODESWITCH DUPLICATELOCALS}: