View Issue Details

IDProjectCategoryView StatusLast Update
0036947LazarusIDEpublic2020-11-17 20:35
ReporterCyrax Assigned ToPascal Riekenberg  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformLinux x86_64OSArch 
Product Version2.1 (SVN) 
Summary0036947: Codetools doesn't have support for class threadvar variable definition, thus "Find declaration" etc. fails to work.
Description"Error: expected procedure, but threadvar found" is error message which shows itself on the message window when trying to use "Find declaration" etc. functionalities in source code where have a class threadvar defined.
TagsNo tags attached.
Fixed in Revision64146
LazTarget2.2
WidgetsetGTK 2
Attached Files

Activities

Juha Manninen

2020-04-21 22:03

developer   ~0122330

Codetools recognizes "class var" inside a class'es private section but not "class threadvar".

Delcio Sbeghen

2020-11-11 22:54

reporter   ~0126842

Possible fix attached.
codetools.patch (1,477 bytes)   
Index: components/codetools/codetree.pas
===================================================================
--- components/codetools/codetree.pas	(revision 64125)
+++ components/codetools/codetree.pas	(working copy)
@@ -107,7 +107,7 @@
   ctnClassInheritance   = 44;
   ctnHelperFor          = 45;//class/record/type helper for, only child is ctnIdentifier
   ctnClassGUID          = 46;
-  ctnClassClassVar      = 47; // child of visibility section
+  ctnClassClassVar      = 47; // child of visibility section (var and threadvar)
   ctnClassPrivate       = 48; // child of AllClassObjects
   ctnClassProtected     = 49;
   ctnClassPublic        = 50;
Index: components/codetools/pascalparsertool.pas
===================================================================
--- components/codetools/pascalparsertool.pas	(revision 64125)
+++ components/codetools/pascalparsertool.pas	(working copy)
@@ -1256,6 +1256,7 @@
 {
   var
   class var
+  class threadvar
 }
 begin
   if CurNode.Desc in AllClassSubSections then begin
@@ -1283,6 +1284,7 @@
     class destructor
     class operator
     class var
+    class threadvar
 }
 begin
   Result:=false;
@@ -1294,7 +1296,7 @@
   end else if UpAtomIs('PROPERTY') then begin
     UndoReadNextAtom;
     Result:=KeyWordFuncClassProperty;
-  end else if UpAtomIs('VAR') then begin
+  end else if UpAtomIs('VAR') or UpAtomIs('THREADVAR')then begin
     UndoReadNextAtom;
     Result:=KeyWordFuncClassVarSection;
   end else
codetools.patch (1,477 bytes)   

Pascal Riekenberg

2020-11-12 10:25

developer   ~0126851

Thanks for the patch. Are you able to provide a test or at least a minimal code sample of the problem?

Sven Barth

2020-11-12 14:10

manager   ~0126860

You can use the tests that were added for this feature:
- for classes: https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/tests/test/tclass16.pp?view=markup&pathrev=39288
- for records: https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/tests/test/terecs20.pp?view=markup&pathrev=39289

Delcio Sbeghen

2020-11-12 18:14

reporter   ~0126866

Last edited: 2020-11-12 18:25

View 3 revisions

program Project1;
type
  TTestClass = class
    private class threadvar
      foo:Boolean;
  end;

begin
//
end.

Before patch:
Call "Find procedure definition" on any code produce below message in Messages window and break functionality of code tools:
  
   Codetools, Errors: 1
   project1.lpr(5,13) Error: expected procedure, but threadvar found

After patch:
 No error occurs.

Pascal Riekenberg

2020-11-17 20:35

developer   ~0127016

Applied. Thanks for the patch and sample.

Issue History

Date Modified Username Field Change
2020-04-21 20:46 Cyrax New Issue
2020-04-21 22:03 Juha Manninen Status new => confirmed
2020-04-21 22:03 Juha Manninen LazTarget => -
2020-04-21 22:03 Juha Manninen Note Added: 0122330
2020-07-30 09:33 Pascal Riekenberg Assigned To => Pascal Riekenberg
2020-07-30 09:33 Pascal Riekenberg Status confirmed => assigned
2020-11-11 22:54 Delcio Sbeghen Note Added: 0126842
2020-11-11 22:54 Delcio Sbeghen File Added: codetools.patch
2020-11-12 10:25 Pascal Riekenberg Note Added: 0126851
2020-11-12 14:10 Sven Barth Note Added: 0126860
2020-11-12 18:14 Delcio Sbeghen Note Added: 0126866
2020-11-12 18:24 Delcio Sbeghen Note Edited: 0126866 View Revisions
2020-11-12 18:25 Delcio Sbeghen Note Edited: 0126866 View Revisions
2020-11-17 20:35 Pascal Riekenberg Status assigned => resolved
2020-11-17 20:35 Pascal Riekenberg Resolution open => fixed
2020-11-17 20:35 Pascal Riekenberg Fixed in Revision => 64146
2020-11-17 20:35 Pascal Riekenberg LazTarget - => 2.2
2020-11-17 20:35 Pascal Riekenberg Widgetset GTK 2 => GTK 2
2020-11-17 20:35 Pascal Riekenberg Note Added: 0127016