Invalid signature for "main" method

Hi,
Using “Remobjects.Elements.RTL.Delphi” seems to confuse the compiler, so it
dosn’t recognize String as a normal type.

type
  Program = assembly static class
  public
    class method Main(args:array of String);
  end;

implementation

uses
  Remobjects.Elements.RTL.Delphi;

Unbenannt 1.bugreport.txt (3.8 KB)
Unbenannt 1.bugreport.zip (8.4 KB)

That’s expected. If you “use” Remobjects.Elements.RTL.Delphi, “String” maps tot he Delpgiu string type. which is not compatible with what the Main() method expects as parameter, which as tp be an array of native Strings.

Use e.g.

class method Main(args:array of System.String);

to work around this.

hth,
marc

Thanks Marc.
I’ve used this workaround myself.

But: if the compiler wouldn’t take the uses clause of the implementation part into account while in the interface part, this would not happen.
(As it was in older versions. I’ve never understood the decision to mix the uses parts together. For me it’s more clear and strict)

But the the signature for your method in the interface wouldn’t match what’s in the implementation :wink:

It’s a matter of taste, but either way “String” in “Main(args:array of String);” has to have the same meaning in both parts of the code…

Personally, I use Unified syntax for all new code I write.

Yes, the types must match. But the error message should be more clear of what’s the problem is imho.
(And maybe the compiler should take precedence of the type which is used in the interface part. Not quite shure if that was in Delphi or older versions).
Anyway, it’s your decision…

Possibly; I’m not sure if we can make it much clearer, as the compiler really doesn’t “know” the underlying details, it just nows its not getting the type it expects, “String”, and this is a rather corner case scenario that a separate type was brought into cope that also happens to be called ‘String’, but in a different namespace.

That yes, in fact im surprised that you don’t get an error that the interface and implementation do not match…