Playing a bit with generics now and having a weird issue, it seems like
specialize cannot be called in
except...end block? I mean, on one hand it feels like a bug, but on the other - I guess I could understand why.
program Project1;
generic function Foo<T>: String;
begin
Exit('Bar');
end;
begin
try
WriteLn(specialize Foo<Integer>); // this one works
except
WriteLn(specialize Foo<Integer>); // Error: Identifier not found "specialize"
end;
end.
Now the fun part that if we wrap generic specialization into a regular function it works without issues:
program Project1;
generic function Foo<T>: String;
begin
Exit('Bar');
end;
function FooBar: String; inline;
begin
Exit(specialize Foo<Integer>);
end;
begin
try
WriteLn(FooBar); // this works
except
WriteLn(FooBar); // this works too
end;
end.
Free Pascal Compiler version 3.3.1-15296-g6a28ac53da [2024/02/27]