View Issue Details

IDProjectCategoryView StatusLast Update
0037426FPCCompilerpublic2021-04-04 11:22
ReporterBart Broersma Assigned ToSven Barth  
Status closedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0037426: Internal error 200109221 on Byte.SetBit in a method
DescriptionThis program will trigger an internal error 200109221.

{$mode objfpc}
  SysUtils, Classes;

  { TFoo }

  TFoo = class
    procedure Bar;

  AByte: Byte;

{ TFoo }

procedure TFoo.Bar;
  AByte := Byte.SetBit(1);


Steps To ReproduceCompile with either trunk or 3.2.0
Additional InformationThe error seems to be only triggered is the offending code (AByte := Byte.SetBit(1)) is part of a classes method.
In a regular procedure it just fails compilation with "Error: Illegal expression"

Discussed on forum:,50705.0.html
TagsNo tags attached.
Fixed in Revision49102
Attached Files


Bart Broersma

2020-07-28 09:05

reporter   ~0124359

Summary should read: Internal error 200109221 on Byte.SetBit in a class method

Thaddy de Koning

2020-07-28 13:18

reporter   ~0124360

Last edited: 2020-07-28 13:20

View 2 revisions

I was never aware setbit() could be used on types. That is not how I designed it. It is meant to be used on vars.
That aside, an internal error should never happen.
Can I have some feedback on how this happened at all? It is not what I wrote.
Bart, do you have more info? You were involved in the original discussion.

It is all simple bit manipulation and should never fail.

Sven Barth

2020-07-29 14:03

manager   ~0124393

@Thaddy: as I wrote on the forum, it's a compiler bug as it shouldn't allow the use of instance methods on the type itself. instead the compiler should error out with "illegal expression" or similar.

jamie philbrook

2020-07-29 22:41

reporter   ~0124405

I would of expected it to start with a 0 value when a Type is used..

 It only makes sense because this way you can assign a byte something from this helper and if you use the TYPE instead of a identifier I expected it to assume a ZERO value to start with and then set the bit..

 Because as pointed out if you do 0.SetBit(1) it does create an entity to start with and so why can't using a TYPE generate a default value, in this case a 0 ?

 Maybe I am expecting too much

Sven Barth

2020-07-30 07:40

manager   ~0124408

Yes, you are expecting too much. Class methods can be used on the type only, instance methods can not.

Sven Barth

2021-04-02 17:25

manager   ~0130044

Please test and close if okay.

Bart Broersma

2021-04-04 11:22

reporter   ~0130072

Compiler now says:
Compiling test.pas
test.pas(24,26) Error: Only class methods, class properties and class variables can be referred with class references
test.pas(30) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted

Issue History

Date Modified Username Field Change
2020-07-27 22:19 Bart Broersma New Issue
2020-07-28 09:05 Bart Broersma Note Added: 0124359
2020-07-28 13:18 Thaddy de Koning Note Added: 0124360
2020-07-28 13:20 Thaddy de Koning Note Edited: 0124360 View Revisions
2020-07-29 14:03 Sven Barth Note Added: 0124393
2020-07-29 22:41 jamie philbrook Note Added: 0124405
2020-07-30 07:40 Sven Barth Note Added: 0124408
2021-04-02 17:25 Sven Barth Assigned To => Sven Barth
2021-04-02 17:25 Sven Barth Status new => resolved
2021-04-02 17:25 Sven Barth Resolution open => fixed
2021-04-02 17:25 Sven Barth Fixed in Version => 3.3.1
2021-04-02 17:25 Sven Barth Fixed in Revision => 49102
2021-04-02 17:25 Sven Barth FPCTarget => -
2021-04-02 17:25 Sven Barth Note Added: 0130044
2021-04-04 11:22 Bart Broersma Status resolved => closed
2021-04-04 11:22 Bart Broersma Note Added: 0130072