diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md index fd28a3c2736..9abf960b75f 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md @@ -20,3 +20,4 @@ ### Changed * Improve error of Active Pattern case Argument Count Not Match ([PR #16846](https://github.com/dotnet/fsharp/pull/16846)) +* Reduce allocations in compiler checking via `ValueOption` usage ([PR #16822](https://github.com/dotnet/fsharp/pull/16822)) diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index 596ea9f085d..823eb4ccbf1 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -616,10 +616,11 @@ module OldStyleMessages = let mutable showParserStackOnParseError = false #endif +[] let (|InvalidArgument|_|) (exn: exn) = match exn with - | :? ArgumentException as e -> Some e.Message - | _ -> None + | :? ArgumentException as e -> ValueSome e.Message + | _ -> ValueNone let OutputNameSuggestions (os: StringBuilder) suggestNames suggestionsF idText = if suggestNames then diff --git a/src/Compiler/Driver/CreateILModule.fs b/src/Compiler/Driver/CreateILModule.fs index 04cda7f6c3f..506171ed0ef 100644 --- a/src/Compiler/Driver/CreateILModule.fs +++ b/src/Compiler/Driver/CreateILModule.fs @@ -54,11 +54,12 @@ module AttributeHelpers = | Some(Attrib(_, _, [ AttribBoolArg p ], _, _, _, _)) -> Some p | _ -> None + [] let (|ILVersion|_|) (versionString: string) = try - Some(parseILVersion versionString) + ValueSome(parseILVersion versionString) with e -> - None + ValueNone //---------------------------------------------------------------------------- // ValidateKeySigningAttributes, GetStrongNameSigner diff --git a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs index c19edc6ac57..e64a64e2ace 100644 --- a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs +++ b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs @@ -330,7 +330,8 @@ let visitNameofResult (nameofResult: NameofResult) : FileContentEntry = FileContentEntry.PrefixedIdentifier(longIdentToPath false longIdent) /// Special case of `nameof Module` type of expression -let (|NameofExpr|_|) (e: SynExpr) : NameofResult option = +[] +let (|NameofExpr|_|) (e: SynExpr) : NameofResult voption = let rec stripParen (e: SynExpr) = match e with | SynExpr.Paren(expr = expr) -> stripParen expr @@ -339,15 +340,15 @@ let (|NameofExpr|_|) (e: SynExpr) : NameofResult option = match e with | SynExpr.App(flag = ExprAtomicFlag.NonAtomic; isInfix = false; funcExpr = SynExpr.Ident NameofIdent; argExpr = moduleNameExpr) -> match stripParen moduleNameExpr with - | SynExpr.Ident moduleNameIdent -> Some(NameofResult.SingleIdent moduleNameIdent) + | SynExpr.Ident moduleNameIdent -> ValueSome(NameofResult.SingleIdent moduleNameIdent) | SynExpr.LongIdent(longDotId = longIdent) -> match longIdent.LongIdent with - | [] -> None + | [] -> ValueNone // This is highly unlikely to be produced by the parser - | [ moduleNameIdent ] -> Some(NameofResult.SingleIdent moduleNameIdent) - | lid -> Some(NameofResult.LongIdent(lid)) - | _ -> None - | _ -> None + | [ moduleNameIdent ] -> ValueSome(NameofResult.SingleIdent moduleNameIdent) + | lid -> ValueSome(NameofResult.LongIdent(lid)) + | _ -> ValueNone + | _ -> ValueNone let visitSynExpr (e: SynExpr) : FileContentEntry list = let rec visit (e: SynExpr) (continuation: FileContentEntry list -> FileContentEntry list) : FileContentEntry list = @@ -566,6 +567,7 @@ let visitSynExpr (e: SynExpr) : FileContentEntry list = visit e id /// Special case of `| nameof Module ->` type of pattern +[] let (|NameofPat|_|) (pat: SynPat) = let rec stripPats p = match p with @@ -582,11 +584,11 @@ let (|NameofPat|_|) (pat: SynPat) = argPats = SynArgPats.Pats [] accessibility = None) -> match longIdent with - | [] -> None - | [ moduleNameIdent ] -> Some(NameofResult.SingleIdent moduleNameIdent) - | lid -> Some(NameofResult.LongIdent lid) - | _ -> None - | _ -> None + | [] -> ValueNone + | [ moduleNameIdent ] -> ValueSome(NameofResult.SingleIdent moduleNameIdent) + | lid -> ValueSome(NameofResult.LongIdent lid) + | _ -> ValueNone + | _ -> ValueNone let visitPat (p: SynPat) : FileContentEntry list = let rec visit (p: SynPat) (continuation: FileContentEntry list -> FileContentEntry list) : FileContentEntry list = diff --git a/src/Compiler/Facilities/AsyncMemoize.fs b/src/Compiler/Facilities/AsyncMemoize.fs index 7e6bed533e9..1adcf5f8b89 100644 --- a/src/Compiler/Facilities/AsyncMemoize.fs +++ b/src/Compiler/Facilities/AsyncMemoize.fs @@ -30,15 +30,16 @@ module internal Utils = let replayDiagnostics (logger: DiagnosticsLogger) = Seq.iter ((<|) logger.DiagnosticSink) + [] let (|TaskCancelled|_|) (ex: exn) = match ex with - | :? System.Threading.Tasks.TaskCanceledException as tce -> Some tce + | :? System.Threading.Tasks.TaskCanceledException as tce -> ValueSome tce //| :? System.AggregateException as ae -> // if ae.InnerExceptions |> Seq.forall (fun e -> e :? System.Threading.Tasks.TaskCanceledException) then // ae.InnerExceptions |> Seq.tryHead |> Option.map (fun e -> e :?> System.Threading.Tasks.TaskCanceledException) // else // None - | _ -> None + | _ -> ValueNone type internal StateUpdate<'TValue> = | CancelRequest diff --git a/src/Compiler/Facilities/AsyncMemoize.fsi b/src/Compiler/Facilities/AsyncMemoize.fsi index 9c317749464..ea7ede2ebb8 100644 --- a/src/Compiler/Facilities/AsyncMemoize.fsi +++ b/src/Compiler/Facilities/AsyncMemoize.fsi @@ -9,7 +9,8 @@ module internal Utils = /// Return file name with one directory above it val shortPath: path: string -> string - val (|TaskCancelled|_|): ex: exn -> TaskCanceledException option + [] + val (|TaskCancelled|_|): ex: exn -> TaskCanceledException voption type internal JobEvent = | Requested diff --git a/src/Compiler/Facilities/DiagnosticsLogger.fs b/src/Compiler/Facilities/DiagnosticsLogger.fs index d93a3a60b6c..443282ffe95 100644 --- a/src/Compiler/Facilities/DiagnosticsLogger.fs +++ b/src/Compiler/Facilities/DiagnosticsLogger.fs @@ -69,10 +69,11 @@ exception StopProcessingExn of exn option with | StopProcessingExn(Some exn) -> "StopProcessingExn, originally (" + exn.ToString() + ")" | _ -> "StopProcessingExn" +[] let (|StopProcessing|_|) exn = match exn with - | StopProcessingExn _ -> Some() - | _ -> None + | StopProcessingExn _ -> ValueSome() + | _ -> ValueNone let StopProcessing<'T> = StopProcessingExn None diff --git a/src/Compiler/Facilities/DiagnosticsLogger.fsi b/src/Compiler/Facilities/DiagnosticsLogger.fsi index ec2d37bc040..453e7d4c605 100644 --- a/src/Compiler/Facilities/DiagnosticsLogger.fsi +++ b/src/Compiler/Facilities/DiagnosticsLogger.fsi @@ -39,7 +39,8 @@ val NoSuggestions: Suggestions /// Thrown when we stop processing the F# Interactive entry or #load. exception StopProcessingExn of exn option -val (|StopProcessing|_|): exn: exn -> unit option +[] +val (|StopProcessing|_|): exn: exn -> unit voption val StopProcessing<'T> : exn diff --git a/src/Compiler/Symbols/SymbolHelpers.fs b/src/Compiler/Symbols/SymbolHelpers.fs index af89176ff6e..1584e096edd 100644 --- a/src/Compiler/Symbols/SymbolHelpers.fs +++ b/src/Compiler/Symbols/SymbolHelpers.fs @@ -356,12 +356,13 @@ module internal SymbolHelpers = [ for tp, ty in prettyTyparInst -> wordL (tagTypeParameter ("'" + tp.DisplayName)) ^^ wordL (tagText (FSComp.SR.descriptionWordIs())) ^^ NicePrint.layoutType denv ty ] + [] let (|ItemWhereTypIsPreferred|_|) item = match item with | Item.DelegateCtor ty | Item.CtorGroup(_, [DefaultStructCtor(_, ty)]) - | Item.Types(_, [ty]) -> Some ty - | _ -> None + | Item.Types(_, [ty]) -> ValueSome ty + | _ -> ValueNone /// Specifies functions for comparing 'Item' objects with respect to the user /// (this means that some values that are not technically equal are treated as equal @@ -730,19 +731,21 @@ module internal SymbolHelpers = #if !NO_TYPEPROVIDERS /// Determine if an item is a provided type + [] let (|ItemIsProvidedType|_|) g item = match item with | Item.Types(_name, tys) -> match tys with | [AppTy g (tcref, _typeInst)] -> if tcref.IsProvidedErasedTycon || tcref.IsProvidedGeneratedTycon then - Some tcref + ValueSome tcref else - None - | _ -> None - | _ -> None + ValueNone + | _ -> ValueNone + | _ -> ValueNone /// Determine if an item is a provided type that has static parameters + [] let (|ItemIsProvidedTypeWithStaticArguments|_|) m g item = match item with | Item.Types(_name, tys) -> @@ -755,31 +758,33 @@ module internal SymbolHelpers = | _ -> failwith "unreachable" let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments, provider) -> typeBeforeArguments.GetStaticParameters provider), range=m) let staticParameters = staticParameters.PApplyArray(id, "GetStaticParameters", m) - Some staticParameters + ValueSome staticParameters else - None - | _ -> None - | _ -> None + ValueNone + | _ -> ValueNone + | _ -> ValueNone + [] let (|ItemIsProvidedMethodWithStaticArguments|_|) item = match item with // Prefer the static parameters from the uninstantiated method info | Item.MethodGroup(_, _, Some minfo) -> match minfo.ProvidedStaticParameterInfo with - | Some (_, staticParameters) -> Some staticParameters - | _ -> None + | Some (_, staticParameters) -> ValueSome staticParameters + | _ -> ValueNone | Item.MethodGroup(_, [minfo], _) -> match minfo.ProvidedStaticParameterInfo with - | Some (_, staticParameters) -> Some staticParameters - | _ -> None - | _ -> None + | Some (_, staticParameters) -> ValueSome staticParameters + | _ -> ValueNone + | _ -> ValueNone /// Determine if an item has static arguments + [] let (|ItemIsWithStaticArguments|_|) m g item = match item with - | ItemIsProvidedTypeWithStaticArguments m g staticParameters -> Some staticParameters - | ItemIsProvidedMethodWithStaticArguments staticParameters -> Some staticParameters - | _ -> None + | ItemIsProvidedTypeWithStaticArguments m g staticParameters -> ValueSome staticParameters + | ItemIsProvidedMethodWithStaticArguments staticParameters -> ValueSome staticParameters + | _ -> ValueNone #endif diff --git a/src/Compiler/Symbols/SymbolHelpers.fsi b/src/Compiler/Symbols/SymbolHelpers.fsi index b25bf18d60f..e2eef38bbb6 100755 --- a/src/Compiler/Symbols/SymbolHelpers.fsi +++ b/src/Compiler/Symbols/SymbolHelpers.fsi @@ -59,13 +59,16 @@ module internal SymbolHelpers = val SelectMethodGroupItems2: TcGlobals -> range -> ItemWithInst -> ItemWithInst list #if !NO_TYPEPROVIDERS - val (|ItemIsProvidedType|_|): TcGlobals -> Item -> TyconRef option + [] + val (|ItemIsProvidedType|_|): TcGlobals -> Item -> TyconRef voption + [] val (|ItemIsWithStaticArguments|_|): - range -> TcGlobals -> Item -> Tainted[] option + range -> TcGlobals -> Item -> Tainted[] voption + [] val (|ItemIsProvidedTypeWithStaticArguments|_|): - range -> TcGlobals -> Item -> Tainted[] option + range -> TcGlobals -> Item -> Tainted[] voption #endif val SimplerDisplayEnv: DisplayEnv -> DisplayEnv diff --git a/src/Compiler/TypedTree/TypeProviders.fs b/src/Compiler/TypedTree/TypeProviders.fs index 75819eebfc8..aba063eb625 100644 --- a/src/Compiler/TypedTree/TypeProviders.fs +++ b/src/Compiler/TypedTree/TypeProviders.fs @@ -504,8 +504,13 @@ type IProvidedCustomAttributeProvider = abstract GetAttributeConstructorArgs: provider: ITypeProvider * attribName: string -> (obj option list * (string * obj option) list) option type ProvidedCustomAttributeProvider (attributes :ITypeProvider -> seq) = - let (|Member|_|) (s: string) (x: CustomAttributeNamedArgument) = if x.MemberName = s then Some x.TypedValue else None - let (|Arg|_|) (x: CustomAttributeTypedArgument) = match x.Value with null -> None | v -> Some v + + [] + let (|Member|_|) (s: string) (x: CustomAttributeNamedArgument) = if x.MemberName = s then ValueSome x.TypedValue else ValueNone + + [] + let (|Arg|_|) (x: CustomAttributeTypedArgument) = match x.Value with null -> ValueNone | v -> ValueSome v + let findAttribByName tyFullName (a: CustomAttributeData) = (a.Constructor.DeclaringType.FullName = tyFullName) let findAttrib (ty: Type) a = findAttribByName ty.FullName a interface IProvidedCustomAttributeProvider with diff --git a/src/Compiler/TypedTree/TypedTreeBasics.fs b/src/Compiler/TypedTree/TypedTreeBasics.fs index 1fca2981579..ca2674f873f 100644 --- a/src/Compiler/TypedTree/TypedTreeBasics.fs +++ b/src/Compiler/TypedTree/TypedTreeBasics.fs @@ -256,10 +256,11 @@ let stripTyparEqns ty = stripTyparEqnsAux false ty let stripUnitEqns unt = stripUnitEqnsAux false unt /// Detect a use of a nominal type, including type abbreviations. +[] let (|AbbrevOrAppTy|_|) (ty: TType) = match stripTyparEqns ty with - | TType_app (tcref, tinst, _) -> Some(tcref, tinst) - | _ -> None + | TType_app (tcref, tinst, _) -> ValueSome(tcref, tinst) + | _ -> ValueNone //--------------------------------------------------------------------------- // These make local/non-local references to values according to whether diff --git a/src/Compiler/TypedTree/TypedTreeBasics.fsi b/src/Compiler/TypedTree/TypedTreeBasics.fsi index c3edc900871..001e4129d06 100644 --- a/src/Compiler/TypedTree/TypedTreeBasics.fsi +++ b/src/Compiler/TypedTree/TypedTreeBasics.fsi @@ -133,7 +133,8 @@ val stripTyparEqns: ty: TType -> TType val stripUnitEqns: unt: Measure -> Measure /// Detect a use of a nominal type, including type abbreviations. -val (|AbbrevOrAppTy|_|): ty: TType -> (TyconRef * TypeInst) option +[] +val (|AbbrevOrAppTy|_|): ty: TType -> (TyconRef * TypeInst) voption val mkLocalValRef: v: Val -> ValRef diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index 02a5497cbb1..120baae8461 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -881,11 +881,14 @@ let tryAnyParTy g ty = ty |> stripTyEqns g |> (function TType_var (v, _) -> Valu let tryAnyParTyOption g ty = ty |> stripTyEqns g |> (function TType_var (v, _) -> Some v | TType_measure unt when isUnitParMeasure g unt -> Some(destUnitParMeasure g unt) | _ -> None) -let (|AppTy|_|) g ty = ty |> stripTyEqns g |> (function TType_app(tcref, tinst, _) -> Some (tcref, tinst) | _ -> None) +[] +let (|AppTy|_|) g ty = ty |> stripTyEqns g |> (function TType_app(tcref, tinst, _) -> ValueSome (tcref, tinst) | _ -> ValueNone) -let (|RefTupleTy|_|) g ty = ty |> stripTyEqns g |> (function TType_tuple(tupInfo, tys) when not (evalTupInfoIsStruct tupInfo) -> Some tys | _ -> None) +[] +let (|RefTupleTy|_|) g ty = ty |> stripTyEqns g |> (function TType_tuple(tupInfo, tys) when not (evalTupInfoIsStruct tupInfo) -> ValueSome tys | _ -> ValueNone) -let (|FunTy|_|) g ty = ty |> stripTyEqns g |> (function TType_fun(domainTy, rangeTy, _) -> Some (domainTy, rangeTy) | _ -> None) +[] +let (|FunTy|_|) g ty = ty |> stripTyEqns g |> (function TType_fun(domainTy, rangeTy, _) -> ValueSome (domainTy, rangeTy) | _ -> ValueNone) let tryNiceEntityRefOfTy ty = let ty = stripTyparEqnsAux false ty @@ -3426,14 +3429,24 @@ let TryFindFSharpAttributeOpt g tref attrs = match tref with None -> None | Some let HasFSharpAttributeOpt g trefOpt attrs = match trefOpt with Some tref -> List.exists (IsMatchingFSharpAttribute g tref) attrs | _ -> false let IsMatchingFSharpAttributeOpt g attrOpt (Attrib(tcref2, _, _, _, _, _, _)) = match attrOpt with Some (AttribInfo(_, tcref)) -> tyconRefEq g tcref tcref2 | _ -> false +[] let (|ExtractAttribNamedArg|_|) nm args = - args |> List.tryPick (function AttribNamedArg(nm2, _, _, v) when nm = nm2 -> Some v | _ -> None) + args |> List.tryPick (function AttribNamedArg(nm2, _, _, v) when nm = nm2 -> Some v | _ -> None) |> ValueOptionInternal.ofOption -let (|StringExpr|_|) = function Expr.Const (Const.String n, _, _) -> Some n | _ -> None -let (|AttribInt32Arg|_|) = function AttribExpr(_, Expr.Const (Const.Int32 n, _, _)) -> Some n | _ -> None -let (|AttribInt16Arg|_|) = function AttribExpr(_, Expr.Const (Const.Int16 n, _, _)) -> Some n | _ -> None -let (|AttribBoolArg|_|) = function AttribExpr(_, Expr.Const (Const.Bool n, _, _)) -> Some n | _ -> None -let (|AttribStringArg|_|) = function AttribExpr(_, Expr.Const (Const.String n, _, _)) -> Some n | _ -> None +[] +let (|StringExpr|_|) = function Expr.Const (Const.String n, _, _) -> ValueSome n | _ -> ValueNone + +[] +let (|AttribInt32Arg|_|) = function AttribExpr(_, Expr.Const (Const.Int32 n, _, _)) -> ValueSome n | _ -> ValueNone + +[] +let (|AttribInt16Arg|_|) = function AttribExpr(_, Expr.Const (Const.Int16 n, _, _)) -> ValueSome n | _ -> ValueNone + +[] +let (|AttribBoolArg|_|) = function AttribExpr(_, Expr.Const (Const.Bool n, _, _)) -> ValueSome n | _ -> ValueNone + +[] +let (|AttribStringArg|_|) = function AttribExpr(_, Expr.Const (Const.String n, _, _)) -> ValueSome n | _ -> ValueNone let TryFindFSharpBoolAttributeWithDefault dflt g nm attrs = match TryFindFSharpAttribute g nm attrs with @@ -3634,9 +3647,10 @@ let destByrefTy g ty = | TType_app(tcref, [x], _) when tyconRefEq g g.byref_tcr tcref -> x // all others | _ -> failwith "destByrefTy: not a byref type" +[] let (|ByrefTy|_|) g ty = // Because of byref = byref2 it is better to write this using is/dest - if isByrefTy g ty then Some (destByrefTy g ty) else None + if isByrefTy g ty then ValueSome (destByrefTy g ty) else ValueNone let destNativePtrTy g ty = match ty |> stripTyEqns g with @@ -3745,10 +3759,11 @@ let destNullableTy g ty = | ValueSome ty -> ty | ValueNone -> failwith "destNullableTy: not a Nullable type" +[] let (|NullableTy|_|) g ty = match tryAppTy g ty with - | ValueSome (tcref, [tyarg]) when tyconRefEq g tcref g.system_Nullable_tcref -> Some tyarg - | _ -> None + | ValueSome (tcref, [tyarg]) when tyconRefEq g tcref g.system_Nullable_tcref -> ValueSome tyarg + | _ -> ValueNone let (|StripNullableTy|) g ty = match tryDestNullableTy g ty with @@ -3788,21 +3803,25 @@ type ValRef with | Some membInfo -> membInfo.MemberFlags.IsDispatchSlot | None -> false +[] let (|UnopExpr|_|) _g expr = match expr with - | Expr.App (Expr.Val (vref, _, _), _, _, [arg1], _) -> Some (vref, arg1) - | _ -> None + | Expr.App (Expr.Val (vref, _, _), _, _, [arg1], _) -> ValueSome (vref, arg1) + | _ -> ValueNone +[] let (|BinopExpr|_|) _g expr = match expr with - | Expr.App (Expr.Val (vref, _, _), _, _, [arg1;arg2], _) -> Some (vref, arg1, arg2) - | _ -> None + | Expr.App (Expr.Val (vref, _, _), _, _, [arg1;arg2], _) -> ValueSome (vref, arg1, arg2) + | _ -> ValueNone +[] let (|SpecificUnopExpr|_|) g vrefReqd expr = match expr with - | UnopExpr g (vref, arg1) when valRefEq g vref vrefReqd -> Some arg1 - | _ -> None + | UnopExpr g (vref, arg1) when valRefEq g vref vrefReqd -> ValueSome arg1 + | _ -> ValueNone +[] let (|SignedConstExpr|_|) expr = match expr with | Expr.Const (Const.Int32 _, _, _) @@ -3810,9 +3829,10 @@ let (|SignedConstExpr|_|) expr = | Expr.Const (Const.Int16 _, _, _) | Expr.Const (Const.Int64 _, _, _) | Expr.Const (Const.Single _, _, _) - | Expr.Const (Const.Double _, _, _) -> Some () - | _ -> None + | Expr.Const (Const.Double _, _, _) -> ValueSome () + | _ -> ValueNone +[] let (|IntegerConstExpr|_|) expr = match expr with | Expr.Const (Const.Int32 _, _, _) @@ -3822,37 +3842,42 @@ let (|IntegerConstExpr|_|) expr = | Expr.Const (Const.Byte _, _, _) | Expr.Const (Const.UInt16 _, _, _) | Expr.Const (Const.UInt32 _, _, _) - | Expr.Const (Const.UInt64 _, _, _) -> Some () - | _ -> None + | Expr.Const (Const.UInt64 _, _, _) -> ValueSome () + | _ -> ValueNone +[] let (|FloatConstExpr|_|) expr = match expr with | Expr.Const (Const.Single _, _, _) - | Expr.Const (Const.Double _, _, _) -> Some () - | _ -> None + | Expr.Const (Const.Double _, _, _) -> ValueSome () + | _ -> ValueNone +[] let (|SpecificBinopExpr|_|) g vrefReqd expr = match expr with - | BinopExpr g (vref, arg1, arg2) when valRefEq g vref vrefReqd -> Some (arg1, arg2) - | _ -> None + | BinopExpr g (vref, arg1, arg2) when valRefEq g vref vrefReqd -> ValueSome (arg1, arg2) + | _ -> ValueNone +[] let (|EnumExpr|_|) g expr = match (|SpecificUnopExpr|_|) g g.enum_vref expr with - | None -> (|SpecificUnopExpr|_|) g g.enumOfValue_vref expr + | ValueNone -> (|SpecificUnopExpr|_|) g g.enumOfValue_vref expr | x -> x +[] let (|BitwiseOrExpr|_|) g expr = (|SpecificBinopExpr|_|) g g.bitwise_or_vref expr +[] let (|AttribBitwiseOrExpr|_|) g expr = match expr with - | BitwiseOrExpr g (arg1, arg2) -> Some(arg1, arg2) + | BitwiseOrExpr g (arg1, arg2) -> ValueSome(arg1, arg2) // Special workaround, only used when compiling FSharp.Core.dll. Uses of 'a ||| b' occur before the '|||' bitwise or operator // is defined. These get through type checking because enums implicitly support the '|||' operator through // the automatic resolution of undefined operators (see tc.fs, Item.ImplicitOp). This then compiles as an // application of a lambda to two arguments. We recognize this pattern here | Expr.App (Expr.Lambda _, _, _, [arg1;arg2], _) when g.compilingFSharpCore -> - Some(arg1, arg2) - | _ -> None + ValueSome(arg1, arg2) + | _ -> ValueNone let isUncheckedDefaultOfValRef g vref = valRefEq g vref g.unchecked_defaultof_vref @@ -3879,35 +3904,41 @@ let isTypeDefOfValRef g vref = // There is an internal version of typedefof defined in prim-types.fs that needs to be detected || (g.compilingFSharpCore && vref.LogicalName = "typedefof") +[] let (|UncheckedDefaultOfExpr|_|) g expr = match expr with - | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isUncheckedDefaultOfValRef g vref -> Some ty - | _ -> None + | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isUncheckedDefaultOfValRef g vref -> ValueSome ty + | _ -> ValueNone +[] let (|TypeOfExpr|_|) g expr = match expr with - | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isTypeOfValRef g vref -> Some ty - | _ -> None + | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isTypeOfValRef g vref -> ValueSome ty + | _ -> ValueNone +[] let (|SizeOfExpr|_|) g expr = match expr with - | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isSizeOfValRef g vref -> Some ty - | _ -> None + | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isSizeOfValRef g vref -> ValueSome ty + | _ -> ValueNone +[] let (|TypeDefOfExpr|_|) g expr = match expr with - | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isTypeDefOfValRef g vref -> Some ty - | _ -> None + | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isTypeDefOfValRef g vref -> ValueSome ty + | _ -> ValueNone +[] let (|NameOfExpr|_|) g expr = match expr with - | Expr.App(Expr.Val(vref,_,_),_,[ty],[],_) when isNameOfValRef g vref -> Some ty - | _ -> None + | Expr.App(Expr.Val(vref,_,_),_,[ty],[],_) when isNameOfValRef g vref -> ValueSome ty + | _ -> ValueNone +[] let (|SeqExpr|_|) g expr = match expr with - | Expr.App(Expr.Val(vref,_,_),_,_,_,_) when valRefEq g vref g.seq_vref -> Some() - | _ -> None + | Expr.App(Expr.Val(vref,_,_),_,_,_,_) when valRefEq g vref g.seq_vref -> ValueSome() + | _ -> ValueNone //-------------------------------------------------------------------------- // DEBUG layout @@ -5051,22 +5082,24 @@ let freeTyvarsAllPublic tyvars = /// -- if then else /// -- match e with pat[vs] -> e1[vs] | _ -> e2 +[] let (|LinearMatchExpr|_|) expr = match expr with - | Expr.Match (sp, m, dtree, [|tg1;(TTarget([], e2, _))|], m2, ty) -> Some(sp, m, dtree, tg1, e2, m2, ty) - | _ -> None + | Expr.Match (sp, m, dtree, [|tg1;(TTarget([], e2, _))|], m2, ty) -> ValueSome(sp, m, dtree, tg1, e2, m2, ty) + | _ -> ValueNone let rebuildLinearMatchExpr (sp, m, dtree, tg1, e2, m2, ty) = primMkMatch (sp, m, dtree, [|tg1;(TTarget([], e2, None))|], m2, ty) /// Detect a subset of 'Expr.Op' expressions we process in a linear way (i.e. using tailcalls, rather than /// unbounded stack). Only covers Cons(args,Cons(args,Cons(args,Cons(args,...._)))). +[] let (|LinearOpExpr|_|) expr = match expr with | Expr.Op (TOp.UnionCase _ as op, tinst, args, m) when not args.IsEmpty -> let argsFront, argLast = List.frontAndBack args - Some (op, tinst, argsFront, argLast, m) - | _ -> None + ValueSome (op, tinst, argsFront, argLast, m) + | _ -> ValueNone let rebuildLinearOpExpr (op, tinst, argsFront, argLast, m) = Expr.Op (op, tinst, argsFront@[argLast], m) @@ -8220,10 +8253,11 @@ let MultiLambdaToTupledLambda g vs body = let tupledv, untupler = untupledToRefTupled g vs tupledv, untupler body +[] let (|RefTuple|_|) expr = match expr with - | Expr.Op (TOp.Tuple (TupInfo.Const false), _, args, _) -> Some args - | _ -> None + | Expr.Op (TOp.Tuple (TupInfo.Const false), _, args, _) -> ValueSome args + | _ -> ValueNone let MultiLambdaToTupledLambdaIfNeeded g (vs, arg) body = match vs, arg with @@ -8296,39 +8330,44 @@ let rec MakeApplicationAndBetaReduceAux g (f, fty, tyargsl: TType list list, arg let MakeApplicationAndBetaReduce g (f, fty, tyargsl, argl, m) = MakeApplicationAndBetaReduceAux g (f, fty, tyargsl, argl, m) +[] let (|NewDelegateExpr|_|) g expr = match expr with | Expr.Obj (lambdaId, ty, a, b, [TObjExprMethod(c, d, e, tmvs, body, f)], [], m) when isDelegateTy g ty -> - Some (lambdaId, List.concat tmvs, body, m, (fun bodyR -> Expr.Obj (lambdaId, ty, a, b, [TObjExprMethod(c, d, e, tmvs, bodyR, f)], [], m))) - | _ -> None + ValueSome (lambdaId, List.concat tmvs, body, m, (fun bodyR -> Expr.Obj (lambdaId, ty, a, b, [TObjExprMethod(c, d, e, tmvs, bodyR, f)], [], m))) + | _ -> ValueNone +[] let (|DelegateInvokeExpr|_|) g expr = match expr with | Expr.App ((Expr.Val (invokeRef, _, _)) as delInvokeRef, delInvokeTy, [], [delExpr;delInvokeArg], m) when invokeRef.LogicalName = "Invoke" && isFSharpDelegateTy g (tyOfExpr g delExpr) -> - Some(delInvokeRef, delInvokeTy, delExpr, delInvokeArg, m) - | _ -> None + ValueSome(delInvokeRef, delInvokeTy, delExpr, delInvokeArg, m) + | _ -> ValueNone +[] let (|OpPipeRight|_|) g expr = match expr with | Expr.App (Expr.Val (vref, _, _), _, [_; resType], [xExpr; fExpr], m) when valRefEq g vref g.piperight_vref -> - Some(resType, xExpr, fExpr, m) - | _ -> None + ValueSome(resType, xExpr, fExpr, m) + | _ -> ValueNone +[] let (|OpPipeRight2|_|) g expr = match expr with | Expr.App (Expr.Val (vref, _, _), _, [_; _; resType], [Expr.Op (TOp.Tuple _, _, [arg1; arg2], _); fExpr], m) when valRefEq g vref g.piperight2_vref -> - Some(resType, arg1, arg2, fExpr, m) - | _ -> None + ValueSome(resType, arg1, arg2, fExpr, m) + | _ -> ValueNone +[] let (|OpPipeRight3|_|) g expr = match expr with | Expr.App (Expr.Val (vref, _, _), _, [_; _; _; resType], [Expr.Op (TOp.Tuple _, _, [arg1; arg2; arg3], _); fExpr], m) when valRefEq g vref g.piperight3_vref -> - Some(resType, arg1, arg2, arg3, fExpr, m) - | _ -> None + ValueSome(resType, arg1, arg2, arg3, fExpr, m) + | _ -> ValueNone let rec MakeFSharpDelegateInvokeAndTryBetaReduce g (delInvokeRef, delExpr, delInvokeTy, delInvokeArg, m) = match delExpr with @@ -8379,14 +8418,15 @@ let stripTupledFunTy g ty = let curriedArgTys = argTys |> List.map (tryDestRefTupleTy g) curriedArgTys, retTy +[] let (|ExprValWithPossibleTypeInst|_|) expr = match expr with | Expr.App (Expr.Val (vref, flags, m), _fty, tyargs, [], _) -> - Some (vref, flags, tyargs, m) + ValueSome (vref, flags, tyargs, m) | Expr.Val (vref, flags, m) -> - Some (vref, flags, [], m) + ValueSome (vref, flags, [], m) | _ -> - None + ValueNone let mkCoerceIfNeeded g tgtTy srcTy expr = if typeEquiv g tgtTy srcTy then @@ -9070,30 +9110,33 @@ let rec TypeHasDefaultValue g m ty = /// Determines types that are potentially known to satisfy the 'comparable' constraint and returns /// a set of residual types that must also satisfy the constraint +[] let (|SpecialComparableHeadType|_|) g ty = if isAnyTupleTy g ty then let _tupInfo, elemTys = destAnyTupleTy g ty - Some elemTys + ValueSome elemTys elif isAnonRecdTy g ty then match tryDestAnonRecdTy g ty with - | ValueNone -> Some [] - | ValueSome (_anonInfo, elemTys) -> Some elemTys + | ValueNone -> ValueSome [] + | ValueSome (_anonInfo, elemTys) -> ValueSome elemTys else match tryAppTy g ty with | ValueSome (tcref, tinst) -> if isArrayTyconRef g tcref || tyconRefEq g tcref g.system_UIntPtr_tcref || tyconRefEq g tcref g.system_IntPtr_tcref then - Some tinst + ValueSome tinst else - None + ValueNone | _ -> - None + ValueNone +[] let (|SpecialEquatableHeadType|_|) g ty = (|SpecialComparableHeadType|_|) g ty +[] let (|SpecialNotEquatableHeadType|_|) g ty = - if isFunTy g ty then Some() else None + if isFunTy g ty then ValueSome() else ValueNone // Can we use the fast helper for the 'LanguagePrimitives.IntrinsicFunctions.TypeTestGeneric'? let canUseTypeTestFast g ty = @@ -10006,23 +10049,24 @@ and EvaledAttribExprEquality g e1 e2 = | TypeDefOfExpr g ty1, TypeDefOfExpr g ty2 -> typeEquiv g ty1 ty2 | _ -> false +[] let (|ConstToILFieldInit|_|) c = match c with - | Const.SByte n -> Some (ILFieldInit.Int8 n) - | Const.Int16 n -> Some (ILFieldInit.Int16 n) - | Const.Int32 n -> Some (ILFieldInit.Int32 n) - | Const.Int64 n -> Some (ILFieldInit.Int64 n) - | Const.Byte n -> Some (ILFieldInit.UInt8 n) - | Const.UInt16 n -> Some (ILFieldInit.UInt16 n) - | Const.UInt32 n -> Some (ILFieldInit.UInt32 n) - | Const.UInt64 n -> Some (ILFieldInit.UInt64 n) - | Const.Bool n -> Some (ILFieldInit.Bool n) - | Const.Char n -> Some (ILFieldInit.Char (uint16 n)) - | Const.Single n -> Some (ILFieldInit.Single n) - | Const.Double n -> Some (ILFieldInit.Double n) - | Const.String s -> Some (ILFieldInit.String s) - | Const.Zero -> Some ILFieldInit.Null - | _ -> None + | Const.SByte n -> ValueSome (ILFieldInit.Int8 n) + | Const.Int16 n -> ValueSome (ILFieldInit.Int16 n) + | Const.Int32 n -> ValueSome (ILFieldInit.Int32 n) + | Const.Int64 n -> ValueSome (ILFieldInit.Int64 n) + | Const.Byte n -> ValueSome (ILFieldInit.UInt8 n) + | Const.UInt16 n -> ValueSome (ILFieldInit.UInt16 n) + | Const.UInt32 n -> ValueSome (ILFieldInit.UInt32 n) + | Const.UInt64 n -> ValueSome (ILFieldInit.UInt64 n) + | Const.Bool n -> ValueSome (ILFieldInit.Bool n) + | Const.Char n -> ValueSome (ILFieldInit.Char (uint16 n)) + | Const.Single n -> ValueSome (ILFieldInit.Single n) + | Const.Double n -> ValueSome (ILFieldInit.Double n) + | Const.String s -> ValueSome (ILFieldInit.String s) + | Const.Zero -> ValueSome ILFieldInit.Null + | _ -> ValueNone let EvalLiteralExprOrAttribArg g x = match x with @@ -10103,49 +10147,56 @@ let mkGetTupleItemN g m n (ty: ILType) isStruct expr retTy = mkAsmExpr ([mkNormalCall(mkILMethodSpecForTupleItem g ty n)], [], [expr], [retTy], m) /// Match an Int32 constant expression +[] let (|Int32Expr|_|) expr = match expr with - | Expr.Const (Const.Int32 n, _, _) -> Some n - | _ -> None + | Expr.Const (Const.Int32 n, _, _) -> ValueSome n + | _ -> ValueNone /// Match a try-finally expression +[] let (|TryFinally|_|) expr = match expr with - | Expr.Op (TOp.TryFinally _, [_resTy], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [_], e2, _, _)], _) -> Some(e1, e2) - | _ -> None + | Expr.Op (TOp.TryFinally _, [_resTy], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [_], e2, _, _)], _) -> ValueSome(e1, e2) + | _ -> ValueNone // detect ONLY the while loops that result from compiling 'for ... in ... do ...' +[] let (|WhileLoopForCompiledForEachExpr|_|) expr = match expr with | Expr.Op (TOp.While (spInWhile, WhileLoopForCompiledForEachExprMarker), _, [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [_], e2, _, _)], m) -> - Some(spInWhile, e1, e2, m) - | _ -> None + ValueSome(spInWhile, e1, e2, m) + | _ -> ValueNone +[] let (|Let|_|) expr = match expr with - | Expr.Let (TBind(v, e1, sp), e2, _, _) -> Some(v, e1, sp, e2) - | _ -> None + | Expr.Let (TBind(v, e1, sp), e2, _, _) -> ValueSome(v, e1, sp, e2) + | _ -> ValueNone +[] let (|RangeInt32Step|_|) g expr = match expr with // detect 'n .. m' | Expr.App (Expr.Val (vf, _, _), _, [tyarg], [startExpr;finishExpr], _) - when valRefEq g vf g.range_op_vref && typeEquiv g tyarg g.int_ty -> Some(startExpr, 1, finishExpr) + when valRefEq g vf g.range_op_vref && typeEquiv g tyarg g.int_ty -> ValueSome(startExpr, 1, finishExpr) // detect (RangeInt32 startExpr N finishExpr), the inlined/compiled form of 'n .. m' and 'n .. N .. m' | Expr.App (Expr.Val (vf, _, _), _, [], [startExpr; Int32Expr n; finishExpr], _) - when valRefEq g vf g.range_int32_op_vref -> Some(startExpr, n, finishExpr) + when valRefEq g vf g.range_int32_op_vref -> ValueSome(startExpr, n, finishExpr) - | _ -> None + | _ -> ValueNone +[] let (|GetEnumeratorCall|_|) expr = match expr with | Expr.Op (TOp.ILCall ( _, _, _, _, _, _, _, ilMethodRef, _, _, _), _, [Expr.Val (vref, _, _) | Expr.Op (_, _, [Expr.Val (vref, ValUseFlag.NormalValUse, _)], _) ], _) -> - if ilMethodRef.Name = "GetEnumerator" then Some vref - else None - | _ -> None + if ilMethodRef.Name = "GetEnumerator" then ValueSome vref + else ValueNone + | _ -> ValueNone // This code matches exactly the output of TcForEachExpr +[] let (|CompiledForEachExpr|_|) g expr = match expr with | Let (enumerableVar, enumerableExpr, spFor, @@ -10169,20 +10220,21 @@ let (|CompiledForEachExpr|_|) g expr = let spInWhile = match spIn with DebugPointAtInOrTo.Yes m -> DebugPointAtWhile.Yes m | DebugPointAtInOrTo.No -> DebugPointAtWhile.No let enumerableTy = tyOfExpr g enumerableExpr - Some (enumerableTy, enumerableExpr, elemVar, bodyExpr, (mBody, spFor, spIn, mFor, mIn, spInWhile, mWholeExpr)) - | _ -> None - + ValueSome (enumerableTy, enumerableExpr, elemVar, bodyExpr, (mBody, spFor, spIn, mFor, mIn, spInWhile, mWholeExpr)) + | _ -> ValueNone +[] let (|CompiledInt32RangeForEachExpr|_|) g expr = match expr with | CompiledForEachExpr g (_, RangeInt32Step g (startExpr, step, finishExpr), elemVar, bodyExpr, ranges) -> - Some (startExpr, step, finishExpr, elemVar, bodyExpr, ranges) - | _ -> None + ValueSome (startExpr, step, finishExpr, elemVar, bodyExpr, ranges) + | _ -> ValueNone +[] let (|ValApp|_|) g vref expr = match expr with - | Expr.App (Expr.Val (vref2, _, _), _f0ty, tyargs, args, m) when valRefEq g vref vref2 -> Some (tyargs, args, m) - | _ -> None + | Expr.App (Expr.Val (vref2, _, _), _f0ty, tyargs, args, m) when valRefEq g vref vref2 -> ValueSome (tyargs, args, m) + | _ -> ValueNone [] module IntegralConst = @@ -11010,24 +11062,27 @@ let mkUnitDelayLambda (g: TcGlobals) m e = let uv, _ = mkCompGenLocal m "unitVar" g.unit_ty mkLambda m uv (e, tyOfExpr g e) +[] let (|UseResumableStateMachinesExpr|_|) g expr = match expr with - | ValApp g g.cgh__useResumableCode_vref (_, _, _m) -> Some () - | _ -> None + | ValApp g g.cgh__useResumableCode_vref (_, _, _m) -> ValueSome () + | _ -> ValueNone /// Match an if...then...else expression or the result of "a && b" or "a || b" +[] let (|IfThenElseExpr|_|) expr = match expr with | Expr.Match (_spBind, _exprm, TDSwitch(cond, [ TCase( DecisionTreeTest.Const (Const.Bool true), TDSuccess ([], 0) )], Some (TDSuccess ([], 1)), _), [| TTarget([], thenExpr, _); TTarget([], elseExpr, _) |], _m, _ty) -> - Some (cond, thenExpr, elseExpr) - | _ -> None + ValueSome (cond, thenExpr, elseExpr) + | _ -> ValueNone /// if __useResumableCode then ... else ... +[] let (|IfUseResumableStateMachinesExpr|_|) g expr = match expr with - | IfThenElseExpr(UseResumableStateMachinesExpr g (), thenExpr, elseExpr) -> Some (thenExpr, elseExpr) - | _ -> None + | IfThenElseExpr(UseResumableStateMachinesExpr g (), thenExpr, elseExpr) -> ValueSome (thenExpr, elseExpr) + | _ -> ValueNone /// Combine a list of ModuleOrNamespaceType's making up the description of a CCU. checking there are now /// duplicate modules etc. @@ -11103,30 +11158,35 @@ let EmptyTraitWitnessInfoHashMap g : TraitWitnessInfoHashMap<'T> = member _.GetHashCode(a) = hash a.MemberName }) +[] let (|WhileExpr|_|) expr = match expr with | Expr.Op (TOp.While (sp1, sp2), _, [Expr.Lambda (_, _, _, [_gv], guardExpr, _, _);Expr.Lambda (_, _, _, [_bv], bodyExpr, _, _)], m) -> - Some (sp1, sp2, guardExpr, bodyExpr, m) - | _ -> None + ValueSome (sp1, sp2, guardExpr, bodyExpr, m) + | _ -> ValueNone +[] let (|TryFinallyExpr|_|) expr = match expr with | Expr.Op (TOp.TryFinally (sp1, sp2), [ty], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [_], e2, _, _)], m) -> - Some (sp1, sp2, ty, e1, e2, m) - | _ -> None + ValueSome (sp1, sp2, ty, e1, e2, m) + | _ -> ValueNone +[] let (|IntegerForLoopExpr|_|) expr = match expr with | Expr.Op (TOp.IntegerForLoop (sp1, sp2, style), _, [Expr.Lambda (_, _, _, [_], e1, _, _);Expr.Lambda (_, _, _, [_], e2, _, _);Expr.Lambda (_, _, _, [v], e3, _, _)], m) -> - Some (sp1, sp2, style, e1, e2, v, e3, m) - | _ -> None + ValueSome (sp1, sp2, style, e1, e2, v, e3, m) + | _ -> ValueNone +[] let (|TryWithExpr|_|) expr = match expr with | Expr.Op (TOp.TryWith (spTry, spWith), [resTy], [Expr.Lambda (_, _, _, [_], bodyExpr, _, _); Expr.Lambda (_, _, _, [filterVar], filterExpr, _, _); Expr.Lambda (_, _, _, [handlerVar], handlerExpr, _, _)], m) -> - Some (spTry, spWith, resTy, bodyExpr, filterVar, filterExpr, handlerVar, handlerExpr, m) - | _ -> None + ValueSome (spTry, spWith, resTy, bodyExpr, filterVar, filterExpr, handlerVar, handlerExpr, m) + | _ -> ValueNone +[] let (|MatchTwoCasesExpr|_|) expr = match expr with | Expr.Match (spBind, mExpr, TDSwitch(cond, [ TCase( DecisionTreeTest.UnionCase (ucref, a), TDSuccess ([], tg1) )], Some (TDSuccess ([], tg2)), b), tgs, m, ty) -> @@ -11135,11 +11195,12 @@ let (|MatchTwoCasesExpr|_|) expr = let rebuild (cond, ucref, tg1, tg2, tgs) = Expr.Match (spBind, mExpr, TDSwitch(cond, [ TCase( DecisionTreeTest.UnionCase (ucref, a), TDSuccess ([], tg1) )], Some (TDSuccess ([], tg2)), b), tgs, m, ty) - Some (cond, ucref, tg1, tg2, tgs, rebuild) + ValueSome (cond, ucref, tg1, tg2, tgs, rebuild) - | _ -> None + | _ -> ValueNone /// match e with None -> ... | Some v -> ... or other variations of the same +[] let (|MatchOptionExpr|_|) expr = match expr with | MatchTwoCasesExpr(cond, ucref, tg1, tg2, tgs, rebuildTwoCases) -> @@ -11158,16 +11219,18 @@ let (|MatchOptionExpr|_|) expr = Expr.Let(TBind(someVar, Expr.Op(TOp.UnionCaseFieldGet (a6a, a6b), a7, a8, a9), a10), someBranchExpr, a11, a12), a13, a14), a16) rebuildTwoCases (cond, ucref, tg1, tg2, tgs) - Some (cond, noneBranchExpr, someVar, someBranchExpr, rebuild) - | _ -> None - | _ -> None + ValueSome (cond, noneBranchExpr, someVar, someBranchExpr, rebuild) + | _ -> ValueNone + | _ -> ValueNone +[] let (|ResumableEntryAppExpr|_|) g expr = match expr with - | ValApp g g.cgh__resumableEntry_vref (_, _, _m) -> Some () - | _ -> None + | ValApp g g.cgh__resumableEntry_vref (_, _, _m) -> ValueSome () + | _ -> ValueNone /// Match an (unoptimized) __resumableEntry expression +[] let (|ResumableEntryMatchExpr|_|) g expr = match expr with | Expr.Let(TBind(matchVar, matchExpr, sp1), MatchOptionExpr (Expr.Val(matchVar2, b, c), noneBranchExpr, someVar, someBranchExpr, rebuildMatch), d, e) -> @@ -11179,13 +11242,14 @@ let (|ResumableEntryMatchExpr|_|) g expr = let rebuild (noneBranchExpr, someBranchExpr) = Expr.Let(TBind(matchVar, matchExpr, sp1), rebuildMatch (Expr.Val(matchVar2, b, c), noneBranchExpr, someVar, someBranchExpr), d, e) - Some (noneBranchExpr, someVar, someBranchExpr, rebuild) + ValueSome (noneBranchExpr, someVar, someBranchExpr, rebuild) - else None + else ValueNone - | _ -> None - | _ -> None + | _ -> ValueNone + | _ -> ValueNone +[] let (|StructStateMachineExpr|_|) g expr = match expr with | ValApp g g.cgh__stateMachine_vref ([dataTy; _resultTy], [moveNext; setStateMachine; afterCode], _m) -> @@ -11193,37 +11257,40 @@ let (|StructStateMachineExpr|_|) g expr = | NewDelegateExpr g (_, [moveNextThisVar], moveNextBody, _, _), NewDelegateExpr g (_, [setStateMachineThisVar;setStateMachineStateVar], setStateMachineBody, _, _), NewDelegateExpr g (_, [afterCodeThisVar], afterCodeBody, _, _) -> - Some (dataTy, + ValueSome (dataTy, (moveNextThisVar, moveNextBody), (setStateMachineThisVar, setStateMachineStateVar, setStateMachineBody), (afterCodeThisVar, afterCodeBody)) - | _ -> None - | _ -> None + | _ -> ValueNone + | _ -> ValueNone +[] let (|ResumeAtExpr|_|) g expr = match expr with - | ValApp g g.cgh__resumeAt_vref (_, [pcExpr], _m) -> Some pcExpr - | _ -> None + | ValApp g g.cgh__resumeAt_vref (_, [pcExpr], _m) -> ValueSome pcExpr + | _ -> ValueNone // Detect __debugPoint calls +[] let (|DebugPointExpr|_|) g expr = match expr with - | ValApp g g.cgh__debugPoint_vref (_, [StringExpr debugPointName], _m) -> Some debugPointName - | _ -> None + | ValApp g g.cgh__debugPoint_vref (_, [StringExpr debugPointName], _m) -> ValueSome debugPointName + | _ -> ValueNone // Detect sequencing constructs in state machine code +[] let (|SequentialResumableCode|_|) (g: TcGlobals) expr = match expr with // e1; e2 | Expr.Sequential(e1, e2, NormalSeq, m) -> - Some (e1, e2, m, (fun e1 e2 -> Expr.Sequential(e1, e2, NormalSeq, m))) + ValueSome (e1, e2, m, (fun e1 e2 -> Expr.Sequential(e1, e2, NormalSeq, m))) // let __stack_step = e1 in e2 | Expr.Let(bind, e2, m, _) when bind.Var.CompiledName(g.CompilerGlobalState).StartsWithOrdinal(stackVarPrefix) -> - Some (bind.Expr, e2, m, (fun e1 e2 -> mkLet bind.DebugPoint m bind.Var e1 e2)) + ValueSome (bind.Expr, e2, m, (fun e1 e2 -> mkLet bind.DebugPoint m bind.Var e1 e2)) - | _ -> None + | _ -> ValueNone let mkLabelled m l e = mkCompGenSequential m (Expr.Op (TOp.Label l, [], [], m)) e @@ -11233,13 +11300,14 @@ let rec isReturnsResumableCodeTy g ty = if isFunTy g ty then isReturnsResumableCodeTy g (rangeOfFunTy g ty) else isResumableCodeTy g ty +[] let (|ResumableCodeInvoke|_|) g expr = match expr with // defn.Invoke x --> let arg = x in [defn][arg/x] | Expr.App ((Expr.Val (invokeRef, _, _) as iref), a, b, (f :: args), m) when invokeRef.LogicalName = "Invoke" && isReturnsResumableCodeTy g (tyOfExpr g f) -> - Some (iref, f, args, m, (fun (f2, args2) -> Expr.App ((iref, a, b, (f2 :: args2), m)))) - | _ -> None + ValueSome (iref, f, args, m, (fun (f2, args2) -> Expr.App ((iref, a, b, (f2 :: args2), m)))) + | _ -> ValueNone let ComputeUseMethodImpl g (v: Val) = v.ImplementedSlotSigs |> List.exists (fun slotsig -> @@ -11269,27 +11337,31 @@ let ComputeUseMethodImpl g (v: Val) = not isStructural)) +[] let (|Seq|_|) g expr = match expr with // use 'seq { ... }' as an indicator - | ValApp g g.seq_vref ([elemTy], [e], _m) -> Some (e, elemTy) - | _ -> None + | ValApp g g.seq_vref ([elemTy], [e], _m) -> ValueSome (e, elemTy) + | _ -> ValueNone /// Detect a 'yield x' within a 'seq { ... }' +[] let (|SeqYield|_|) g expr = match expr with - | ValApp g g.seq_singleton_vref (_, [arg], m) -> Some (arg, m) - | _ -> None + | ValApp g g.seq_singleton_vref (_, [arg], m) -> ValueSome (arg, m) + | _ -> ValueNone /// Detect a 'expr; expr' within a 'seq { ... }' +[] let (|SeqAppend|_|) g expr = match expr with - | ValApp g g.seq_append_vref (_, [arg1; arg2], m) -> Some (arg1, arg2, m) - | _ -> None + | ValApp g g.seq_append_vref (_, [arg1; arg2], m) -> ValueSome (arg1, arg2, m) + | _ -> ValueNone let isVarFreeInExpr v e = Zset.contains v (freeInExpr CollectTyparsAndLocals e).FreeLocals /// Detect a 'while gd do expr' within a 'seq { ... }' +[] let (|SeqWhile|_|) g expr = match expr with | ValApp g g.seq_generated_vref (_, [Expr.Lambda (_, _, _, [dummyv], guardExpr, _, _);innerExpr], m) @@ -11298,11 +11370,12 @@ let (|SeqWhile|_|) g expr = // The debug point for 'while' is attached to the innerExpr, see TcSequenceExpression let mWhile = innerExpr.Range let spWhile = match mWhile.NotedSourceConstruct with NotedSourceConstruct.While -> DebugPointAtWhile.Yes mWhile | _ -> DebugPointAtWhile.No - Some (guardExpr, innerExpr, spWhile, m) + ValueSome (guardExpr, innerExpr, spWhile, m) | _ -> - None + ValueNone +[] let (|SeqTryFinally|_|) g expr = match expr with | ValApp g g.seq_finally_vref (_, [arg1;Expr.Lambda (_, _, _, [dummyv], compensation, _, _) as arg2], m) @@ -11315,53 +11388,58 @@ let (|SeqTryFinally|_|) g expr = let spTry = match mTry.NotedSourceConstruct with NotedSourceConstruct.Try -> DebugPointAtTry.Yes mTry | _ -> DebugPointAtTry.No let spFinally = match mFinally.NotedSourceConstruct with NotedSourceConstruct.Finally -> DebugPointAtFinally.Yes mFinally | _ -> DebugPointAtFinally.No - Some (arg1, compensation, spTry, spFinally, m) + ValueSome (arg1, compensation, spTry, spFinally, m) | _ -> - None + ValueNone +[] let (|SeqUsing|_|) g expr = match expr with | ValApp g g.seq_using_vref ([_;_;elemTy], [resource;Expr.Lambda (_, _, _, [v], body, mBind, _)], m) -> // The debug point mFor at the 'use x = ... ' gets attached to the lambda let spBind = match mBind.NotedSourceConstruct with NotedSourceConstruct.Binding -> DebugPointAtBinding.Yes mBind | _ -> DebugPointAtBinding.NoneAtInvisible - Some (resource, v, body, elemTy, spBind, m) + ValueSome (resource, v, body, elemTy, spBind, m) | _ -> - None + ValueNone +[] let (|SeqForEach|_|) g expr = match expr with // Nested for loops are represented by calls to Seq.collect | ValApp g g.seq_collect_vref ([_inpElemTy;_enumty2;genElemTy], [Expr.Lambda (_, _, _, [v], body, mIn, _); inp], mFor) -> // The debug point mIn at the 'in' gets attached to the first argument, see TcSequenceExpression let spIn = match mIn.NotedSourceConstruct with NotedSourceConstruct.InOrTo -> DebugPointAtInOrTo.Yes mIn | _ -> DebugPointAtInOrTo.No - Some (inp, v, body, genElemTy, mFor, mIn, spIn) + ValueSome (inp, v, body, genElemTy, mFor, mIn, spIn) // "for x in e -> e2" is converted to a call to Seq.map by the F# type checker. This could be removed, except it is also visible in F# quotations. | ValApp g g.seq_map_vref ([_inpElemTy;genElemTy], [Expr.Lambda (_, _, _, [v], body, mIn, _); inp], mFor) -> let spIn = match mIn.NotedSourceConstruct with NotedSourceConstruct.InOrTo -> DebugPointAtInOrTo.Yes mIn | _ -> DebugPointAtInOrTo.No // The debug point mFor at the 'for' gets attached to the first argument, see TcSequenceExpression - Some (inp, v, mkCallSeqSingleton g body.Range genElemTy body, genElemTy, mFor, mIn, spIn) + ValueSome (inp, v, mkCallSeqSingleton g body.Range genElemTy body, genElemTy, mFor, mIn, spIn) - | _ -> None + | _ -> ValueNone +[] let (|SeqDelay|_|) g expr = match expr with | ValApp g g.seq_delay_vref ([elemTy], [Expr.Lambda (_, _, _, [v], e, _, _)], _m) when not (isVarFreeInExpr v e) -> - Some (e, elemTy) - | _ -> None + ValueSome (e, elemTy) + | _ -> ValueNone +[] let (|SeqEmpty|_|) g expr = match expr with - | ValApp g g.seq_empty_vref (_, [], m) -> Some m - | _ -> None + | ValApp g g.seq_empty_vref (_, [], m) -> ValueSome m + | _ -> ValueNone let isFSharpExceptionTy g ty = match tryTcrefOfAppTy g ty with | ValueSome tcref -> tcref.IsFSharpException | _ -> false +[] let (|EmptyModuleOrNamespaces|_|) (moduleOrNamespaceContents: ModuleOrNamespaceContents) = match moduleOrNamespaceContents with | TMDefs(defs = defs) -> @@ -11390,10 +11468,10 @@ let (|EmptyModuleOrNamespaces|_|) (moduleOrNamespaceContents: ModuleOrNamespaceC | _ -> None) if mdDefsLength = emptyModuleOrNamespaces.Length then - Some emptyModuleOrNamespaces + ValueSome emptyModuleOrNamespaces else - None - | _ -> None + ValueNone + | _ -> ValueNone let tryFindExtensionAttribute (g: TcGlobals) (attribs: Attrib list): Attrib option = attribs diff --git a/src/Compiler/TypedTree/TypedTreeOps.fsi b/src/Compiler/TypedTree/TypedTreeOps.fsi index 1740cbb530d..cec67a4961d 100755 --- a/src/Compiler/TypedTree/TypedTreeOps.fsi +++ b/src/Compiler/TypedTree/TypedTreeOps.fsi @@ -73,7 +73,8 @@ val (|DebugPoints|): Expr -> Expr * (Expr -> Expr) val valsOfBinds: Bindings -> Vals /// Look for a use of an F# value, possibly including application of a generic thing to a set of type arguments -val (|ExprValWithPossibleTypeInst|_|): Expr -> (ValRef * ValUseFlag * TType list * range) option +[] +val (|ExprValWithPossibleTypeInst|_|): Expr -> (ValRef * ValUseFlag * TType list * range) voption /// Build decision trees imperatively type MatchBuilder = @@ -1759,16 +1760,20 @@ val isStructRecordOrUnionTyconTy: TcGlobals -> TType -> bool val StripSelfRefCell: TcGlobals * ValBaseOrThisInfo * TType -> TType /// An active pattern to determine if a type is a nominal type, possibly instantiated -val (|AppTy|_|): TcGlobals -> TType -> (TyconRef * TType list) option +[] +val (|AppTy|_|): TcGlobals -> TType -> (TyconRef * TType list) voption /// An active pattern to match System.Nullable types -val (|NullableTy|_|): TcGlobals -> TType -> TType option +[] +val (|NullableTy|_|): TcGlobals -> TType -> TType voption /// An active pattern to transform System.Nullable types to their input, otherwise leave the input unchanged +[] val (|StripNullableTy|): TcGlobals -> TType -> TType /// Matches any byref type, yielding the target type -val (|ByrefTy|_|): TcGlobals -> TType -> TType option +[] +val (|ByrefTy|_|): TcGlobals -> TType -> TType voption //------------------------------------------------------------------------- // Special semantic constraints @@ -2527,19 +2532,25 @@ type EntityRef with member HasMember: TcGlobals -> string -> TType list -> bool -val (|AttribBitwiseOrExpr|_|): TcGlobals -> Expr -> (Expr * Expr) option +[] +val (|AttribBitwiseOrExpr|_|): TcGlobals -> Expr -> (Expr * Expr) voption -val (|EnumExpr|_|): TcGlobals -> Expr -> Expr option +[] +val (|EnumExpr|_|): TcGlobals -> Expr -> Expr voption -val (|TypeOfExpr|_|): TcGlobals -> Expr -> TType option +[] +val (|TypeOfExpr|_|): TcGlobals -> Expr -> TType voption -val (|TypeDefOfExpr|_|): TcGlobals -> Expr -> TType option +[] +val (|TypeDefOfExpr|_|): TcGlobals -> Expr -> TType voption val isNameOfValRef: TcGlobals -> ValRef -> bool -val (|NameOfExpr|_|): TcGlobals -> Expr -> TType option +[] +val (|NameOfExpr|_|): TcGlobals -> Expr -> TType voption -val (|SeqExpr|_|): TcGlobals -> Expr -> unit option +[] +val (|SeqExpr|_|): TcGlobals -> Expr -> unit voption val EvalLiteralExprOrAttribArg: TcGlobals -> Expr -> Expr @@ -2547,27 +2558,37 @@ val EvaledAttribExprEquality: TcGlobals -> Expr -> Expr -> bool val IsSimpleSyntacticConstantExpr: TcGlobals -> Expr -> bool -val (|ConstToILFieldInit|_|): Const -> ILFieldInit option +[] +val (|ConstToILFieldInit|_|): Const -> ILFieldInit voption -val (|ExtractAttribNamedArg|_|): string -> AttribNamedArg list -> AttribExpr option +[] +val (|ExtractAttribNamedArg|_|): string -> AttribNamedArg list -> AttribExpr voption -val (|AttribInt32Arg|_|): AttribExpr -> int32 option +[] +val (|AttribInt32Arg|_|): (AttribExpr -> int32 voption) -val (|AttribInt16Arg|_|): AttribExpr -> int16 option +[] +val (|AttribInt16Arg|_|): (AttribExpr -> int16 voption) -val (|AttribBoolArg|_|): AttribExpr -> bool option +[] +val (|AttribBoolArg|_|): (AttribExpr -> bool voption) -val (|AttribStringArg|_|): AttribExpr -> string option +[] +val (|AttribStringArg|_|): (AttribExpr -> string voption) -val (|Int32Expr|_|): Expr -> int32 option +[] +val (|Int32Expr|_|): Expr -> int32 voption /// Determines types that are potentially known to satisfy the 'comparable' constraint and returns /// a set of residual types that must also satisfy the constraint -val (|SpecialComparableHeadType|_|): TcGlobals -> TType -> TType list option +[] +val (|SpecialComparableHeadType|_|): TcGlobals -> TType -> TType list voption -val (|SpecialEquatableHeadType|_|): TcGlobals -> TType -> TType list option +[] +val (|SpecialEquatableHeadType|_|): TcGlobals -> TType -> TType list voption -val (|SpecialNotEquatableHeadType|_|): TcGlobals -> TType -> unit option +[] +val (|SpecialNotEquatableHeadType|_|): TcGlobals -> TType -> unit voption /// Matches if the given expression is an application /// of the range or range-step operator on an integral type @@ -2627,18 +2648,21 @@ val ValIsExplicitImpl: TcGlobals -> Val -> bool val ValRefIsExplicitImpl: TcGlobals -> ValRef -> bool +[] val (|LinearMatchExpr|_|): - Expr -> (DebugPointAtBinding * range * DecisionTree * DecisionTreeTarget * Expr * range * TType) option + Expr -> (DebugPointAtBinding * range * DecisionTree * DecisionTreeTarget * Expr * range * TType) voption val rebuildLinearMatchExpr: DebugPointAtBinding * range * DecisionTree * DecisionTreeTarget * Expr * range * TType -> Expr -val (|LinearOpExpr|_|): Expr -> (TOp * TypeInst * Expr list * Expr * range) option +[] +val (|LinearOpExpr|_|): Expr -> (TOp * TypeInst * Expr list * Expr * range) voption val rebuildLinearOpExpr: TOp * TypeInst * Expr list * Expr * range -> Expr val mkCoerceIfNeeded: TcGlobals -> tgtTy: TType -> srcTy: TType -> Expr -> Expr +[] val (|InnerExprPat|): Expr -> Expr val allValsOfModDef: ModuleOrNamespaceContents -> seq @@ -2668,48 +2692,61 @@ type TraitWitnessInfoHashMap<'T> = ImmutableDictionary val EmptyTraitWitnessInfoHashMap: TcGlobals -> TraitWitnessInfoHashMap<'T> /// Match expressions that are an application of a particular F# function value -val (|ValApp|_|): TcGlobals -> ValRef -> Expr -> (TypeInst * Exprs * range) option +[] +val (|ValApp|_|): TcGlobals -> ValRef -> Expr -> (TypeInst * Exprs * range) voption /// Match expressions that represent the creation of an instance of an F# delegate value -val (|NewDelegateExpr|_|): TcGlobals -> Expr -> (Unique * Val list * Expr * range * (Expr -> Expr)) option +[] +val (|NewDelegateExpr|_|): TcGlobals -> Expr -> (Unique * Val list * Expr * range * (Expr -> Expr)) voption /// Match a .Invoke on a delegate -val (|DelegateInvokeExpr|_|): TcGlobals -> Expr -> (Expr * TType * Expr * Expr * range) option +[] +val (|DelegateInvokeExpr|_|): TcGlobals -> Expr -> (Expr * TType * Expr * Expr * range) voption /// Match 'if __useResumableCode then ... else ...' expressions -val (|IfUseResumableStateMachinesExpr|_|): TcGlobals -> Expr -> (Expr * Expr) option +[] +val (|IfUseResumableStateMachinesExpr|_|): TcGlobals -> Expr -> (Expr * Expr) voption val CombineCcuContentFragments: ModuleOrNamespaceType list -> ModuleOrNamespaceType /// Recognise a 'match __resumableEntry() with ...' expression -val (|ResumableEntryMatchExpr|_|): g: TcGlobals -> Expr -> (Expr * Val * Expr * (Expr * Expr -> Expr)) option +[] +val (|ResumableEntryMatchExpr|_|): g: TcGlobals -> Expr -> (Expr * Val * Expr * (Expr * Expr -> Expr)) voption /// Recognise a '__stateMachine' expression +[] val (|StructStateMachineExpr|_|): - g: TcGlobals -> expr: Expr -> (TType * (Val * Expr) * (Val * Val * Expr) * (Val * Expr)) option + g: TcGlobals -> expr: Expr -> (TType * (Val * Expr) * (Val * Val * Expr) * (Val * Expr)) voption /// Recognise a sequential or binding construct in a resumable code -val (|SequentialResumableCode|_|): g: TcGlobals -> Expr -> (Expr * Expr * range * (Expr -> Expr -> Expr)) option +[] +val (|SequentialResumableCode|_|): g: TcGlobals -> Expr -> (Expr * Expr * range * (Expr -> Expr -> Expr)) voption /// Recognise a '__debugPoint' expression -val (|DebugPointExpr|_|): g: TcGlobals -> Expr -> string option +[] +val (|DebugPointExpr|_|): g: TcGlobals -> Expr -> string voption /// Recognise a '__resumeAt' expression -val (|ResumeAtExpr|_|): g: TcGlobals -> Expr -> Expr option +[] +val (|ResumeAtExpr|_|): g: TcGlobals -> Expr -> Expr voption /// Recognise a while expression -val (|WhileExpr|_|): Expr -> (DebugPointAtWhile * SpecialWhileLoopMarker * Expr * Expr * range) option +[] +val (|WhileExpr|_|): Expr -> (DebugPointAtWhile * SpecialWhileLoopMarker * Expr * Expr * range) voption /// Recognise an integer for-loop expression +[] val (|IntegerForLoopExpr|_|): - Expr -> (DebugPointAtFor * DebugPointAtInOrTo * ForLoopStyle * Expr * Expr * Val * Expr * range) option + Expr -> (DebugPointAtFor * DebugPointAtInOrTo * ForLoopStyle * Expr * Expr * Val * Expr * range) voption /// Recognise a try-with expression +[] val (|TryWithExpr|_|): - Expr -> (DebugPointAtTry * DebugPointAtWith * TType * Expr * Val * Expr * Val * Expr * range) option + Expr -> (DebugPointAtTry * DebugPointAtWith * TType * Expr * Val * Expr * Val * Expr * range) voption /// Recognise a try-finally expression -val (|TryFinallyExpr|_|): Expr -> (DebugPointAtTry * DebugPointAtFinally * TType * Expr * Expr * range) option +[] +val (|TryFinallyExpr|_|): Expr -> (DebugPointAtTry * DebugPointAtFinally * TType * Expr * Expr * range) voption /// Add a label to use as the target for a goto val mkLabelled: range -> ILCodeLabel -> Expr -> Expr @@ -2733,49 +2770,63 @@ val TryBindTyconRefAttribute: val HasDefaultAugmentationAttribute: g: TcGlobals -> tcref: TyconRef -> bool +[] val (|ResumableCodeInvoke|_|): - g: TcGlobals -> expr: Expr -> (Expr * Expr * Expr list * range * (Expr * Expr list -> Expr)) option + g: TcGlobals -> expr: Expr -> (Expr * Expr * Expr list * range * (Expr * Expr list -> Expr)) voption -val (|OpPipeRight|_|): g: TcGlobals -> expr: Expr -> (TType * Expr * Expr * range) option +[] +val (|OpPipeRight|_|): g: TcGlobals -> expr: Expr -> (TType * Expr * Expr * range) voption -val (|OpPipeRight2|_|): g: TcGlobals -> expr: Expr -> (TType * Expr * Expr * Expr * range) option +[] +val (|OpPipeRight2|_|): g: TcGlobals -> expr: Expr -> (TType * Expr * Expr * Expr * range) voption -val (|OpPipeRight3|_|): g: TcGlobals -> expr: Expr -> (TType * Expr * Expr * Expr * Expr * range) option +[] +val (|OpPipeRight3|_|): g: TcGlobals -> expr: Expr -> (TType * Expr * Expr * Expr * Expr * range) voption val mkDebugPoint: m: range -> expr: Expr -> Expr /// Match an if...then...else expression or the result of "a && b" or "a || b" -val (|IfThenElseExpr|_|): expr: Expr -> (Expr * Expr * Expr) option +[] +val (|IfThenElseExpr|_|): expr: Expr -> (Expr * Expr * Expr) voption /// Determine if a value is a method implementing an interface dispatch slot using a private method impl val ComputeUseMethodImpl: g: TcGlobals -> v: Val -> bool /// Detect the de-sugared form of a 'yield x' within a 'seq { ... }' -val (|SeqYield|_|): TcGlobals -> Expr -> (Expr * range) option +[] +val (|SeqYield|_|): TcGlobals -> Expr -> (Expr * range) voption /// Detect the de-sugared form of a 'expr; expr' within a 'seq { ... }' -val (|SeqAppend|_|): TcGlobals -> Expr -> (Expr * Expr * range) option +[] +val (|SeqAppend|_|): TcGlobals -> Expr -> (Expr * Expr * range) voption /// Detect the de-sugared form of a 'while gd do expr' within a 'seq { ... }' -val (|SeqWhile|_|): TcGlobals -> Expr -> (Expr * Expr * DebugPointAtWhile * range) option +[] +val (|SeqWhile|_|): TcGlobals -> Expr -> (Expr * Expr * DebugPointAtWhile * range) voption /// Detect the de-sugared form of a 'try .. finally .. ' within a 'seq { ... }' -val (|SeqTryFinally|_|): TcGlobals -> Expr -> (Expr * Expr * DebugPointAtTry * DebugPointAtFinally * range) option +[] +val (|SeqTryFinally|_|): TcGlobals -> Expr -> (Expr * Expr * DebugPointAtTry * DebugPointAtFinally * range) voption /// Detect the de-sugared form of a 'use x = ..' within a 'seq { ... }' -val (|SeqUsing|_|): TcGlobals -> Expr -> (Expr * Val * Expr * TType * DebugPointAtBinding * range) option +[] +val (|SeqUsing|_|): TcGlobals -> Expr -> (Expr * Val * Expr * TType * DebugPointAtBinding * range) voption /// Detect the de-sugared form of a 'for x in collection do ..' within a 'seq { ... }' -val (|SeqForEach|_|): TcGlobals -> Expr -> (Expr * Val * Expr * TType * range * range * DebugPointAtInOrTo) option +[] +val (|SeqForEach|_|): TcGlobals -> Expr -> (Expr * Val * Expr * TType * range * range * DebugPointAtInOrTo) voption /// Detect the outer 'Seq.delay' added for a construct 'seq { ... }' -val (|SeqDelay|_|): TcGlobals -> Expr -> (Expr * TType) option +[] +val (|SeqDelay|_|): TcGlobals -> Expr -> (Expr * TType) voption /// Detect a 'Seq.empty' implicit in the implied 'else' branch of an 'if .. then' in a seq { ... } -val (|SeqEmpty|_|): TcGlobals -> Expr -> range option +[] +val (|SeqEmpty|_|): TcGlobals -> Expr -> range voption /// Detect a 'seq { ... }' expression -val (|Seq|_|): TcGlobals -> Expr -> (Expr * TType) option +[] +val (|Seq|_|): TcGlobals -> Expr -> (Expr * TType) voption /// Indicates if an F# type is the type associated with an F# exception declaration val isFSharpExceptionTy: g: TcGlobals -> ty: TType -> bool @@ -2801,8 +2852,9 @@ type TraitConstraintInfo with /// Matches a ModuleOrNamespaceContents that is empty from a signature printing point of view. /// Signatures printed via the typed tree in NicePrint don't print TMDefOpens or TMDefDo. /// This will match anything that does not have any types or bindings. +[] val (|EmptyModuleOrNamespaces|_|): - moduleOrNamespaceContents: ModuleOrNamespaceContents -> (ModuleOrNamespace list) option + moduleOrNamespaceContents: ModuleOrNamespaceContents -> (ModuleOrNamespace list) voption val tryFindExtensionAttribute: g: TcGlobals -> attribs: Attrib list -> Attrib option