Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi Prism/Compiler    [ Add a report in this area ]  
Report #:  98557   Status: Open
Internal error in compiler with forward declaration of nested method
Project:  Embarcadero Prism Build #:  5.0.29.893
Version:    2010.1 Submitted By:   Robert Ogren
Report Type:  Basic functionality failure Date Reported:  9/5/2011 7:37:56 AM
Severity:    Infrequently encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   287446
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
Code similar to the following, which compiled fine in the Spring 2011 release, does not work in XE2 (Oxygene version 5.0.29.893). This is old code that has originally been developed in an old version of Delphi.NET and then upgraded to Prism, which explains why the forward line was originally needed. My main problem with this bug is that you don't know which unit or method that caused the internal error, unlike a regular compile error.

class method ConsoleApp.Main(args: array of String);
      method RoundDown(d: Double): Double; forward;
      method RoundUp(d: Double): Double;
      begin
        if d < 0 then
          result := -RoundDown(-d)
        else
          result := 0;
      end;

      method RoundDown(d: Double): Double;
      begin
        if d < 0 then
          result := -RoundUp(-d)
        else
          result := 0;
      end;
begin
  // add your own code here
  Console.WriteLine('Hello World.');
end;


It produces the following error when compiling


error E0: Internal error: System.NullReferenceException: Object reference not set to an instance of an object.
   at F.O.f.VisitCallExpression(B A)
   at RemObjects.Oxygene.Code.BaseVisitor.VisitExpression(M element)
   at RemObjects.Oxygene.Code.BaseVisitor.VisitUnaryExpression(e unaryExpression)
   at F.O.f.VisitUnaryExpression(e A)
   at RemObjects.Oxygene.Code.BaseVisitor.VisitExpression(M element)
   at RemObjects.Oxygene.Code.BaseVisitor.VisitAssignmentStatement(b assignmentStatement)
   at F.O.f.VisitAssignmentStatement(b A)
   at RemObjects.Oxygene.Code.BaseVisitor.VisitStatement(X element)
   at F.O.f.VisitStatement(X A)
   at RemObjects.Oxygene.Code.BaseVisitor.VisitIfStatement(g ifStatement)
   at F.O.f.VisitIfStatement(g A)
   at RemObjects.Oxygene.Code.BaseVisitor.VisitStatement(X element)
   at F.O.f.VisitStatement(X A)
   at RemObjects.Oxygene.Code.BaseVisitor.VisitBeginStatement(z beginStatement)
   at F.O.f.VisitBeginStatement(z A)
   at RemObjects.Oxygene.Code.BaseVisitor.VisitStatement(X element)
   at F.O.f.VisitStatement(X A)
   at RemObjects.Oxygene.Code.BaseVisitor.VisitMethodImplementation(F methodImplementation)
   at F.O.f.VisitMethodImplementation(F A)
   at F.O.f.A(t A)
   at H.p.A(Boolean A, Func`2 a)
   at F.O.f.A(Dictionary`2 A)
   at F.O.r()
   at F.O.G()
Steps to Reproduce:
Paste the code above into the main method of an empty console application, or use the attached console project.
Workarounds
Remove the first line:
      method RoundDown(d: Double): Double; forward;

This does not seem to be needed anymore.
Attachment
NestedMethodForward.zip
Comments

None

Server Response from: ETNACODE01