Casting a block calls the block

I am pretty sure, that when I try to cast the block without parameters to a block with parameters, it gets called during the cast (throws exception in the cast).

The example is relatively complicated:
type
[CallingConvention(CallingConvention.Stdcall)]
fptrInitGL = public method (hWnd: rtl.HWND);

  Program = class
  public
class var XXX: fptrInitGL;

class method Main(args: array of String): Int32;
begin
  // add your own code here
  var libra := rtl.LoadLibrary ("D:\AGKDevelopment\apps\OxyAGK\Final\OxyAGKlib.dll");
  if libra = nil then writeLn ("Library failed to load.");

  var funInitGL := rtl.GetProcAddress (libra, "AGK_InitGL");

  // this cast fails, as funInitGL block is called instead of casted.
  Program.XXX := fptrInitGL (funInitGL);

  // this is an ugly working workaround ... maybe there is better one???
  var BBB := ^fptrInitGL (@funInitGL);
  Program.XXX := BBB^;
end;

What platform (I assume Island?) and sub-platform?

Island, Win 32, Elements 10 unstable

1 Like

Thanks, logged as bugs://79577

bugs://79577 got closed with status fixed.