(E253) Error while generating executable:

Getting this:

Error 8 (E253) Error while generating executable: Object reference not set to an instance of an object.

Not sure what I did to deserve it. The File, Line and Column columns are empty. Which makes finding it hard.

Suggestions?

Do you remember what you added/changed before this triggered?

Else can you send the project that triggered this to support@?

No, I can’t remember exactly. I was making a bunch of changes across several source files. I was really hoping the E253 would mean something to you to give me a hint of where to start commenting code out.

I’ll need to see if I can get permission to send the project. It’s pretty big at this point.

But if you can give me any hints of what might do this, I’ll comment code out on my end and if I can find it, I’ll post the offending code.

Also, I’m moving the next 3 days, so it will probably be Saturday before I can pound on this again.

this particular one is tricky. It could be anything in the last compiler phase (output). For what it’s worth we’ll treat your project as private and delete it as soon as the bug is fixed.

I found it, finally. I boiled it down greatly, so this example won’t provide much context.

Basically I’m trying to port existing code (Windows and other platforms) that use handles (variously defined) for among other things, files, memory objects and so forth. In most environments, these net out to some sort of integer. So our common, non-target code uses them and we define them as need be on the target code side. But Java doesn’t play quite so nicely with this scheme–and I need to adapt it. With that background…

So we have a typedef for HANDLE. Which can be files and other neat things, depending on context. So I figured I’d use an ‘Object’ and cast it based on context to what I need. So the code simply make a type:

type
	Handle_FAKE = Object; 

Now later, the common code uses a target specific const INVALID_HANDLE_VALUE (usually a 0 or -1) to test if a HANDLE (Handle_FAKE in my case) is valid (open or what not). Since I don’t have a simple 0 or -1 test value–the Object in my case is either an Object or nil–I set up this const:

CONST
  INVALID_HANDLE_VALUE     = Handle_FAKE(nil);

and that line seems to generate our friend, E253.

Now, it would be swell if I could do this:

CONST
  INVALID_HANDLE_VALUE     = nil; // Handle_FAKE(nil);

but I get a complaint: ‘E65 Constant value expected’.

So I’m not sure how to solve the problem of properly defining the const–which is a separate question from the E253 issue, which I’ve at least identified how to create in a very short sample app.

(FWIW, under Compatibility, I am using ‘Allow globals’, ‘Allow legacy ‘with’’, ‘Allow implicit var/out in method calls’, ‘Allow Delphi compatibility syntax’ and ‘Use Delphi compatible division operators’, if that makes any difference).

I hope this helps identify the error (and if the IDE could point out the offending line for other poor souls in the future, that would be great), but I’d also appreciate advice on how I can make this CONST thing work with an Object. If possible.

Thanks.

Update: I think I’m going to be able to work around the HANDLE vs. nil issue.

Thanks, logged as bugs://71580

I tried this:

unit issue71580test;

interface



uses

  System.Linq, System.Collections.Generic;

type

    Handle_FAKE = Object;

type

  ConsoleApp = public class

  public

    class method Main(args: array of string): Integer;

  CONST

    INVALID_HANDLE_VALUE     = Handle_FAKE(nil);

  end;



implementation



class method ConsoleApp.Main(args: array of string): Integer;

begin

  var r: Handle_FAKE;

  if r = INVALID_HANDLE_VALUE then begin

  end;

end;



end.

But it doesn’t seem to fail. What am I missing?

The reason for
Const X = Nil not working is that nil is untyped, in that case you have to give a type:

CONST

    INVALID_HANDLE_VALUE: Object = nil;

to make it work.

Odd. Attached is the skeletal project that gives me that error. Hopefully you can reproduce it from that?

Thanks for the typing hint!

TestConsoleApp.zip (53.3 KB)

ah! I missed the part where this was a Java project. That does show it. Fixing.

bugs://71580 got closed with status fixed.

Thanks!