Skip to content

Commit 2f270f2

Browse files
authored
Merge pull request #7241 from dotnet/merges/master-to-release/dev16.3
Merge master to release/dev16.3
2 parents f720c73 + c7cd220 commit 2f270f2

12 files changed

Lines changed: 119 additions & 83 deletions

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<ProductDependencies>
44
</ProductDependencies>
55
<ToolsetDependencies>
6-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.19362.5">
6+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.19364.1">
77
<Uri>https://github.com/dotnet/arcade</Uri>
8-
<Sha>15f50ca6a9d0b441c9927421657fb9dc91206cc9</Sha>
8+
<Sha>0c81c2bbdc49749e9940bc8858ebd16026d51277</Sha>
99
</Dependency>
1010
</ToolsetDependencies>
1111
</Dependencies>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
},
1212
"msbuild-sdks": {
13-
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19362.5",
13+
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19364.1",
1414
"Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2"
1515
}
1616
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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.Compiler.SourceCodeServices
7+
8+
[<TestFixture>]
9+
module ``Constructor`` =
10+
11+
[<Test>]
12+
let ``Invalid Record``() =
13+
CompilerAssert.TypeCheckWithErrors
14+
"""
15+
type Record = {field1:int; field2:int}
16+
let doSomething (xs) = List.map (fun {field1=x} -> x) xs
17+
18+
doSomething {Record.field1=0; field2=0}
19+
"""
20+
[|
21+
FSharpErrorSeverity.Error, 1, (5, 13, 5, 40), "This expression was expected to have type\n 'Record list' \nbut here has type\n 'Record' "
22+
FSharpErrorSeverity.Warning, 20, (5, 1, 5, 40), "The result of this expression has type 'int list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'."
23+
|]
24+
25+
[<Test>]
26+
let ``Comma In Rec Ctor``() =
27+
CompilerAssert.TypeCheckWithErrors
28+
"""
29+
type Person = { Name : string; Age : int; City : string }
30+
let x = { Name = "Isaac", Age = 21, City = "London" }
31+
"""
32+
[|
33+
FSharpErrorSeverity.Error, 1, (3, 18, 3, 52), "This expression was expected to have type\n 'string' \nbut here has type\n ''a * 'b * 'c' \r\nA ';' is used to separate field values in records. Consider replacing ',' with ';'."
34+
FSharpErrorSeverity.Error, 764, (3, 9, 3, 54), "No assignment given for field 'Age' of type 'Test.Person'"
35+
|]
36+
37+
[<Test>]
38+
let ``Missing Comma In Ctor``() =
39+
CompilerAssert.TypeCheckWithErrors
40+
"""
41+
type Person() =
42+
member val Name = "" with get,set
43+
member val Age = 0 with get,set
44+
45+
let p =
46+
Person(Name = "Fred"
47+
Age = 18)
48+
"""
49+
[|
50+
FSharpErrorSeverity.Error, 39, (7, 12, 7, 16), "The value or constructor 'Name' is not defined."
51+
FSharpErrorSeverity.Warning, 20, (7, 12, 7, 25), "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'."
52+
FSharpErrorSeverity.Error, 39, (8, 12, 8, 15), "The value or constructor 'Age' is not defined."
53+
FSharpErrorSeverity.Error, 501, (7, 5, 8, 21), "The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'. If some of the arguments are meant to assign values to properties, consider separating those arguments with a comma (',')."
54+
|]
55+
56+
[<Test>]
57+
let ``Missing Ctor Value``() =
58+
CompilerAssert.TypeCheckSingleError
59+
"""
60+
type Person(x:int) =
61+
member val Name = "" with get,set
62+
member val Age = x with get,set
63+
64+
let p =
65+
Person(Name = "Fred",
66+
Age = 18)
67+
"""
68+
FSharpErrorSeverity.Error
69+
496
70+
(7, 5, 8, 21)
71+
"The member or object constructor 'Person' requires 1 argument(s). The required signature is 'new : x:int -> Person'."
72+
73+
[<Test>]
74+
let ``Extra Argument In Ctor``() =
75+
CompilerAssert.TypeCheckSingleError
76+
"""
77+
type Person() =
78+
member val Name = "" with get,set
79+
member val Age = 0 with get,set
80+
81+
let p =
82+
Person(1)
83+
"""
84+
FSharpErrorSeverity.Error
85+
501
86+
(7, 5, 7, 14)
87+
"The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'."
88+
89+
[<Test>]
90+
let ``Extra Argument In Ctor2``() =
91+
CompilerAssert.TypeCheckSingleError
92+
"""
93+
type Person() =
94+
member val Name = "" with get,set
95+
member val Age = 0 with get,set
96+
97+
let b = 1
98+
99+
let p =
100+
Person(1=b)
101+
"""
102+
FSharpErrorSeverity.Error
103+
501
104+
(9, 5, 9, 16)
105+
"The object constructor 'Person' takes 0 argument(s) but is here given 1. The required signature is 'new : unit -> Person'."
106+
107+
[<Test>]
108+
let ``Valid Comma In Rec Ctor``() =
109+
CompilerAssert.Pass
110+
"""
111+
type Person = { Name : string * bool * bool }
112+
let Age = 22
113+
let City = "London"
114+
let x = { Name = "Isaac", Age = 21, City = "London" }
115+
"""

tests/fsharp/FSharpSuite.Tests.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<Compile Include="tests.fs" />
3434
<Compile Include="Compiler\ILChecker.fs" />
3535
<Compile Include="Compiler\CompilerAssert.fs" />
36+
<Compile Include="Compiler\ErrorMessages\ConstructorTests.fs" />
3637
<Compile Include="Compiler\ErrorMessages\AccessOfTypeAbbreviationTests.fs" />
3738
<Compile Include="Compiler\ErrorMessages\ElseBranchHasWrongTypeTests.fs" />
3839
<Compile Include="Compiler\ErrorMessages\MissingElseBranch.fs" />

tests/fsharpqa/Source/Warnings/CommaInRecCtor.fs

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/fsharpqa/Source/Warnings/ExtraArgumentInCtor.fs

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/fsharpqa/Source/Warnings/ExtraArgumentInCtor2.fs

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/fsharpqa/Source/Warnings/InvalidRecord.fs

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/fsharpqa/Source/Warnings/MissingCommaInCtor.fs

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/fsharpqa/Source/Warnings/MissingCtorValue.fs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)