Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master to dev15.8 #5000

Merged
merged 2 commits into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,798 changes: 1,401 additions & 1,397 deletions src/buildfromsource/FSharp.Compiler.Private/FSComp.fs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/buildfromsource/FSharp.Compiler.Private/FSComp.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4152,6 +4152,9 @@
<data name="keywordDescriptionMatch" xml:space="preserve">
<value>Used to branch by comparing a value to a pattern.</value>
</data>
<data name="keywordDescriptionMatchBang" xml:space="preserve">
<value>Used in computation expressions to pattern match directly over the result of another computation expression.</value>
</data>
<data name="keywordDescriptionMember" xml:space="preserve">
<value>Used to declare a property or method in an object type.</value>
</data>
Expand Down
1 change: 1 addition & 0 deletions src/fsharp/CompileOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) =
| Parser.TOKEN_LAZY -> getErrorString("Parser.TOKEN.LAZY")
| Parser.TOKEN_OLAZY -> getErrorString("Parser.TOKEN.LAZY")
| Parser.TOKEN_MATCH -> getErrorString("Parser.TOKEN.MATCH")
| Parser.TOKEN_MATCH_BANG -> getErrorString("Parser.TOKEN.MATCH.BANG")
| Parser.TOKEN_MUTABLE -> getErrorString("Parser.TOKEN.MUTABLE")
| Parser.TOKEN_NEW -> getErrorString("Parser.TOKEN.NEW")
| Parser.TOKEN_OF -> getErrorString("Parser.TOKEN.OF")
Expand Down
1 change: 1 addition & 0 deletions src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@ keywordDescriptionLazy,"Used to specify a computation that is to be performed on
keywordDescriptionLet,"Used to associate, or bind, a name to a value or function."
keywordDescriptionLetBang,"Used in asynchronous workflows to bind a name to the result of an asynchronous computation, or, in other computation expressions, used to bind a name to a result, which is of the computation type."
keywordDescriptionMatch,"Used to branch by comparing a value to a pattern."
keywordDescriptionMatchBang,"Used in computation expressions to pattern match directly over the result of another computation expression."
keywordDescriptionMember,"Used to declare a property or method in an object type."
keywordDescriptionModule,"Used to associate a name with a group of related types, values, and functions, to logically separate it from other code."
keywordDescriptionMutable,"Used to declare a variable, that is, a value that can be changed."
Expand Down
3 changes: 3 additions & 0 deletions src/fsharp/FSStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,9 @@
<data name="Parser.TOKEN.MATCH" xml:space="preserve">
<value>keyword 'match'</value>
</data>
<data name="Parser.TOKEN.MATCH.BANG" xml:space="preserve">
<value>keyword 'match!'</value>
</data>
<data name="Parser.TOKEN.MUTABLE" xml:space="preserve">
<value>keyword 'mutable'</value>
</data>
Expand Down
37 changes: 28 additions & 9 deletions src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
<PropertyGroup>
<EnableDefaultCompileItems Condition=" '$(EnableDefaultCompileItems)' == '' ">false</EnableDefaultCompileItems> <!--- Do not glob F# source files -->
<EnableDefaultNoneItems Condition=" '$(EnableDefaultNoneItems)' == '' ">false</EnableDefaultNoneItems>
<DefaultValueTuplePackageVersion>4.3.1</DefaultValueTuplePackageVersion>
<DefaultFSharpPackageVersion>4.3.4</DefaultFSharpPackageVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -67,14 +65,35 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
<FscToolExe Condition="'$(OS)' == 'Unix' and '$(FscToolExe)' == ''">RunFsc.sh</FscToolExe>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="$(DefaultValueTuplePackageVersion)" >
<DefaultInclude>true</DefaultInclude>
</PackageReference>
<ItemGroup Condition="'$(DisableImplicitSystemValueTupleReference)' != 'true'
and ('$(TargetFrameworkIdentifier)' == '.NETStandard' or '$(TargetFrameworkIdentifier)' == '.NETCoreApp')
and !('$(_TargetFrameworkVersionWithoutV)' >= '2.0' )">
<PackageReference Include="System.ValueTuple" Version="$(ValueTupleImplicitPackageVersion)" />
</ItemGroup>

<PropertyGroup>
<DefaultValueTuplePackageVersion>4.3.1</DefaultValueTuplePackageVersion>
<DefaultFSharpCorePackageVersion>4.3.4</DefaultFSharpCorePackageVersion>
<ValueTupleImplicitPackageVersion>$(DefaultValueTuplePackageVersion)</ValueTupleImplicitPackageVersion>
<FSharpCoreImplicitPackageVersion>$(DefaultFSharpCorePackageVersion)</FSharpCoreImplicitPackageVersion>
</PropertyGroup>

<ItemGroup Condition="'$(DisableImplicitSystemValueTupleReference)' != 'true'
and ('$(TargetFrameworkIdentifier)' == '.NETFramework'
and ('$(_TargetFrameworkVersionWithoutV)' == ''
or '$(_TargetFrameworkVersionWithoutV)' == '4.0' or
'$(_TargetFrameworkVersionWithoutV)' == '4.5' or
'$(_TargetFrameworkVersionWithoutV)' == '4.5.1' or
'$(_TargetFrameworkVersionWithoutV)' == '4.5.2' or
'$(_TargetFrameworkVersionWithoutV)' == '4.6' or
'$(_TargetFrameworkVersionWithoutV)' == '4.6.1' or
'$(_TargetFrameworkVersionWithoutV)' == '4.6.2' or
'$(_TargetFrameworkVersionWithoutV)' == '4.7')) ">
<PackageReference Include="System.ValueTuple" Version="$(ValueTupleImplicitPackageVersion)" />
</ItemGroup>

<PackageReference Include="FSharp.Core" Version="$(DefaultFSharpPackageVersion)">
<DefaultInclude>true</DefaultInclude>
</PackageReference>
<ItemGroup Condition="'$(DisableImplicitFSharpCoreReference)' != 'true'">
<PackageReference Include="FSharp.Core" Version="$(FSharpCoreImplicitPackageVersion)" />
</ItemGroup>

</Project>
55 changes: 0 additions & 55 deletions src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
<_ExplicitReference Include="$(FrameworkPathOverride)\mscorlib.dll" Condition=" '$(NoStdLib)' != 'true' " />
</ItemGroup>

<PropertyGroup>
<_TargetFrameworkVersionWithoutV>$(TargetFrameworkVersion)</_TargetFrameworkVersionWithoutV>
<_TargetFrameworkVersionWithoutV Condition="$(TargetFrameworkVersion.StartsWith('v'))">$(TargetFrameworkVersion.Substring(1))</_TargetFrameworkVersionWithoutV>
</PropertyGroup>

<PropertyGroup>
<TargetProfile Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' " >mscorlib</TargetProfile>
<TargetProfile Condition=" '$(TargetFrameworkIdentifier)' != '.NETFramework' " >netcore</TargetProfile>
Expand All @@ -53,60 +48,10 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
<PackProjectInputFile>$(MSBuildProjectFullPath)</PackProjectInputFile>
</PropertyGroup>

<PropertyGroup>
<_FrameworkNeedsValueTupleReference Condition=" ('$(TargetFrameworkIdentifier)' == '.NETStandard' or '$(TargetFrameworkIdentifier)' == '.NETCoreApp') and !('$(_TargetFrameworkVersionWithoutV)' >= '2.0') ">true</_FrameworkNeedsValueTupleReference>
<_FrameworkNeedsValueTupleReference Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' and
('$(_TargetFrameworkVersionWithoutV)' == '' or
'$(_TargetFrameworkVersionWithoutV)' == '4.0' or
'$(_TargetFrameworkVersionWithoutV)' == '4.5' or
'$(_TargetFrameworkVersionWithoutV)' == '4.6' or
'$(_TargetFrameworkVersionWithoutV)' == '4.6.1' or
'$(_TargetFrameworkVersionWithoutV)' == '4.6.2' or
'$(_TargetFrameworkVersionWithoutV)' == '4.7') ">true</_FrameworkNeedsValueTupleReference>
</PropertyGroup>

<PropertyGroup>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackageFSharpDesignTimeTools</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>

<Target Name="FSharpCorePackageReferences" BeforeTargets="CollectPackageReferences;">
<ItemGroup>
<FSharpCorePackages Include="@(PackageReference)" Condition=" '%(Identity)' == 'FSharp.Core' " />
<PackageReference Update="FSharp.Core" Version="$(FSharpCoreImplicitPackageVersion)"
Condition=" ('%(PackageReference.Identity)' == 'FSharp.Core')
and ('%(PackageReference.Version)' == '$(DefaultFSharpPackageVersion)')
and ('%(PackageReference.DefaultInclude)' == 'true')
and ('$(DisableImplicitFSharpCoreReference)' != 'true')
and ('$(FSharpCoreImplicitPackageVersion)' != '')
and (@(FSharpCorePackages->Count()) == 1) " />
<PackageReference Remove="FSharp.Core"
Condition=" (('$(DisableImplicitFSharpCoreReference)' == 'true') or (@(FSharpCorePackages->Count()) &gt; 1))
and ('%(PackageReference.Identity)' == 'FSharp.Core')
and ('%(PackageReference.Version)' == '$(DefaultFSharpPackageVersion)')
and ('%(PackageReference.DefaultInclude)' == 'true') " />
</ItemGroup>
</Target>

<Target Name="ValueTuplePackageReferences" BeforeTargets="CollectPackageReferences;">
<Message Text="PackageReferences: ValueTuplePackageReferences start : @(PackageReference)" />
<ItemGroup>
<ValueTuplePackages Include="@(PackageReference)" Condition=" '%(Identity)' == 'System.ValueTuple' " />
<PackageReference Update="System.ValueTuple" Version="$(ValueTupleImplicitPackageVersion)"
Condition=" ('%(PackageReference.Identity)' == 'System.ValueTuple')
and ('%(PackageReference.Version)' == '$(DefaultValueTuplePackageVersion)')
and ('%(PackageReference.DefaultInclude)' == 'true')
and ('$(ValueTupleImplicitPackageVersion)' != '')
and ('$(DisableImplicitSystemValueTupleReference)' != 'true')
and ('$(_FrameworkNeedsValueTupleReference)' == 'true')
and (@(ValueTuplePackages->Count()) == 1) " />
<PackageReference Remove="System.ValueTuple"
Condition=" ( ('$(DisableImplicitSystemValueTupleReference)' == 'true') or ('$(_FrameworkNeedsValueTupleReference)' != 'true') or (@(ValueTuplePackages->Count()) &gt; 1) )
and ('%(PackageReference.Identity)' == 'System.ValueTuple')
and ('%(PackageReference.Version)' == '$(DefaultValueTuplePackageVersion)')
and ('%(PackageReference.DefaultInclude)' == 'true') " />
</ItemGroup>
</Target>

<Target Name="PackageFSharpDesignTimeTools" DependsOnTargets="_GetFrameworkAssemblyReferences">
<PropertyGroup>
<FSharpDesignTimeProtocol Condition = " '$(FSharpDesignTimeProtocol)' == '' ">fsharp41</FSharpDesignTimeProtocol>
Expand Down
4 changes: 2 additions & 2 deletions src/fsharp/LexFilter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ type LexFilterImpl (lightSyntaxStatus:LightSyntaxStatus, compilingFsLib, lexer,
| Parser.EOF _ -> false
| _ ->
not (isSameLine()) ||
(match peekNextToken() with TRY | MATCH | IF | LET _ | FOR | WHILE -> true | _ -> false)
(match peekNextToken() with TRY | MATCH | MATCH_BANG | IF | LET _ | FOR | WHILE -> true | _ -> false)

// Look for '=' or '.Id.id.id = ' after an identifier
let rec isLongIdentEquals token =
Expand Down Expand Up @@ -2034,7 +2034,7 @@ type LexFilterImpl (lightSyntaxStatus:LightSyntaxStatus, compilingFsLib, lexer,
pushCtxt tokenTup (CtxtIf (tokenStartPos))
returnToken tokenLexbufState token

| MATCH, _ ->
| (MATCH | MATCH_BANG), _ ->
if debug then dprintf "MATCH, pushing CtxtMatch(%a)\n" outputPos tokenStartPos
pushCtxt tokenTup (CtxtMatch (tokenStartPos))
returnToken tokenLexbufState token
Expand Down
24 changes: 19 additions & 5 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3457,7 +3457,8 @@ let (|SimpleSemicolonSequence|_|) acceptDeprecated c =
| SynExpr.Sequential (_, _, e1, e2, _) -> YieldFree e1 && YieldFree e2
| SynExpr.IfThenElse (_, e2, e3opt, _, _, _, _) -> YieldFree e2 && Option.forall YieldFree e3opt
| SynExpr.TryWith (e1, _, clauses, _, _, _, _) -> YieldFree e1 && clauses |> List.forall (fun (Clause(_, _, e, _, _)) -> YieldFree e)
| SynExpr.Match (_, _, clauses, _, _) -> clauses |> List.forall (fun (Clause(_, _, e, _, _)) -> YieldFree e)
| (SynExpr.Match (_, _, clauses, _, _) | SynExpr.MatchBang (_, _, clauses, _, _)) ->
clauses |> List.forall (fun (Clause(_, _, e, _, _)) -> YieldFree e)
| SynExpr.For (_, _, _, _, _, body, _)
| SynExpr.TryFinally (body, _, _, _, _)
| SynExpr.LetOrUse (_, _, _, body, _)
Expand All @@ -3483,6 +3484,7 @@ let (|SimpleSemicolonSequence|_|) acceptDeprecated c =
| SynExpr.YieldOrReturn _
| SynExpr.LetOrUse _
| SynExpr.Do _
| SynExpr.MatchBang _
| SynExpr.LetOrUseBang _
| SynExpr.ImplicitZero _
| SynExpr.While _ -> false
Expand Down Expand Up @@ -6040,17 +6042,19 @@ and TcExprUndelayed cenv overallTy env tpenv (expr: SynExpr) =

| SynExpr.YieldOrReturn ((isTrueYield, _), _, m)
| SynExpr.YieldOrReturnFrom ((isTrueYield, _), _, m) when isTrueYield ->
error(Error(FSComp.SR.tcConstructRequiresListArrayOrSequence(), m))
error(Error(FSComp.SR.tcConstructRequiresListArrayOrSequence(), m))
| SynExpr.YieldOrReturn ((_, isTrueReturn), _, m)
| SynExpr.YieldOrReturnFrom ((_, isTrueReturn), _, m) when isTrueReturn ->
error(Error(FSComp.SR.tcConstructRequiresComputationExpressions(), m))
error(Error(FSComp.SR.tcConstructRequiresComputationExpressions(), m))
| SynExpr.YieldOrReturn (_, _, m)
| SynExpr.YieldOrReturnFrom (_, _, m)
| SynExpr.ImplicitZero m ->
error(Error(FSComp.SR.tcConstructRequiresSequenceOrComputations(), m))
error(Error(FSComp.SR.tcConstructRequiresSequenceOrComputations(), m))
| SynExpr.DoBang (_, m)
| SynExpr.LetOrUseBang (_, _, _, _, _, _, m) ->
error(Error(FSComp.SR.tcConstructRequiresComputationExpression(), m))
error(Error(FSComp.SR.tcConstructRequiresComputationExpression(), m))
| SynExpr.MatchBang (_, _, _, _, m) ->
error(Error(FSComp.SR.tcConstructRequiresComputationExpression(), m))

/// Check lambdas as a group, to catch duplicate names in patterns
and TcIteratedLambdas cenv isFirst (env: TcEnv) overallTy takenNames tpenv e =
Expand Down Expand Up @@ -7960,6 +7964,15 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv
let clauses = clauses |> List.map (fun (Clause(pat, cond, innerComp, patm, sp)) -> Clause(pat, cond, transNoQueryOps innerComp, patm, sp))
Some(translatedCtxt (SynExpr.Match(spMatch, expr, clauses, false, m)))

// 'match! expr with pats ...' --> build.Bind(e1, (function pats ...))
| SynExpr.MatchBang (spMatch, expr, clauses, false, m) ->
let mMatch = match spMatch with SequencePointAtBinding mMatch -> mMatch | _ -> m
if isQuery then error(Error(FSComp.SR.tcMatchMayNotBeUsedWithQuery(), mMatch))
if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env mMatch ad "Bind" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Bind"), mMatch))
let clauses = clauses |> List.map (fun (Clause(pat, cond, innerComp, patm, sp)) -> Clause(pat, cond, transNoQueryOps innerComp, patm, sp))
let consumeExpr = SynExpr.MatchLambda(false, mMatch, clauses, spMatch, mMatch)
Some(translatedCtxt (mkSynCall "Bind" mMatch [expr; consumeExpr]))

| SynExpr.TryWith (innerComp, _mTryToWith, clauses, _mWithToLast, mTryToLast, spTry, _spWith) ->
let mTry = match spTry with SequencePointAtTry(m) -> m | _ -> mTryToLast

Expand Down Expand Up @@ -8766,6 +8779,7 @@ and TcItemThen cenv overallTy env tpenv (item, mItem, rest, afterResolution) del
| SynExpr.ImplicitZero _
| SynExpr.YieldOrReturn _
| SynExpr.YieldOrReturnFrom _
| SynExpr.MatchBang _
| SynExpr.LetOrUseBang _
| SynExpr.DoBang _
| SynExpr.TraitCall _
Expand Down
8 changes: 8 additions & 0 deletions src/fsharp/ast.fs
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,9 @@ and
/// Computation expressions only
| LetOrUseBang of bindSeqPoint:SequencePointInfoForBinding * isUse:bool * isFromSource:bool * SynPat * SynExpr * SynExpr * range:range

/// F# syntax: match! expr with pat1 -> expr | ... | patN -> exprN
| MatchBang of matchSeqPoint:SequencePointInfoForBinding * expr:SynExpr * clauses:SynMatchClause list * isExnMatch:bool * range:range (* bool indicates if this is an exception match in a computation expression which throws unmatched exceptions *)

/// F# syntax: do! expr
/// Computation expressions only
| DoBang of expr:SynExpr * range:range
Expand Down Expand Up @@ -779,6 +782,7 @@ and
| SynExpr.YieldOrReturn (range=m)
| SynExpr.YieldOrReturnFrom (range=m)
| SynExpr.LetOrUseBang (range=m)
| SynExpr.MatchBang (range=m)
| SynExpr.DoBang (range=m)
| SynExpr.Fixed (range=m) -> m
| SynExpr.Ident id -> id.idRange
Expand Down Expand Up @@ -839,6 +843,7 @@ and
| SynExpr.YieldOrReturn (range=m)
| SynExpr.YieldOrReturnFrom (range=m)
| SynExpr.LetOrUseBang (range=m)
| SynExpr.MatchBang (range=m)
| SynExpr.DoBang (range=m) -> m
| SynExpr.DotGet (expr,_,lidwd,m) -> if lidwd.ThereIsAnExtraDotAtTheEnd then unionRanges expr.Range lidwd.RangeSansAnyExtraDot else m
| SynExpr.LongIdent (_,lidwd,_,_) -> lidwd.RangeSansAnyExtraDot
Expand Down Expand Up @@ -901,6 +906,7 @@ and
| SynExpr.YieldOrReturn (range=m)
| SynExpr.YieldOrReturnFrom (range=m)
| SynExpr.LetOrUseBang (range=m)
| SynExpr.MatchBang (range=m)
| SynExpr.DoBang (range=m) -> m
// these are better than just .Range, and also commonly applicable inside queries
| SynExpr.Paren(_,m,_,_) -> m
Expand Down Expand Up @@ -2397,6 +2403,8 @@ let rec synExprContainsError inpExpr =
| SynExpr.DotNamedIndexedPropertySet (e1,_,e2,e3,_) ->
walkExpr e1 || walkExpr e2 || walkExpr e3

| SynExpr.MatchBang (_,e,cl,_,_) ->
walkExpr e || walkMatchClauses cl
| SynExpr.LetOrUseBang (_,_,_,_,e1,e2,_) ->
walkExpr e1 || walkExpr e2
walkExpr inpExpr
2 changes: 2 additions & 0 deletions src/fsharp/lex.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ rule token args skip = parse
{ YIELD_BANG(true) }
| "return!"
{ YIELD_BANG(false) }
| "match!"
{ MATCH_BANG }
| ident '!'
{ let tok = Keywords.KeywordOrIdentifierToken args lexbuf (lexemeTrimRight lexbuf 1)
match tok with
Expand Down
1 change: 1 addition & 0 deletions src/fsharp/lexhelp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ module Keywords =
"let", FSComp.SR.keywordDescriptionLet()
"let!", FSComp.SR.keywordDescriptionLetBang()
"match", FSComp.SR.keywordDescriptionMatch()
"match!", FSComp.SR.keywordDescriptionMatchBang()
"member", FSComp.SR.keywordDescriptionMember()
"module", FSComp.SR.keywordDescriptionModule()
"mutable", FSComp.SR.keywordDescriptionMutable()
Expand Down
Loading