View Issue Details

IDProjectCategoryView StatusLast Update
0024502LazarusIDEpublic2014-03-24 23:50
ReporterDo-wan Kim Assigned ToJuha Manninen  
PrioritynoneSeverityminorReproducibilityalways
Status closedResolutionfixed 
Summary0024502: patch / codetool "Error: ancestor has same name as class"
DescriptionCode editor raise error on completion "Error: ancestor has same name as class".


unit test;

uses classes, sysutils, stdctrls;

type
   ListBox = class(stdctrls.ListBox)
...
   end;

...
TagsNo tags attached.
Fixed in Revisionr44513
LazTarget-
Widgetset
Attached Files

Relationships

related to 0023550 closedJuha Manninen Converter loses properties of a component that has a local inherited (hack-)type definition 

Activities

Do-wan Kim

2013-05-28 11:39

reporter  

lazaruscodeeditor.png (11,076 bytes)   
lazaruscodeeditor.png (11,076 bytes)   

Do-wan Kim

2013-05-28 11:42

reporter   ~0067919

It's lazarus code editor issue.

Do-wan Kim

2013-06-01 06:35

reporter   ~0067972

There is a tweak. It works fine.

...
TMyListBox=StdCtrls.TListBox;

TListBox=class(TMyListBox)
...

It can close. Thank you in advance :)

ocean

2014-03-20 17:40

reporter   ~0073865

Was about to report this.

Thanks for the workaround.

But I think this should be fixed, not closed. There should be no error.

ocean

2014-03-21 09:00

reporter  

finddeclarationtool.pas.patch (791 bytes)   
Index: components/codetools/finddeclarationtool.pas
===================================================================
--- components/codetools/finddeclarationtool.pas	(revision 44470)
+++ components/codetools/finddeclarationtool.pas	(working copy)
@@ -5768,13 +5768,6 @@
     AtomIsIdentifierE;
     AncestorStartPos:=CurPos.StartPos;
   end;
-  if (ClassIdentNode<>nil)
-  and (ClassIdentNode.Desc=ctnTypeDefinition)
-  and (CompareIdentifiers(@Src[AncestorStartPos],@Src[ClassIdentNode.StartPos])=0)
-  then begin
-    MoveCursorToCleanPos(AncestorStartPos);
-    RaiseException('ancestor has same name as class');
-  end;
   {$IFDEF ShowTriedContexts}
   DebugLn('[TFindDeclarationTool.FindAncestorOfClass] ',
   ' search ancestor class = ',GetIdentifier(@Src[AncestorStartPos]));

ocean

2014-03-21 09:01

reporter   ~0073873

Attached "removal patch" seems to also fix related issue

Do-wan Kim

2014-03-24 10:13

reporter  

finddeclarationtool-dotname.pas.patch (1,048 bytes)   
Index: finddeclarationtool.pas
===================================================================
--- finddeclarationtool.pas	(revision 44501)
+++ finddeclarationtool.pas	(working copy)
@@ -5735,6 +5735,7 @@
   AncestorNode, ClassNode, ClassIdentNode: TCodeTreeNode;
   AncestorContext: TFindContext;
   AncestorStartPos: LongInt;
+  AncestorHasDot: Boolean;
 begin
   {$IFDEF CheckNodeTool}CheckNodeTool(IdentifierNode);{$ENDIF}
   if (IdentifierNode=nil)
@@ -5767,10 +5768,15 @@
     ReadNextAtom;
     AtomIsIdentifierE;
     AncestorStartPos:=CurPos.StartPos;
-  end;
+    AncestorHasDot:=True;
+  end else
+    AncestorHasDot:=False;
   if (ClassIdentNode<>nil)
   and (ClassIdentNode.Desc=ctnTypeDefinition)
-  and (CompareIdentifiers(@Src[AncestorStartPos],@Src[ClassIdentNode.StartPos])=0)
+  and (
+    (CompareIdentifiers(@Src[AncestorStartPos],@Src[ClassIdentNode.StartPos])=0)
+    and not AncestorHasDot
+      )
   then begin
     MoveCursorToCleanPos(AncestorStartPos);
     RaiseException('ancestor has same name as class');

Juha Manninen

2014-03-24 23:32

developer   ~0073946

If only there were competing patches in every bug report. :)
I applied ocean's version because it came first and it removed useless code.
Thanks both.

Do-wan Kim

2014-03-24 23:50

reporter   ~0073949

Thank you :)

Issue History

Date Modified Username Field Change
2013-05-28 11:39 Do-wan Kim New Issue
2013-05-28 11:39 Do-wan Kim File Added: lazaruscodeeditor.png
2013-05-28 11:42 Do-wan Kim Note Added: 0067919
2013-05-30 17:48 Jonas Maebe Project FPC => Lazarus
2013-05-30 17:48 Jonas Maebe Category Misc => General
2013-06-01 06:35 Do-wan Kim Note Added: 0067972
2014-03-20 17:40 ocean Note Added: 0073865
2014-03-20 22:18 Juha Manninen Relationship added related to 0023550
2014-03-21 09:00 ocean File Added: finddeclarationtool.pas.patch
2014-03-21 09:01 ocean Note Added: 0073873
2014-03-21 13:02 Martin Friebe LazTarget => -
2014-03-21 13:02 Martin Friebe Category General => IDE
2014-03-21 13:02 Martin Friebe Product Version 2.7.1 =>
2014-03-21 13:02 Martin Friebe Summary Code editor error "Error: ancestor has same name as class" => patch / codetool "Error: ancestor has same name as class"
2014-03-24 10:13 Do-wan Kim File Added: finddeclarationtool-dotname.pas.patch
2014-03-24 17:46 Juha Manninen Assigned To => Juha Manninen
2014-03-24 17:46 Juha Manninen Status new => assigned
2014-03-24 23:32 Juha Manninen Fixed in Revision => r44513
2014-03-24 23:32 Juha Manninen Note Added: 0073946
2014-03-24 23:32 Juha Manninen Status assigned => resolved
2014-03-24 23:32 Juha Manninen Resolution open => fixed
2014-03-24 23:50 Do-wan Kim Note Added: 0073949
2014-03-24 23:50 Do-wan Kim Status resolved => closed