View Issue Details

IDProjectCategoryView StatusLast Update
0026326FPCCompilerpublic2019-12-28 18:59
ReporterZex Atilla Assigned ToFlorian  
Status resolvedResolutionfixed 
Product Version2.6.2 
Fixed in Version3.3.1 
Summary0026326: Invalid message "Local variable is assigned but never used"
DescriptionIn this example the compiler will report that aForm is declared but not used, even though it was used.

procedure Test (aObject: TObject);
  aForm: TForm;
  aEvent: TNotifyEvent;
  if (aObject is TForm) then
    aForm := aObject as TForm;
    aEvent := @aForm.OnClick;
Steps To ReproduceSample Lazarus project attached.
TagsNo tags attached.
Fixed in Revision43804
Attached Files


Zex Atilla

2014-06-11 15:17

reporter (128,913 bytes)

Anton Kavalenka

2014-06-11 22:09

reporter   ~0075633

aEvent obviously assigned and never used

Zex Atilla

2014-06-12 17:18

reporter   ~0075641

Doesn't matter if you use aEvent or not, the compiler reports that aForm is not used. And aForm was used.

Serge Anvarov

2019-02-25 18:53

reporter   ~0114421

Similar invalid message "Value parameter "Obj" is assigned but never used"

  TSimpleMethod = procedure of object;

procedure DoMethod(Method: TSimpleMethod);

procedure Test(Obj: TObject);

The bug is still not fixed, even in FPC 3.1.1

jamie philbrook

2019-02-26 00:07

reporter   ~0114437

This is what you call a language barrier. And I am not talking about pascal/Fpc
 If you put $100 in the bank and never take any amount of it out to spend it
on something, it has not been used!
 In this case, assigning aForm to an object is the same as giving aform something, but, as you can see in the code, it was never referenced to be

 If aForm was never given anything then it would be Declared like an empy
bank account but not assigned, nothing put into it.

 As for the above example, I suppose that could be an issue..

Issue History

Date Modified Username Field Change
2014-06-11 15:17 Zex Atilla New Issue
2014-06-11 15:17 Zex Atilla File Added:
2014-06-11 22:09 Anton Kavalenka Note Added: 0075633
2014-06-12 17:18 Zex Atilla Note Added: 0075641
2019-02-25 18:53 Serge Anvarov Note Added: 0114421
2019-02-26 00:07 jamie philbrook Note Added: 0114437
2019-12-28 18:59 Florian Assigned To => Florian
2019-12-28 18:59 Florian Status new => resolved
2019-12-28 18:59 Florian Resolution open => fixed
2019-12-28 18:59 Florian Fixed in Version => 3.3.1
2019-12-28 19:00 Florian Fixed in Revision => 43804
2019-12-28 19:00 Florian FPCTarget => -