Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49faa92

Browse files
authored
Merge branch 'master' into indexer
2 parents37517de +9512ed1 commit49faa92

File tree

14 files changed

+93
-61
lines changed

14 files changed

+93
-61
lines changed

‎attributions.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ This is for those who contributed language features, compiler improvements, or i
3131
-[Gustavo Leon](https://github.com/gmpl)
3232
-[Steffen Forkmann](https://github.com/forki)
3333
-[Libo Zeng](https://github.com/liboz)
34+
-[Rikki Gibson](https://github.com/RikkiGibson)
3435

3536
**SRTP Improvements**
3637

@@ -85,6 +86,11 @@ This is for those who contributed Visual Studio IDE features and platform suppor
8586
* Separate color themes for light and dark mode -[Jakub Majocha](https://github.com/majocha)
8687
* Semantic highlighting -[Vasily Kirichenko](https://github.com/vasily-kirichenko) and[Jared Hester](github.com/cloudroutine)
8788
* ReSharper-like ordering in Completion lists -[Vasily Kirichenko](https://github.com/vasily-kirichenko)
89+
* Collapse to Definition -[Vasily Kirichenko](https://github.com/vasily-kirichenko)
90+
* Support for Editor Settings -[Jakub Majocha](https://github.com/majocha)
91+
* Localized Go to Definition Status Bar -[Saul Rennison](https://github.com/saul)
92+
* R#-like completion for items in unopened namespaces -[Vasily Kirichenko](https://github.com/vasily-kirichenko)
93+
* Wrap XML docs -[Jakub Majocha](https://github.com/majocha)
8894

8995
**Project System**
9096

@@ -106,6 +112,8 @@ This is for those who contributed Visual Studio IDE features and platform suppor
106112
* Add open Statement Analyzer and Codefix -[Vasily Kirichenko](https://github.com/vasily-kirichenko)
107113
* Simplify Name Analyzer and Codefix -[Vasily Kirichenko](https://github.com/vasily-kirichenko)
108114
* Gray Out Unused Values -[Vasily Kirichenko](https://github.com/vasily-kirichenko)
115+
* Unused Declarations Analyzer and Codefix -[Vasily Kirichenko](https://github.com/vasily-kirichenko)
116+
* Add reference to\<assembly\> analyzer and codefix -[Saul Rennison](https://github.com/saul)
109117

110118
###.NET Core Support
111119

@@ -123,4 +131,4 @@ Infrastructure isn't the sexiest stuff in the world, but it's absolutely necessa
123131
*[Zp Babbi](https://github.com/zpbappi)
124132
*[Gauthier Segay](https://github.com/smoothdeveloper)
125133
*[Jared Hester](github.com/cloudroutine)
126-
*[Cameron Taggert](https://github.com/ctaggart)
134+
*[Cameron Taggert](https://github.com/ctaggart)

‎src/fsharp/CompileOps.fs‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -625,14 +625,11 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) =
625625
os.Append(ConstraintSolverMissingConstraintE().Format(NicePrint.stringOfTyparConstraint denv(tpr,tpc)))|> ignore
626626
if m.StartLine<> m2.StartLinethen
627627
os.Append(SeeAlsoE().Format(stringOfRange m))|> ignore
628-
| ConstraintSolverTypesNotInEqualityRelation(denv,(TType_measure_as t1),(TType_measure_as t2),m,m2,contextInfo)->
628+
| ConstraintSolverTypesNotInEqualityRelation(denv,(TType_measure_as t1),(TType_measure_as t2),m,m2,_)->
629629
// REVIEW: consider if we need to show _cxs (the type parameter constraints)
630630
lett1,t2,_cxs= NicePrint.minimalStringsOfTwoTypes denv t1 t2
631631

632-
match contextInfowith
633-
| ContextInfo.OmittedElseBranch rangewhen range= m-> os.Append(FSComp.SR.missingElseBranch(t2))|> ignore
634-
| ContextInfo.ElseBranchResult rangewhen range= m-> os.Append(FSComp.SR.elseBranchHasWrongType(t1,t2))|> ignore
635-
|_-> os.Append(ConstraintSolverTypesNotInEqualityRelation1E().Format t1 t2)|> ignore
632+
os.Append(ConstraintSolverTypesNotInEqualityRelation1E().Format t1 t2)|> ignore
636633

637634
if m.StartLine<> m2.StartLinethen
638635
os.Append(SeeAlsoE().Format(stringOfRange m))|> ignore
@@ -641,6 +638,12 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) =
641638
lett1,t2,_cxs= NicePrint.minimalStringsOfTwoTypes denv t1 t2
642639

643640
match contextInfowith
641+
| ContextInfo.IfExpression rangewhen range= m-> os.Append(FSComp.SR.ifExpression(t1,t2))|> ignore
642+
| ContextInfo.CollectionElement(isArray,range)when range= m->
643+
if isArraythen
644+
os.Append(FSComp.SR.arrayElementHasWrongType(t1,t2))|> ignore
645+
else
646+
os.Append(FSComp.SR.listElementHasWrongType(t1,t2))|> ignore
644647
| ContextInfo.OmittedElseBranch rangewhen range= m-> os.Append(FSComp.SR.missingElseBranch(t2))|> ignore
645648
| ContextInfo.ElseBranchResult rangewhen range= m-> os.Append(FSComp.SR.elseBranchHasWrongType(t1,t2))|> ignore
646649
|_-> os.Append(ConstraintSolverTypesNotInEqualityRelation2E().Format t1 t2)|> ignore
@@ -666,6 +669,12 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) =
666669
&& typeEquiv g t2 t2'->
667670
lett1,t2,tpcs= NicePrint.minimalStringsOfTwoTypes denv t1 t2
668671
match contextInfowith
672+
| ContextInfo.IfExpression rangewhen range= m-> os.Append(FSComp.SR.ifExpression(t1,t2))|> ignore
673+
| ContextInfo.CollectionElement(isArray,range)when range= m->
674+
if isArraythen
675+
os.Append(FSComp.SR.arrayElementHasWrongType(t1,t2))|> ignore
676+
else
677+
os.Append(FSComp.SR.listElementHasWrongType(t1,t2))|> ignore
669678
| ContextInfo.OmittedElseBranch rangewhen range= m-> os.Append(FSComp.SR.missingElseBranch(t2))|> ignore
670679
| ContextInfo.ElseBranchResult rangewhen range= m-> os.Append(FSComp.SR.elseBranchHasWrongType(t1,t2))|> ignore
671680
| ContextInfo.TupleInRecordFields->

‎src/fsharp/ConstraintSolver.fs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ let FreshenMethInfo m (minfo:MethInfo) =
117117
typeContextInfo=
118118
/// No context was given.
119119
| NoContext
120+
/// The type equation comes from an IF expression.
121+
| IfExpressionofrange
120122
/// The type equation comes from an omitted else branch.
121123
| OmittedElseBranchofrange
122124
/// The type equation comes from a type check of the result of an else branch.
@@ -125,6 +127,8 @@ type ContextInfo =
125127
| RecordFields
126128
/// The type equation comes from the verification of a tuple in record fields.
127129
| TupleInRecordFields
130+
/// The type equation comes from a list or array constructor
131+
| CollectionElementofbool*range
128132
/// The type equation comes from a return in a computation expression.
129133
| ReturnInComputationExpression
130134
/// The type equation comes from a yield in a computation expression.

‎src/fsharp/ConstraintSolver.fsi‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ val FreshenMethInfo : range -> MethInfo -> TType list
5252
type ContextInfo=
5353
/// No context was given.
5454
| NoContext
55+
/// The type equation comes from an IF expression.
56+
| IfExpressionofrange
5557
/// The type equation comes from an omitted else branch.
5658
| OmittedElseBranchofrange
5759
/// The type equation comes from a type check of the result of an else branch.
@@ -60,6 +62,8 @@ type ContextInfo =
6062
| RecordFields
6163
/// The type equation comes from the verification of a tuple in record fields.
6264
| TupleInRecordFields
65+
/// The type equation comes from a list or array constructor
66+
| CollectionElementofbool*range
6367
/// The type equation comes from a return in a computation expression.
6468
| ReturnInComputationExpression
6569
/// The type equation comes from a yield in a computation expression.

‎src/fsharp/FSComp.txt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ undefinedNameTypeParameter,"The type parameter %s is not defined."
1717
undefinedNamePatternDiscriminator,"The pattern discriminator '%s' is not defined."
1818
replaceWithSuggestion,"Replace with '%s'"
1919
addIndexerDot,"Add . for indexer access."
20+
listElementHasWrongType,"All elements of a list constructor expression must have the same type. This expression was expected to have type '%s', but here has type '%s'."
21+
arrayElementHasWrongType,"All elements of an array constructor expression must have the same type. This expression was expected to have type '%s', but here has type '%s'."
2022
missingElseBranch,"The 'if' expression is missing an 'else' branch. The 'then' branch has type '%s'. Because 'if' is an expression, and not a statement, add an 'else' branch which returns a value of the same type."
21-
elseBranchHasWrongType,"All branches of an 'if' expression must return the same type. This expression was expected to have type '%s' but here has type '%s'."
23+
ifExpression,"The 'if' expression needs to have type '%s' to satisfy context type requirements. It currently has type '%s'."
24+
elseBranchHasWrongType,"All branches of an 'if' expression must return the same type. This expression was expected to have type '%s', but here has type '%s'."
2225
commaInsteadOfSemicolonInRecord,"A ';' is used to separate field values in records. Consider replacing ',' with ';'."
2326
derefInsteadOfNot,"The '!' operator is used to dereference a ref cell. Consider using 'not expr' here."
2427
buildUnexpectedTypeArgs,"The non-generic type '%s' does not expect any type arguments, but here is given %d type argument(s)"

‎src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.targets‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
5151
<FSharpCoreImplicitPackageVersion>4.2.*</FSharpCoreImplicitPackageVersion>
5252
</PropertyGroup>
5353

54-
<PropertyGroupCondition=" '$(DisableImplcitSystemValueTupleReference)' != 'true'">
54+
<PropertyGroupCondition=" '$(DisableImplicitSystemValueTupleReference)' != 'true'">
5555
<_FrameworkNeedsValueTupleReferenceCondition=" $(TargetFramework.StartsWith(netcoreapp1.)) or $(TargetFramework.StartsWith(netstandard1.))">true</_FrameworkNeedsValueTupleReference>
5656
<_FrameworkNeedsValueTupleReferenceCondition=" '$(TargetFramework)' == 'net40' or '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'net46' or '$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'net47'">true</_FrameworkNeedsValueTupleReference>
5757
</PropertyGroup>
5858

5959
<ItemGroup>
60-
<PackageReferenceInclude="System.ValueTuple"Version="4.*"Condition=" '$(DisableImplcitSystemValueTupleReference)' != 'true' and '$(_FrameworkNeedsValueTupleReference)' == 'true'"></PackageReference>
61-
<PackageReferenceInclude="FSharp.Core"Version="$(FSharpCoreImplicitPackageVersion)"Condition=" '$(DisableImplcitSystemValueTupleReference)' != 'true'"></PackageReference>
60+
<PackageReferenceInclude="System.ValueTuple"Version="4.*"Condition=" '$(DisableImplicitSystemValueTupleReference)' != 'true' and '$(_FrameworkNeedsValueTupleReference)' == 'true'"></PackageReference>
61+
<PackageReferenceInclude="FSharp.Core"Version="$(FSharpCoreImplicitPackageVersion)"Condition=" '$(DisableImplicitFSharpCoreReference)' != 'true'"></PackageReference>
6262
</ItemGroup>
6363

6464
</Project>

‎src/fsharp/TypeChecker.fs‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5716,7 +5716,15 @@ and TcExprUndelayed cenv overallTy env tpenv (expr: SynExpr) =
57165716

57175717
// Always allow subsumption if a nominal type is known prior to type checking any arguments
57185718
let flex = not (isTyparTy cenv.g argty)
5719-
let args',tpenv = List.mapFold (TcExprFlex cenv flex argty env) tpenv args
5719+
let first = ref true
5720+
let getInitEnv m =
5721+
if !first then
5722+
first := false
5723+
env
5724+
else
5725+
{ env with eContextInfo = ContextInfo.CollectionElement (isArray,m) }
5726+
5727+
let args',tpenv = List.mapFold (fun tpenv (x:SynExpr) -> TcExprFlex cenv flex argty (getInitEnv x.Range) tpenv x) tpenv args
57205728

57215729
let expr =
57225730
if isArray then Expr.Op(TOp.Array, [argty],args',m)
@@ -5873,12 +5881,19 @@ and TcExprUndelayed cenv overallTy env tpenv (expr: SynExpr) =
58735881
| SynExpr.IfThenElse (e1,e2,e3opt,spIfToThen,isRecovery,mIfToThen,m) ->
58745882
let e1',tpenv = TcExprThatCantBeCtorBody cenv cenv.g.bool_ty env tpenv e1
58755883
let e2',tpenv =
5884+
let env =
5885+
match env.eContextInfo with
5886+
| ContextInfo.ElseBranchResult _ -> { env with eContextInfo = ContextInfo.ElseBranchResult e2.Range }
5887+
| _ ->
5888+
match e3opt with
5889+
| None -> { env with eContextInfo = ContextInfo.OmittedElseBranch e2.Range }
5890+
| _ -> { env with eContextInfo = ContextInfo.IfExpression e2.Range }
5891+
58765892
if not isRecovery && Option.isNone e3opt then
5877-
let env = { env with eContextInfo = ContextInfo.OmittedElseBranch e2.Range}
58785893
UnifyTypes cenv env m cenv.g.unit_ty overallTy
5879-
TcExprThatCanBeCtorBody cenv overallTy env tpenv e2
5880-
else
5881-
TcExprThatCanBeCtorBody cenv overallTy env tpenv e2
5894+
5895+
TcExprThatCanBeCtorBody cenv overallTy env tpenv e2
5896+
58825897
let e3',sp2,tpenv =
58835898
match e3opt with
58845899
| None ->
@@ -5887,6 +5902,7 @@ and TcExprUndelayed cenv overallTy env tpenv (expr: SynExpr) =
58875902
let env = { env with eContextInfo = ContextInfo.ElseBranchResult e3.Range }
58885903
let e3',tpenv = TcExprThatCanBeCtorBody cenv overallTy env tpenv e3
58895904
e3',SequencePointAtTarget,tpenv
5905+
58905906
primMkCond spIfToThen SequencePointAtTarget sp2 m overallTy e1' e2' e3', tpenv
58915907

58925908
// This is for internal use in the libraries only

‎tests/fsharp/typecheck/sigs/neg20.bsl‎

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -69,35 +69,17 @@ neg20.fs(53,38,53,39): typecheck error FS0001: This expression was expected to h
6969
but here has type
7070
'int'
7171

72-
neg20.fs(60,26,60,33): typecheck error FS0001: This expression was expectedto have type
73-
'B'
74-
but here has type
75-
'A'
72+
neg20.fs(60,26,60,33): typecheck error FS0001: All elements of a list constructor expression must have the same type. This expression was expectedto have type 'B', but here has type 'A'.
7673

77-
neg20.fs(61,27,61,35): typecheck error FS0001: This expression was expectedto have type
78-
'B1'
79-
but here has type
80-
'B2'
74+
neg20.fs(61,27,61,35): typecheck error FS0001: All elements of a list constructor expression must have the same type. This expression was expectedto have type 'B1', but here has type 'B2'.
8175

82-
neg20.fs(62,26,62,33): typecheck error FS0001: This expression was expectedto have type
83-
'C'
84-
but here has type
85-
'B'
76+
neg20.fs(62,26,62,33): typecheck error FS0001: All elements of a list constructor expression must have the same type. This expression was expectedto have type 'C', but here has type 'B'.
8677

87-
neg20.fs(66,25,66,32): typecheck error FS0001: This expression was expectedto have type
88-
'A'
89-
but here has type
90-
'B'
78+
neg20.fs(66,25,66,32): typecheck error FS0001: All elements of a list constructor expression must have the same type. This expression was expectedto have type 'A', but here has type 'B'.
9179

92-
neg20.fs(67,27,67,34): typecheck error FS0001: This expression was expectedto have type
93-
'B'
94-
but here has type
95-
'C'
80+
neg20.fs(67,27,67,34): typecheck error FS0001: All elements of a list constructor expression must have the same type. This expression was expectedto have type 'B', but here has type 'C'.
9681

97-
neg20.fs(70,31,70,38): typecheck error FS0001: This expression was expectedto have type
98-
'B'
99-
but here has type
100-
'C'
82+
neg20.fs(70,31,70,38): typecheck error FS0001: All elements of a list constructor expression must have the same type. This expression was expectedto have type 'B', but here has type 'C'.
10183

10284
neg20.fs(71,34,71,42): typecheck error FS0001: Type mismatch. Expecting a
10385
'A list'
@@ -128,7 +110,7 @@ but given a
128110
'B list'
129111
The type 'A' doesnot match the type 'B'
130112

131-
neg20.fs(83,47,83,54): typecheck error FS0001: All branches of an 'if' expression mustreturn the same type. This expression was expectedto have type 'B' but here has type 'C'.
113+
neg20.fs(83,47,83,54): typecheck error FS0001: All branches of an 'if' expression mustreturn the same type. This expression was expectedto have type 'B', but here has type 'C'.
132114

133115
neg20.fs(87,54,87,61): typecheck error FS0001: This expression was expectedto have type
134116
'B'
@@ -150,10 +132,7 @@ neg20.fs(97,26,97,33): typecheck error FS0001: This expression was expected to h
150132
but here has type
151133
'B'
152134

153-
neg20.fs(99,26,99,33): typecheck error FS0001: This expression was expectedto have type
154-
'B'
155-
but here has type
156-
'A'
135+
neg20.fs(99,26,99,33): typecheck error FS0001: All elements of a list constructor expression must have the same type. This expression was expectedto have type 'B', but here has type 'A'.
157136

158137
neg20.fs(108,12,108,16): typecheck error FS0001: Type mismatch. Expecting a
159138
'B* B-> 'a'

‎tests/fsharp/typecheck/sigs/neg21.bsl‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,11 @@ but given a
1717
'float<s ^4>'
1818
The unit of measure 's ^3' doesnot match the unit of measure 's ^4'
1919

20-
neg21.fs(19,59,19,67): typecheck error FS0001: Type mismatch. Expecting a
21-
'area'
22-
but given a
23-
'float<m ^3>'
24-
The unit of measure 'sqrm' doesnot match the unit of measure 'm ^3'
20+
neg21.fs(19,59,19,67): typecheck error FS0001: The unit of measure 'sqrm' doesnot match the unit of measure 'm ^3'
2521

26-
neg21.fs(20,36,20,44): typecheck error FS0001: Type mismatch. Expecting a
27-
'area'
28-
but given a
29-
'float<m ^3>'
30-
The unit of measure 'sqrm' doesnot match the unit of measure 'm ^3'
22+
neg21.fs(20,36,20,44): typecheck error FS0001: The unit of measure 'sqrm' doesnot match the unit of measure 'm ^3'
3123

32-
neg21.fs(21,53,21,59): typecheck error FS0001: Type mismatch. Expecting a
33-
'float<s ^2>'
34-
but given a
35-
'float<m>'
36-
The unit of measure 's ^2' doesnot match the unit of measure 'm'
24+
neg21.fs(21,53,21,59): typecheck error FS0001: The unit of measure 's ^2' doesnot match the unit of measure 'm'
3725

3826
neg21.fs(22,17,22,21): typecheck error FS0001: The unit of measure 's ^4' doesnot match the unit of measure 'sqrm'
3927

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #Warnings
2+
//<Expects status="Error" id="FS0001">The 'if' expression needs to have type 'bool'</Expects>
3+
4+
letx=1
5+
lety:bool=
6+
if x=2then"A"
7+
else"B"
8+
9+
exit0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp