@@ -773,20 +773,20 @@ namespace N
773
773
|> compile
774
774
|> shouldFail
775
775
|> withResults [
776
- { Error = Warning 3569
777
- Range = { StartLine = 21
778
- StartColumn = 27
779
- EndLine = 21
780
- EndColumn = 35 }
781
- Message =
782
- " The member or function 'instType' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." }
783
776
{ Error = Warning 3569
784
777
Range = { StartLine = 17
785
778
StartColumn = 32
786
779
EndLine = 17
787
780
EndColumn = 77 }
788
781
Message =
789
782
" The member or function 'instType' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." }
783
+ { Error = Warning 3569
784
+ Range = { StartLine = 21
785
+ StartColumn = 27
786
+ EndLine = 21
787
+ EndColumn = 35 }
788
+ Message =
789
+ " The member or function 'instType' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." }
790
790
]
791
791
792
792
[<FSharp.Test.FactForNETCOREAPP>]
@@ -1769,3 +1769,72 @@ module M =
1769
1769
|> withLangVersion80
1770
1770
|> compile
1771
1771
|> shouldSucceed
1772
+
1773
+ [<FSharp.Test.FactForNETCOREAPP>]
1774
+ let ``Warn successfully in Array - mapped recursive call`` () =
1775
+ """
1776
+ namespace N
1777
+
1778
+ module M =
1779
+
1780
+ type Value =
1781
+ { Code: string }
1782
+
1783
+ [<TailCall>]
1784
+ let rec fooArray (values: Value[], code: string) =
1785
+ match values with
1786
+ | [||] -> seq { code }
1787
+ | values ->
1788
+ let replicatedValues =
1789
+ values
1790
+ |> Array.map (fun value -> fooArray (values, value.Code))
1791
+ replicatedValues |> Seq.concat
1792
+ """
1793
+ |> FSharp
1794
+ |> withLangVersion80
1795
+ |> compile
1796
+ |> shouldFail
1797
+ |> withResults [
1798
+ { Error = Warning 3569
1799
+ Range = { StartLine = 16
1800
+ StartColumn = 20
1801
+ EndLine = 16
1802
+ EndColumn = 74 }
1803
+ Message =
1804
+ " The member or function 'fooArray' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." }
1805
+ ]
1806
+
1807
+ [<FSharp.Test.FactForNETCOREAPP>]
1808
+ let ``Warn successfully in Seq - mapped recursive call`` () =
1809
+ """
1810
+ namespace N
1811
+
1812
+ module M =
1813
+
1814
+ type Value =
1815
+ { Code: string }
1816
+
1817
+ [<TailCall>]
1818
+ let rec fooSeq (values: Value[], code: string) =
1819
+ match values with
1820
+ | [||] -> seq { code }
1821
+ | values ->
1822
+ let replicatedValues =
1823
+ values
1824
+ |> Seq.map (fun value -> fooSeq (values, value.Code))
1825
+ |> Seq.toArray
1826
+ replicatedValues |> Seq.concat
1827
+ """
1828
+ |> FSharp
1829
+ |> withLangVersion80
1830
+ |> compile
1831
+ |> shouldFail
1832
+ |> withResults [
1833
+ { Error = Warning 3569
1834
+ Range = { StartLine = 16
1835
+ StartColumn = 42
1836
+ EndLine = 16
1837
+ EndColumn = 48 }
1838
+ Message =
1839
+ " The member or function 'fooSeq' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." }
1840
+ ]
0 commit comments