File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2+
3+ namespace FSharp.Compiler.UnitTests
4+
5+ open NUnit.Framework
6+ open FSharp.TestHelpers
7+
8+ module ` `Dictionary Tests`` =
9+
10+ [<Test>]
11+ let ``Assigning to dictionary should compile`` () =
12+ // Regression test for FSHARP1.0:5365
13+
14+ CompilerAssert.Pass
15+ """
16+ module N.M
17+
18+ open System
19+ open System.Collections.Generic
20+
21+ type ICloneable<'a> =
22+ abstract Clone : unit -> 'a
23+
24+ type DictionaryFeature<'key> (dict: IDictionary<'key, int>) =
25+ member this.Add key value =
26+ dict.[key] <- value
27+ """
28+
29+ [<Test>]
30+ let ``Assigning to dictionary with type constraint should compile`` () =
31+ // Regression test for FSHARP1.0:5365
32+ // Used to give error: value must be local and mutable in order to mutate the contents of a value type, e.g. 'let mutable x = ...'
33+
34+ CompilerAssert.Pass
35+ """
36+ module N.M
37+
38+ open System
39+ open System.Collections.Generic
40+
41+ type ICloneable<'a> =
42+ abstract Clone : unit -> 'a
43+
44+ type DictionaryFeature<'key, 'dict when 'dict :> IDictionary<'key, int> and 'dict :> ICloneable<'dict>> (dict: 'dict) =
45+ member this.Add key value =
46+ dict.[key] <- value
47+ """
Original file line number Diff line number Diff line change 7979 <Compile Include =" Compiler\Libraries\Core\Collections\MapTests.fs" />
8080 <Compile Include =" Compiler\Libraries\Core\Collections\CollectionTests.fs" />
8181 <Compile Include =" Compiler\Libraries\Core\Collections\ListTests.fs" />
82+ <Compile Include =" Compiler\Libraries\Core\ExtraTopLevelOperators\DictionaryTests.fs" />
8283 <None Include =" app.config" />
8384 <None Include =" update.base.line.with.actuals.fsx" />
8485
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments