[lazarus] Name Confilct in fpc

Marc Weustink Marc.Weustink at cuperus.nl
Mon Feb 28 04:40:08 EST 2000


+ From: Peter Dyson [mailto:peter at skel.demon.co.uk]
+
+ .... but while doing the compile/comment out/create new
+ methods cycle, I came across this name conflict I cannot
+ resolve.
+
+ Here is a code snippet which shows the problem,
+ Along with the errors generated.
+ It would seem the compiler has some scoping issues.
+ Is this design or a 'feature'? :)

This is as far as I can see normal compiler behaviour.

+ The code should describe the problem clearly.
+
+ {
+
+  $Author: peter $
+  $Revision: 1.1 $
+  $Log: hello.pp,v $
+  Revision 1.1  2000/02/28 02:04:58  peter
+  Initial revision
+
+ }
+ unit hello;
+
+ {$mode objfpc}   file://tried delphi mode too
+ interface
+
+ uses SysUtils;
+
+
+ type
+   TSomeObject = class(TObject)
+   private
+     s, t, v: string;
+   public
+     //note made sure this is not same calling convention as Insert
+     procedure Insert(Dummy, Dummy1: String);
+     procedure NestProc;
+   end;
+
+ implementation
+
+ procedure TSomeObject.Insert(Dummy, Dummy1: String);
+ begin
+  writeln('Hello World Again this is yet another test');
+ end;
+
+ procedure TSomeObject.NestProc;
+
+   procedure Nested;
+   begin
+        s := 'A bit of text';
+        t := ' new';
+        Insert(t, s, 5); // won't compile
+        //error "hello.pp" 41 Wrong amount of parameters specified

This is by design. The nearest insert takes 2 arguments.

+   end;
+
+ begin
+        s := 'A bit of text';
+        t := ' new';
+        SysUtils.Insert(t, s, 5); // won't compile
+        //error "hello.pp 48 Identifier not found INSERT

This is also by design since Insert is part of the System unit and the
compiler can't resolve SysUtils.Insert. System.Insert should work here ;-)

+
+   writeln('Hello World Again this is yet another test');
+
+ end;
+
+ end.

BTW. Have you tried this in delphi ?

Marc







More information about the Lazarus mailing list