View Issue Details

IDProjectCategoryView StatusLast Update
0038957LazarusIDEpublic2021-06-13 09:23
ReporterBart Broersma Assigned To 
Status newResolutionopen 
Product Version2.1 (SVN) 
Summary0038957: CodeTools trips over System.UITypes
DescriptionIf a source file has System.UITypes in it's uses clause, CodeTools trip over it whenever it is invoked:

system.uitypes.pp(183,9) Error: Case only allowed in records
Steps To Reproduce| Indicates the position of the Caret:

{$mode objfpc}{$H+}

    Classes, SysUtils, System.UITypes;


After writing the opening bracket for writeln(), CodeTools just trip.
TagsNo tags attached.
Fixed in Revision
Attached Files


related to 0038995 closedJuha Manninen [patch] JCF can't format System.UITypes operator := and case in records. 


jamie philbrook

2021-06-03 10:36

reporter   ~0131136

It's the Record being used in the system.uitype.

Same type record fails anywhere so its not restricted to the system.uitypes file..

The record has a VAR just before the CASE within the record, code tools does not like it, thinks it is looking at a VAR section and a case does not belong there.

create a record with Const fields and then VAR and Case following, you get the same error in local file.

Juha Manninen

2021-06-11 10:00

developer   ~0131254

Last edited: 2021-06-11 10:02

View 2 revisions

This shorter record is enough to reproduce the issue :
  TColorRec = record
      case Integer of
        0: {$IFDEF ENDIAN_BIG}
            (A,B,G,R : Byte);
            (R,G,B,A : Byte);
        1: (Color : TColor);

I debugged using the attached patch. Surprisingly the results differ between mode objfpc and mode delphi. Node descriptors differ and error messages differ.
 With mode objfpc :
  KeyWordFuncTypeRecordCase: CurNode=50, CurNode.Parent=74, CurNode.Parent.Parent=20
  ### TCodeToolManager.HandleException: [20170421195408] "expected :, but case found" at Line=19 Col=7 in "unit1.pas"
 With mode delphi :
  KeyWordFuncTypeRecordCase: CurNode=11, CurNode.Parent=50, CurNode.Parent.Parent=74
  ### TCodeToolManager.HandleException: [20170421195148] "Case only allowed in records" at Line=19 Col=7 in "unit1.pas"

This is what the numbers mean :
 ctnVarSection = 11
 ctnTypeDefinition = 20
 ctnClassPublic = 50
 ctnRecordType = 74

The descriptor ctnClassPublic (50) is wrong IMO. This is a record, not a class.
0001-Debug-KeyWordFuncTypeRecordCase.patch (1,050 bytes)   
From 678305ae5f2ae7abd8f3663bb1e3e5daf0d360fd Mon Sep 17 00:00:00 2001
From: Juha <>
Date: Fri, 11 Jun 2021 12:46:03 +0300
Subject: [PATCH] Debug KeyWordFuncTypeRecordCase.

 components/codetools/pascalparsertool.pas | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas
index 73391284d..6c14e8d78 100644
--- a/components/codetools/pascalparsertool.pas
+++ b/components/codetools/pascalparsertool.pas
@@ -5199,6 +5199,9 @@ begin
   if not UpAtomIs('CASE') then
     SaveRaiseException(20170421195151,'[TPascalParserTool.KeyWordFuncTypeRecordCase] '
       +'internal error');
+  DebugLn(['KeyWordFuncTypeRecordCase: CurNode=', CurNode.Desc,
+                             ', CurNode.Parent=', CurNode.Parent.Desc,
+                      ', CurNode.Parent.Parent=', CurNode.Parent.Parent.Desc]);
   if (CurNode.Desc=ctnRecordVariant)
   or ((CurNode.Desc in AllClassSections)
       and (CurNode.Parent.Desc=ctnRecordType))

Issue History

Date Modified Username Field Change
2021-06-02 20:47 Bart Broersma New Issue
2021-06-02 20:48 Bart Broersma Summary CodeTools trip over SystemUITypes => CodeTools trips over System.UIType
2021-06-02 20:48 Bart Broersma LazTarget => -
2021-06-02 21:27 Maxim Ganetsky Summary CodeTools trips over System.UIType => CodeTools trips over System.UITypes
2021-06-03 10:36 jamie philbrook Note Added: 0131136
2021-06-11 10:00 Juha Manninen Note Added: 0131254
2021-06-11 10:00 Juha Manninen File Added: 0001-Debug-KeyWordFuncTypeRecordCase.patch
2021-06-11 10:02 Juha Manninen Note Edited: 0131254 View Revisions
2021-06-13 09:23 Juha Manninen Relationship added related to 0038995