mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-10 23:38:06 +02:00
+ add test for fixed #40011
This commit is contained in:
parent
b7608b045b
commit
291d2e911a
35
tests/webtbs/tw40011.pp
Normal file
35
tests/webtbs/tw40011.pp
Normal file
@ -0,0 +1,35 @@
|
||||
program tw40011;
|
||||
|
||||
{$mode delphi}
|
||||
{$modeswitch nestedprocvars}
|
||||
{$modeswitch anonymousfunctions}
|
||||
|
||||
type
|
||||
TFuncNested = function (const P1: String): String is nested;
|
||||
|
||||
TMyClass = class
|
||||
class function CallFn(const A: String; const Fn: TFuncNested): String;
|
||||
class function Test(const A, B: String): String;
|
||||
end;
|
||||
|
||||
class function TMyClass.CallFn(const A: String; const Fn: TFuncNested): String;
|
||||
begin
|
||||
Result := Fn(A);
|
||||
end;
|
||||
|
||||
class function TMyClass.Test(const A, B: String): String;
|
||||
begin
|
||||
Result := CallFn(A, function (const P1: String): String begin
|
||||
Result := P1 + B; // <-- SIGSEGV !!!
|
||||
end);
|
||||
end;
|
||||
|
||||
var
|
||||
Sum: String;
|
||||
begin
|
||||
Sum := TMyClass.Test('1', '2');
|
||||
if Sum <> '12' then
|
||||
Halt(1);
|
||||
WriteLn('OK');
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user