Browse Source

+ added

git-svn-id: trunk@3028 -
Jonas Maebe 19 years ago
parent
commit
9c14f95ce9
2 changed files with 41 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 40 0
      tests/webtbs/tw4678.pp

+ 1 - 0
.gitattributes

@@ -6750,6 +6750,7 @@ tests/webtbs/tw4635.pp svneol=native#text/plain
 tests/webtbs/tw4640.pp svneol=native#text/plain
 tests/webtbs/tw4640.pp svneol=native#text/plain
 tests/webtbs/tw4669.pp svneol=native#text/plain
 tests/webtbs/tw4669.pp svneol=native#text/plain
 tests/webtbs/tw4675.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/tw4700.pp svneol=native#text/plain
 tests/webtbs/tw4704.pp -text
 tests/webtbs/tw4704.pp -text
 tests/webtbs/tw4763.pp svneol=native#text/plain
 tests/webtbs/tw4763.pp svneol=native#text/plain

+ 40 - 0
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: [email protected] }
+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.
+
+