View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0038145 | FPC | Compiler | public | 2020-11-28 09:23 | 2020-11-29 17:43 |
Reporter | avk | Assigned To | Sven Barth | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | any | OS | any | ||
Product Version | 3.3.1 | ||||
Fixed in Version | 3.3.1 | ||||
Summary | 0038145: Generic specialization problem | ||||
Description | Generic cannot be specialized with a short string of non-standard length if it contains operators for casting to the type of a formal parameter. program test; {$mode delphi} type TMyWrap<T> = record Value: T; class operator Explicit(const w: TMyWrap<T>): T; class operator Implicit(const w: TMyWrap<T>): T; end; class operator TMyWrap<T>.Explicit(const w: TMyWrap<T>): T; begin Result := w.Value; end; class operator TMyWrap<T>.Implicit(const w: TMyWrap<T>): T; begin Result := w.Value; end; type //TString = string[255]; //compiles TString = string[254]; //not compiles var MySpec: TMyWrap<TString>; begin end. and another mode: program test; {$mode objfpc}{$modeswitch advancedrecords} type generic TMyWrap<T> = record Value: T; class operator Explicit(const w: TMyWrap): T; class operator :=(const w: TMyWrap): T; end; class operator TMyWrap.Explicit(const w: TMyWrap): T; begin Result := w.Value; end; class operator TMyWrap.:=(const w: TMyWrap): T; begin Result := w.Value; end; type //TString = string[255]; //compiles TString = string[254]; //not compiles var MySpec: specialize TMyWrap<TString>; begin end. | ||||
Steps To Reproduce | Try to compile the provided examples. | ||||
Tags | generics | ||||
Fixed in Revision | 47634 | ||||
FPCOldBugId | |||||
FPCTarget | - | ||||
Attached Files |
|
|
Please note that this is not specific to generics: this will fail for any assignment operator to a ShortString with a specified length <> 255. Considering that Delphi allows such code I've raised the issue on Core. |
|
Please test and close if okay. |
|
Thank you very much! |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-11-28 09:23 | avk | New Issue | |
2020-11-28 09:24 | avk | Tag Attached: generics | |
2020-11-28 17:02 | Sven Barth | Note Added: 0127243 | |
2020-11-29 16:48 | Sven Barth | Assigned To | => Sven Barth |
2020-11-29 16:48 | Sven Barth | Status | new => resolved |
2020-11-29 16:48 | Sven Barth | Resolution | open => fixed |
2020-11-29 16:48 | Sven Barth | Fixed in Version | => 3.3.1 |
2020-11-29 16:48 | Sven Barth | Fixed in Revision | => 47634 |
2020-11-29 16:48 | Sven Barth | FPCTarget | => - |
2020-11-29 16:48 | Sven Barth | Note Added: 0127256 | |
2020-11-29 17:43 | avk | Status | resolved => closed |
2020-11-29 17:43 | avk | Note Added: 0127258 |