EugeneK 22 Posted 4 hours ago Hi Anyone else have this error in 12.3 [dcc32 Error] Type parameter 'T' must be a non-nullable value type Works fine in 12.2, trying to isolate it now, seems to work in some places but not the others. Share this post Link to post
EugeneK 22 Posted 3 hours ago Happens when record field has an attribute unit UTestGenericsBug; interface uses System.Rtti, Data.DB; type DBField = class(TCustomAttribute) strict private FFieldType: TFieldType; FLength: Integer; public constructor Create(const AFieldType: TFieldType = ftUnknown; const ALength: Integer = 0); property FieldType: TFieldType read FFieldType; property Length: Integer read FLength; end; TTestRecord = record private [DBField(ftString, 20)] FTerminalName: string; public end; TRecordLoader<T: record> = class sealed class function Get: T; static; end; implementation constructor DBField.Create(const AFieldType: TFieldType = ftUnknown; const ALength: Integer = 0); begin end; class function TRecordLoader<T>.Get: T; begin Result := Default(T); end; function Get: TTestRecord; begin // error here Result := TRecordLoader<TTestRecord>.Get; end; end. 😒 Share this post Link to post
DelphiUdIT 214 Posted 3 hours ago TRecordLoader<T> = class sealed class function Get: T; static; If you use full generic declaration it works. Share this post Link to post
EugeneK 22 Posted 3 hours ago Just now, DelphiUdIT said: TRecordLoader<T> = class sealed class function Get: T; static; If you use full generic declaration it works. Yes I'll probably use it as a workaround, but that kind of defeats the purpose Share this post Link to post