diff --git a/.gitattributes b/.gitattributes index f861fc1c21..4515df2270 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6750,6 +6750,7 @@ tests/webtbs/tw4635.pp svneol=native#text/plain tests/webtbs/tw4640.pp svneol=native#text/plain tests/webtbs/tw4669.pp svneol=native#text/plain tests/webtbs/tw4675.pp svneol=native#text/plain +tests/webtbs/tw4678.pp -text tests/webtbs/tw4700.pp svneol=native#text/plain tests/webtbs/tw4704.pp -text tests/webtbs/tw4763.pp svneol=native#text/plain diff --git a/tests/webtbs/tw4678.pp b/tests/webtbs/tw4678.pp new file mode 100644 index 0000000000..c757b0155e --- /dev/null +++ b/tests/webtbs/tw4678.pp @@ -0,0 +1,40 @@ +{ %OPT=-Sd } + +{ Source provided for Free Pascal Bug Report 4678 } +{ Submitted by "Phil H." on 2006-01-09 } +{ e-mail: pjhess@purdue.edu } +program TestVarBug2; + +uses + Variants; + +type + TMyClass = class + private + function GetValue(AnInt : Integer) : Variant; + public + property Value[AnInt : Integer] : Variant read GetValue; + end; + +function TMyClass.GetValue(AnInt : Integer) : Variant; +begin + if AnInt < 0 then + Result := Null + else + Result := AnInt; +end; + +var + AClass : TMyClass; + VarVal : Variant; +begin + AClass := TMyClass.Create; + + // This statement throws an exception with FPC. + // Should assign Null to VarVal as per Delphi rule: + // "any operation on a Null variant produces a Null variant". + VarVal := AClass.Value[5] + AClass.Value[-1] + 1; + +end. + +