View Issue Details

IDProjectCategoryView StatusLast Update
0037919pas2jstranspilerpublic2020-11-03 12:54
Reporterhenrique Assigned ToMattias Gaertner  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformPas2JsOSWindows 
Summary0037919: Optimizer is removing class declaration
DescriptionWhen I declare a custom attribute, the optimizer is removing the declaration from the class in the final generated file.

I've set up an example with the problem occurring.
TagsNo tags attached.
Fixed in Revision47283.
Attached Files

Activities

henrique

2020-10-13 20:35

reporter  

Error.zip (510 bytes)

Mattias Gaertner

2020-10-28 22:05

manager   ~0126619

I compiled your example and I see in the Error.js:
$r.attr = [$mod.Attribute,"Create"];

What is missing?

henrique

2020-10-28 22:16

reporter   ~0126623

The class of the atrribute is missing, in the generated file.

Sven Barth

2020-10-30 15:03

developer   ~0126660

I've attached an example that shows this as a runtime exception (except if the assignment to "m" is enabled)
tattr.pp (579 bytes)   
program tattr;

{$mode objfpc}
{$modeswitch prefixedattributes}

uses
  Rtti;

type
  MyAttribute = class(TCustomAttribute)
  end;

  [MyAttribute]
  TTest = class

  end;

var
  context: TRTTIContext;
  t: TRttiType;
  attrs: TCustomAttributeArray;
  attr: TCustomAttribute;
  m: MyAttribute;
begin
  //m := MyAttribute.Create;
  context := TRTTIContext.Create;
  try
    t := context.GetType(TTest);
    attrs := t.GetAttributes;
    for attr in attrs do begin
      Writeln(attr.ClassName);
    end;
  finally
    context.Free;
  end;
end.
tattr.pp (579 bytes)   

Issue History

Date Modified Username Field Change
2020-10-13 20:35 henrique New Issue
2020-10-13 20:35 henrique File Added: Error.zip
2020-10-13 22:26 Mattias Gaertner Assigned To => Mattias Gaertner
2020-10-13 22:26 Mattias Gaertner Status new => assigned
2020-10-28 22:05 Mattias Gaertner Status assigned => feedback
2020-10-28 22:05 Mattias Gaertner Note Added: 0126619
2020-10-28 22:12 henrique Status feedback => assigned
2020-10-28 22:16 henrique Note Added: 0126623
2020-10-30 14:39 Mattias Gaertner Status assigned => confirmed
2020-10-30 15:03 Sven Barth Note Added: 0126660
2020-10-30 15:03 Sven Barth File Added: tattr.pp
2020-11-02 16:04 Mattias Gaertner Status confirmed => resolved
2020-11-02 16:04 Mattias Gaertner Resolution open => fixed
2020-11-02 16:04 Mattias Gaertner Fixed in Revision => 47283.