On 21/10/2020 22:46, Ryan Joseph via fpc-pascal wrote:
>> On Oct 21, 2020, at 2:43 PM, Jonas Maebe via fpc-pascal
>> wrote:
>>
>> I tried to explain in the rest of my message why that cannot be done. It
>> might be possible in some cases, but that would just create a false
>> sense of security an
> On Oct 21, 2020, at 2:43 PM, Jonas Maebe via fpc-pascal
> wrote:
>
> I tried to explain in the rest of my message why that cannot be done. It
> might be possible in some cases, but that would just create a false
> sense of security and unpredictable results (because no compile-time
> range c
On 21/10/2020 21:34, Ryan Joseph via fpc-pascal wrote:
I thought default would just return the first value in the enum but I guess
it's just zeros. Maybe we need a better default for objfpc mode.
The first element is returned by Low(TEnum), and the first value by
Ord(Low(TEnum)).
On 21/10/2020 22:34, Ryan Joseph via fpc-pascal wrote:
>
>
>> On Oct 21, 2020, at 2:08 PM, Jonas Maebe via fpc-pascal
>> wrote:
>>
>> See https://bugs.freepascal.org/view.php?id=34972 for some comments
>> about Default. So this is a bug in the usage of Default, since Default
>> cannot be guaran
> On Oct 21, 2020, at 2:08 PM, Jonas Maebe via fpc-pascal
> wrote:
>
> See https://bugs.freepascal.org/view.php?id=34972 for some comments
> about Default. So this is a bug in the usage of Default, since Default
> cannot be guaranteed to return a valid value for a type.
I thought default woul
On 21/10/2020 21:59, Ryan Joseph via fpc-pascal wrote:
> Is this a bug in generics with default()?
>
> =
>
> type
> TEnum = (Unused = '.');
> generic TSomething = class
> function Get: T;
> end;
> TEnumeratedSomething = specialize TSomething;
>
> function TSometh
Is this a bug in generics with default()?
=
type
TEnum = (Unused = '.');
generic TSomething = class
function Get: T;
end;
TEnumeratedSomething = specialize TSomething;
function TSomething.Get: T;
begin
// Range check error while evaluating constants (0 must be