diff --git a/.gitattributes b/.gitattributes index 1f0674029e..434f6f62c0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15247,6 +15247,8 @@ tests/webtbs/tw30443.pp svneol=native#text/plain tests/webtbs/tw3045.pp svneol=native#text/plain tests/webtbs/tw3048.pp svneol=native#text/plain tests/webtbs/tw30522.pp svneol=native#text/plain +tests/webtbs/tw30524a.pp svneol=native#text/pascal +tests/webtbs/tw30524b.pp svneol=native#text/pascal tests/webtbs/tw30530.pp svneol=native#text/pascal tests/webtbs/tw30534.pp svneol=native#text/pascal tests/webtbs/tw30537.pp svneol=native#text/pascal diff --git a/tests/webtbs/tw30524a.pp b/tests/webtbs/tw30524a.pp new file mode 100644 index 0000000000..b96160c760 --- /dev/null +++ b/tests/webtbs/tw30524a.pp @@ -0,0 +1,42 @@ +{ %NORUN } + +program tw30524a; + +{$ifdef FPC} +{$MODE DELPHI} +{$endif} + +{uses + Generics.Defaults;} + +type + Tuple = record + Item1: T; + class operator Equal( a, b: Tuple ): Boolean; // FPC Error: Compilation raised exception internally + class operator NotEqual( a, b: Tuple ): Boolean; + end; + + Tuple = record + class function Create( Item1: T ): Tuple; overload; static; + end; + +class function Tuple.Create( Item1: T ): Tuple; +begin + Result.Item1 := Item1; +end; + +class operator Tuple.Equal( a, b: Tuple ): Boolean; +begin + Result := False;//TEqualityComparer.Default.Equals( a.Item1, b.Item1 ); +end; + +class operator Tuple.NotEqual( a, b: Tuple ): Boolean; +begin + Result := not( a = b ); +end; + +var + t: Tuple; +begin + t := Tuple.Create(42); +end. diff --git a/tests/webtbs/tw30524b.pp b/tests/webtbs/tw30524b.pp new file mode 100644 index 0000000000..203056b84c --- /dev/null +++ b/tests/webtbs/tw30524b.pp @@ -0,0 +1,41 @@ +{ %NORUN } + +program tw30524b; + +{$MODE objfpc} +{$modeswitch advancedrecords} + +{uses + Generics.Defaults;} + +type + generic Tuple = record + Item1: T; + class operator =( a, b: specialize Tuple ): Boolean; // FPC Error: Compilation raised exception internally + class operator <>( a, b: specialize Tuple ): Boolean; + end; + + TTuple = record + generic class function Create( Item1: T ): specialize Tuple; overload; static; + end; + +generic class function TTuple.Create( Item1: T ): specialize Tuple; +begin + Result.Item1 := Item1; +end; + +class operator Tuple.=( a, b: specialize Tuple ): Boolean; +begin + Result := False;//TEqualityComparer.Default.Equals( a.Item1, b.Item1 ); +end; + +class operator Tuple.<>( a, b: specialize Tuple ): Boolean; +begin + Result := not( a = b ); +end; + +var + t: specialize Tuple; +begin + t := TTuple.specialize Create(42); +end.