From 646de42211134d5ffc1e2ac0b54bfc884de238e3 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Fri, 8 Jul 2022 19:26:49 +0100 Subject: [PATCH 01/11] ValRepInfoForDisplay added for improved quick info for functions defined in expressions --- src/Compiler/Checking/CheckExpressions.fs | 58 ++++++++++++------- src/Compiler/Checking/CheckExpressions.fsi | 3 +- .../Checking/CheckIncrementalClasses.fs | 8 +-- src/Compiler/Checking/NicePrint.fs | 3 +- src/Compiler/Checking/PostInferenceChecks.fs | 3 +- src/Compiler/Checking/PostInferenceChecks.fsi | 4 +- src/Compiler/TypedTree/TypedTree.fs | 31 ++++++++-- src/Compiler/TypedTree/TypedTree.fsi | 13 +++++ src/Compiler/TypedTree/TypedTreeBasics.fs | 18 +++++- src/Compiler/TypedTree/TypedTreeBasics.fsi | 4 ++ src/Compiler/TypedTree/TypedTreeOps.fs | 4 +- src/Compiler/TypedTree/TypedTreePickle.fs | 1 + 12 files changed, 112 insertions(+), 38 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 0de950283e7..a3114d259c5 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -578,6 +578,7 @@ type ValScheme = id: Ident * typeScheme: GeneralizedType * valReprInfo: ValReprInfo option * + valReprInfoForDisplay: ValReprInfo option * memberInfo: PrelimMemberInfo option * isMutable: bool * inlineInfo: ValInline * @@ -1500,7 +1501,7 @@ let MakeAndPublishVal (cenv: cenv) env (altActualParent, inSig, declKind, valRec let g = cenv.g - let (ValScheme(id, typeScheme, valReprInfo, memberInfoOpt, isMutable, inlineFlag, baseOrThis, vis, isCompGen, isIncrClass, isTyFunc, hasDeclaredTypars)) = vscheme + let (ValScheme(id, typeScheme, valReprInfo, valReprInfoForDisplay, memberInfoOpt, isMutable, inlineFlag, baseOrThis, vis, isCompGen, isIncrClass, isTyFunc, hasDeclaredTypars)) = vscheme let ty = GeneralizedTypeForTypeScheme typeScheme @@ -1608,6 +1609,10 @@ let MakeAndPublishVal (cenv: cenv) env (altActualParent, inSig, declKind, valRec xmlDoc, isTopBinding, isExtrinsic, isIncrClass, isTyFunc, (hasDeclaredTypars || inSig), isGeneratedEventVal, konst, actualParent) + match valReprInfoForDisplay with + | Some info when not (ValReprInfo.IsEmpty info) -> + vspec.SetValReprInfoForDisplay valReprInfoForDisplay + | _ -> () CheckForAbnormalOperatorNames cenv id.idRange vspec.DisplayNameCoreMangled memberInfoOpt @@ -1641,10 +1646,11 @@ let MakeAndPublishVals cenv env (altActualParent, inSig, declKind, valRecInfo, v valSchemes Map.empty +/// Create a Val node for "base" in a class let MakeAndPublishBaseVal cenv env baseIdOpt ty = baseIdOpt |> Option.map (fun (id: Ident) -> - let valscheme = ValScheme(id, NonGenericTypeScheme ty, None, None, false, ValInline.Never, BaseVal, None, false, false, false, false) + let valscheme = ValScheme(id, NonGenericTypeScheme ty, None, None, None, false, ValInline.Never, BaseVal, None, false, false, false, false) MakeAndPublishVal cenv env (ParentNone, false, ExpressionBinding, ValNotInRecScope, valscheme, [], XmlDoc.Empty, None, false)) // Make the "delayed reference" value where the this pointer will reside after calling the base class constructor @@ -1657,7 +1663,7 @@ let MakeAndPublishSafeThisVal (cenv: cenv) env (thisIdOpt: Ident option) thisTy if not (isFSharpObjModelTy g thisTy) then errorR(Error(FSComp.SR.tcStructsCanOnlyBindThisAtMemberDeclaration(), thisId.idRange)) - let valScheme = ValScheme(thisId, NonGenericTypeScheme(mkRefCellTy g thisTy), None, None, false, ValInline.Never, CtorThisVal, None, false, false, false, false) + let valScheme = ValScheme(thisId, NonGenericTypeScheme(mkRefCellTy g thisTy), None, None, None, false, ValInline.Never, CtorThisVal, None, false, false, false, false) Some(MakeAndPublishVal cenv env (ParentNone, false, ExpressionBinding, ValNotInRecScope, valScheme, [], XmlDoc.Empty, None, false)) | None -> @@ -1742,11 +1748,11 @@ let ChooseCanonicalDeclaredTyparsAfterInference g denv declaredTypars m = declaredTypars let ChooseCanonicalValSchemeAfterInference g denv vscheme m = - let (ValScheme(id, typeScheme, arityInfo, memberInfoOpt, isMutable, inlineFlag, baseOrThis, vis, isCompGen, isIncrClass, isTyFunc, hasDeclaredTypars)) = vscheme + let (ValScheme(id, typeScheme, valReprInfo, valReprInfoForDisplay, memberInfoOpt, isMutable, inlineFlag, baseOrThis, vis, isCompGen, isIncrClass, isTyFunc, hasDeclaredTypars)) = vscheme let (GeneralizedType(generalizedTypars, ty)) = typeScheme let generalizedTypars = ChooseCanonicalDeclaredTyparsAfterInference g denv generalizedTypars m let typeScheme = GeneralizedType(generalizedTypars, ty) - let valscheme = ValScheme(id, typeScheme, arityInfo, memberInfoOpt, isMutable, inlineFlag, baseOrThis, vis, isCompGen, isIncrClass, isTyFunc, hasDeclaredTypars) + let valscheme = ValScheme(id, typeScheme, valReprInfo, valReprInfoForDisplay, memberInfoOpt, isMutable, inlineFlag, baseOrThis, vis, isCompGen, isIncrClass, isTyFunc, hasDeclaredTypars) valscheme let PlaceTyparsInDeclarationOrder declaredTypars generalizedTypars = @@ -1817,10 +1823,11 @@ let ComputeIsTyFunc(id: Ident, hasDeclaredTypars, arityInfo: ValReprInfo option) | Some info -> info.NumCurriedArgs = 0) let UseSyntacticArity declKind typeScheme prelimValReprInfo = + let valReprInfo = InferGenericArityFromTyScheme typeScheme prelimValReprInfo if DeclKind.MustHaveArity declKind then - Some(InferGenericArityFromTyScheme typeScheme prelimValReprInfo) + Some valReprInfo, None else - None + None, Some valReprInfo /// Combine the results of InferSynValData and InferArityOfExpr. // @@ -1855,18 +1862,17 @@ let UseSyntacticArity declKind typeScheme prelimValReprInfo = // { new Base with // member x.M(v: unit) = () } // -let CombineSyntacticAndInferredArities g declKind rhsExpr prelimScheme = +let CombineSyntacticAndInferredArities g rhsExpr prelimScheme = let (PrelimVal2(_, typeScheme, partialValReprInfoOpt, memberInfoOpt, isMutable, _, _, ArgAndRetAttribs(argAttribs, retAttribs), _, _, _)) = prelimScheme - match partialValReprInfoOpt, DeclKind.MustHaveArity declKind with - | _, false -> None - | None, true -> Some(PrelimValReprInfo([], ValReprInfo.unnamedRetVal)) + match partialValReprInfoOpt with + | None -> Some(PrelimValReprInfo([], ValReprInfo.unnamedRetVal)) // Don't use any expression information for members, where syntax dictates the arity completely | _ when memberInfoOpt.IsSome -> partialValReprInfoOpt // Don't use any expression information for 'let' bindings where return attributes are present | _ when retAttribs.Length > 0 -> partialValReprInfoOpt - | Some partialValReprInfoFromSyntax, true -> + | Some partialValReprInfoFromSyntax -> let (PrelimValReprInfo(curriedArgInfosFromSyntax, retInfoFromSyntax)) = partialValReprInfoFromSyntax let partialArityInfo = if isMutable then @@ -1897,18 +1903,28 @@ let CombineSyntacticAndInferredArities g declKind rhsExpr prelimScheme = Some partialArityInfo +// "let"/"pat" --> TcLetBinding, SynPat, SynSimplePat: Syn* --> PrelimVal1 --> PrelimVal2 --> ValScheme --> Val +// "let rec"/"member"/...., SynPat, SynSimplePat: Syn* --> Val ---> Checking --> Incremental Generalization --> Fixup Val with inferred types + let BuildValScheme declKind partialArityInfoOpt prelimScheme = let (PrelimVal2(id, typeScheme, _, memberInfoOpt, isMutable, inlineFlag, baseOrThis, _, vis, isCompGen, hasDeclaredTypars)) = prelimScheme - let valReprInfo = + let valReprInfoOpt = + match partialArityInfoOpt with + | Some partialValReprInfo -> + let valReprInfo = InferGenericArityFromTyScheme typeScheme partialValReprInfo + Some valReprInfo + | None -> + None + let valReprInfo, valReprInfoForDisplay = if DeclKind.MustHaveArity declKind then - Option.map (InferGenericArityFromTyScheme typeScheme) partialArityInfoOpt + valReprInfoOpt, None else - None + None, valReprInfoOpt let isTyFunc = ComputeIsTyFunc(id, hasDeclaredTypars, valReprInfo) - ValScheme(id, typeScheme, valReprInfo, memberInfoOpt, isMutable, inlineFlag, baseOrThis, vis, isCompGen, false, isTyFunc, hasDeclaredTypars) + ValScheme(id, typeScheme, valReprInfo, valReprInfoForDisplay, memberInfoOpt, isMutable, inlineFlag, baseOrThis, vis, isCompGen, false, isTyFunc, hasDeclaredTypars) let UseCombinedArity g declKind rhsExpr prelimScheme = - let partialArityInfoOpt = CombineSyntacticAndInferredArities g declKind rhsExpr prelimScheme + let partialArityInfoOpt = CombineSyntacticAndInferredArities g rhsExpr prelimScheme BuildValScheme declKind partialArityInfoOpt prelimScheme let UseNoArity prelimScheme = @@ -10229,7 +10245,7 @@ and TcNormalizedBinding declKind (cenv: cenv) env tpenv overallTy safeThisValOpt | [] -> valSynData | {Range=mHead} :: _ -> let (SynValData(valMf, SynValInfo(args, SynArgInfo(attrs, opt, retId)), valId)) = valSynData - in SynValData(valMf, SynValInfo(args, SynArgInfo({Attributes=rotRetSynAttrs; Range=mHead} :: attrs, opt, retId)), valId) + SynValData(valMf, SynValInfo(args, SynArgInfo({Attributes=rotRetSynAttrs; Range=mHead} :: attrs, opt, retId)), valId) retAttribs, valAttribs, valSynData let isVolatile = HasFSharpAttribute g g.attrib_VolatileFieldAttribute valAttribs @@ -10779,7 +10795,7 @@ and TcLetBinding cenv isUse env containerInfo declKind tpenv (synBinds, synBinds // If the overall declaration is declaring statics or a module value, then force the patternInputTmp to also // have representation as module value. - if (DeclKind.MustHaveArity declKind) then + if DeclKind.MustHaveArity declKind then AdjustValToTopVal tmp altActualParent (InferArityOfExprBinding g AllowTypeDirectedDetupling.Yes tmp rhsExpr) tmp, checkedPat @@ -11355,9 +11371,9 @@ and AnalyzeAndMakeAndPublishRecursiveValue // NOTE: top arity, type and typars get fixed-up after inference let prelimTyscheme = GeneralizedType(enclosingDeclaredTypars@declaredTypars, ty) let prelimValReprInfo = TranslateSynValInfo mBinding (TcAttributes cenv envinner) valSynInfo - let valReprInfo = UseSyntacticArity declKind prelimTyscheme prelimValReprInfo + let valReprInfo, valReprInfoForDisplay = UseSyntacticArity declKind prelimTyscheme prelimValReprInfo let hasDeclaredTypars = not (List.isEmpty declaredTypars) - let prelimValScheme = ValScheme(bindingId, prelimTyscheme, valReprInfo, memberInfoOpt, false, inlineFlag, NormalVal, vis, false, false, false, hasDeclaredTypars) + let prelimValScheme = ValScheme(bindingId, prelimTyscheme, valReprInfo, valReprInfoForDisplay, memberInfoOpt, false, inlineFlag, NormalVal, vis, false, false, false, hasDeclaredTypars) // Check the literal r.h.s., if any let _, literalValue = TcLiteral cenv ty envinner tpenv (bindingAttribs, bindingExpr) diff --git a/src/Compiler/Checking/CheckExpressions.fsi b/src/Compiler/Checking/CheckExpressions.fsi index 831a4cf9b20..8b5f1878532 100644 --- a/src/Compiler/Checking/CheckExpressions.fsi +++ b/src/Compiler/Checking/CheckExpressions.fsi @@ -584,12 +584,13 @@ type RecursiveBindingInfo = [] type CheckedBindingInfo -/// Represnts the results of the second phase of checking simple values +/// Represents the results of the second phase of checking simple values type ValScheme = | ValScheme of id: Ident * typeScheme: GeneralizedType * valReprInfo: ValReprInfo option * + valReprInfoForDisplay: ValReprInfo option * memberInfo: PrelimMemberInfo option * isMutable: bool * inlineInfo: ValInline * diff --git a/src/Compiler/Checking/CheckIncrementalClasses.fs b/src/Compiler/Checking/CheckIncrementalClasses.fs index f4371e3c925..f225a9927e8 100644 --- a/src/Compiler/Checking/CheckIncrementalClasses.fs +++ b/src/Compiler/Checking/CheckIncrementalClasses.fs @@ -133,7 +133,7 @@ let TcImplicitCtorLhs_Phase2A(cenv: cenv, env, tpenv, tcref: TyconRef, vis, attr let prelimTyschemeG = GeneralizedType(copyOfTyconTypars, ctorTy) let isComplete = ComputeIsComplete copyOfTyconTypars [] ctorTy let varReprInfo = InferGenericArityFromTyScheme prelimTyschemeG prelimValReprInfo - let ctorValScheme = ValScheme(id, prelimTyschemeG, Some varReprInfo, Some memberInfo, false, ValInline.Never, NormalVal, vis, false, true, false, false) + let ctorValScheme = ValScheme(id, prelimTyschemeG, Some varReprInfo, None, Some memberInfo, false, ValInline.Never, NormalVal, vis, false, true, false, false) let paramNames = varReprInfo.ArgNames let xmlDoc = xmlDoc.ToXmlDoc(true, Some paramNames) let ctorVal = MakeAndPublishVal cenv env (Parent tcref, false, ModuleOrMemberBinding, ValInRecScope isComplete, ctorValScheme, attribs, xmlDoc, None, false) @@ -154,7 +154,7 @@ let TcImplicitCtorLhs_Phase2A(cenv: cenv, env, tpenv, tcref: TyconRef, vis, attr let prelimValReprInfo = TranslateSynValInfo m (TcAttributes cenv env) valSynData let prelimTyschemeG = GeneralizedType(copyOfTyconTypars, cctorTy) let valReprInfo = InferGenericArityFromTyScheme prelimTyschemeG prelimValReprInfo - let cctorValScheme = ValScheme(id, prelimTyschemeG, Some valReprInfo, Some memberInfo, false, ValInline.Never, NormalVal, Some (SynAccess.Private Range.Zero), false, true, false, false) + let cctorValScheme = ValScheme(id, prelimTyschemeG, Some valReprInfo, None, Some memberInfo, false, ValInline.Never, NormalVal, Some (SynAccess.Private Range.Zero), false, true, false, false) let cctorVal = MakeAndPublishVal cenv env (Parent tcref, false, ModuleOrMemberBinding, ValNotInRecScope, cctorValScheme, [(* no attributes*)], XmlDoc.Empty, None, false) cctorArgs, cctorVal, cctorValScheme @@ -162,7 +162,7 @@ let TcImplicitCtorLhs_Phase2A(cenv: cenv, env, tpenv, tcref: TyconRef, vis, attr let thisVal = // --- Create this for use inside constructor let thisId = ident ("this", m) - let thisValScheme = ValScheme(thisId, NonGenericTypeScheme thisTy, None, None, false, ValInline.Never, CtorThisVal, None, true, false, false, false) + let thisValScheme = ValScheme(thisId, NonGenericTypeScheme thisTy, None, None, None, false, ValInline.Never, CtorThisVal, None, true, false, false, false) let thisVal = MakeAndPublishVal cenv env (ParentNone, false, ClassLetBinding false, ValNotInRecScope, thisValScheme, [], XmlDoc.Empty, None, false) thisVal @@ -350,7 +350,7 @@ type IncrClassReprInfo = // NOTE: putting isCompilerGenerated=true here is strange. The method is not public, nor is // it a "member" in the F# sense, but the F# spec says it is generated and it is reasonable to reflect on it. - let memberValScheme = ValScheme(id, prelimTyschemeG, Some valReprInfo, Some memberInfo, false, ValInline.Never, NormalVal, None, true (* isCompilerGenerated *), true (* isIncrClass *), false, false) + let memberValScheme = ValScheme(id, prelimTyschemeG, Some valReprInfo, None, Some memberInfo, false, ValInline.Never, NormalVal, None, true (* isCompilerGenerated *), true (* isIncrClass *), false, false) let methodVal = MakeAndPublishVal cenv env (Parent tcref, false, ModuleOrMemberBinding, ValNotInRecScope, memberValScheme, v.Attribs, XmlDoc.Empty, None, false) diff --git a/src/Compiler/Checking/NicePrint.fs b/src/Compiler/Checking/NicePrint.fs index 3a398620de9..6d8b38c7956 100644 --- a/src/Compiler/Checking/NicePrint.fs +++ b/src/Compiler/Checking/NicePrint.fs @@ -1270,7 +1270,8 @@ module PrintTastMemberOrVals = let layoutNonMemberVal denv (tps, v: Val, tau, cxs) = let env = SimplifyTypes.CollectInfo true [tau] cxs let cxs = env.postfixConstraints - let argInfos, retTy = GetTopTauTypeInFSharpForm denv.g (arityOfVal v).ArgInfos tau v.Range + let valReprInfo = arityOfValForDisplay v + let argInfos, retTy = GetTopTauTypeInFSharpForm denv.g valReprInfo.ArgInfos tau v.Range let nameL = let tagF = diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index 1459fc99984..bea20761e41 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -1977,7 +1977,8 @@ and AdjustAccess isHidden (cpath: unit -> CompilationPath) access = else access -and CheckBinding cenv env alwaysCheckNoReraise ctxt (TBind(v, bindRhs, _) as bind) : Limit = +and CheckBinding cenv env alwaysCheckNoReraise ctxt bind : Limit = + let (TBind(v, bindRhs, _)) = bind let vref = mkLocalValRef v let g = cenv.g let isTop = Option.isSome bind.Var.ValReprInfo diff --git a/src/Compiler/Checking/PostInferenceChecks.fsi b/src/Compiler/Checking/PostInferenceChecks.fsi index 6e289af71c8..4230c06e371 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fsi +++ b/src/Compiler/Checking/PostInferenceChecks.fsi @@ -10,7 +10,7 @@ open FSharp.Compiler.TypedTree open FSharp.Compiler.TypedTreeOps open FSharp.Compiler.TcGlobals -/// Perform the checks on the TAST for a file after type inference is complete. +/// Perform the checks on the TypedTree for a file after type inference is complete. val CheckImplFile: g: TcGlobals * amap: ImportMap * @@ -23,6 +23,6 @@ val CheckImplFile: implFileTy: ModuleOrNamespaceType * implFileContents: ModuleOrNamespaceContents * extraAttribs: Attribs * - (bool * bool) * + isLastCompiland: (bool * bool) * isInternalTestSpanStackReferring: bool -> bool * StampMap diff --git a/src/Compiler/TypedTree/TypedTree.fs b/src/Compiler/TypedTree/TypedTree.fs index 3b328134868..23d252f0e84 100644 --- a/src/Compiler/TypedTree/TypedTree.fs +++ b/src/Compiler/TypedTree/TypedTree.fs @@ -2488,6 +2488,9 @@ type ValOptionalData = /// Used to implement [] mutable val_defn: Expr option + /// Records the "extra information" for a value compiled as a method (rather + /// than a closure or a local), including argument names, attributes etc. + // // MUTABILITY CLEANUP: mutability of this field is used by // -- adjustAllUsesOfRecValue // -- TLR optimizations @@ -2497,6 +2500,10 @@ type ValOptionalData = // type-checked expression. mutable val_repr_info: ValReprInfo option + /// Records the "extra information" for display purposes for expression-level function definitions + /// that may be compiled as closures (that is are not-necessarily compiled as top-level methods). + mutable val_repr_info_for_display: ValReprInfo option + /// How visible is this? /// MUTABILITY: for unpickle linkage mutable val_access: Accessibility @@ -2556,6 +2563,7 @@ type Val = val_const = None val_defn = None val_repr_info = None + val_repr_info_for_display = None val_access = TAccess [] val_xmldoc = XmlDoc.Empty val_member_info = None @@ -2620,6 +2628,11 @@ type Val = | Some optData -> optData.val_repr_info | _ -> None + member x.ValReprInfoForDisplay: ValReprInfo option = + match x.val_opt_data with + | Some optData -> optData.val_repr_info_for_display + | _ -> None + member x.Id = ident(x.LogicalName, x.Range) /// Is this represented as a "top level" static binding (i.e. a static field, static member, @@ -2996,34 +3009,39 @@ type Val = member x.SetValReprInfo info = match x.val_opt_data with | Some optData -> optData.val_repr_info <- info - | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_repr_info = info } + | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_repr_info = info } + + member x.SetValReprInfoForDisplay info = + match x.val_opt_data with + | Some optData -> optData.val_repr_info_for_display <- info + | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_repr_info_for_display = info } member x.SetType ty = x.val_type <- ty member x.SetOtherRange m = match x.val_opt_data with | Some optData -> optData.val_other_range <- Some m - | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_other_range = Some m } + | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_other_range = Some m } member x.SetDeclaringEntity parent = match x.val_opt_data with | Some optData -> optData.val_declaring_entity <- parent - | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_declaring_entity = parent } + | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_declaring_entity = parent } member x.SetAttribs attribs = match x.val_opt_data with | Some optData -> optData.val_attribs <- attribs - | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_attribs = attribs } + | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_attribs = attribs } member x.SetMemberInfo member_info = match x.val_opt_data with | Some optData -> optData.val_member_info <- Some member_info - | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_member_info = Some member_info } + | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_member_info = Some member_info } member x.SetValDefn val_defn = match x.val_opt_data with | Some optData -> optData.val_defn <- Some val_defn - | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_defn = Some val_defn } + | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_defn = Some val_defn } /// Create a new value with empty, unlinked data. Only used during unpickling of F# metadata. static member NewUnlinked() : Val = @@ -3055,6 +3073,7 @@ type Val = val_other_range = tg.val_other_range val_const = tg.val_const val_defn = tg.val_defn + val_repr_info_for_display = tg.val_repr_info_for_display val_repr_info = tg.val_repr_info val_access = tg.val_access val_xmldoc = tg.val_xmldoc diff --git a/src/Compiler/TypedTree/TypedTree.fsi b/src/Compiler/TypedTree/TypedTree.fsi index d2a23e73038..50eec286e7b 100644 --- a/src/Compiler/TypedTree/TypedTree.fsi +++ b/src/Compiler/TypedTree/TypedTree.fsi @@ -1777,8 +1777,15 @@ type ValOptionalData = /// What is the original, unoptimized, closed-term definition, if any? /// Used to implement [] mutable val_defn: Expr option + + /// Records the "extra information" for a value compiled as a method (rather + /// than a closure or a local), including argument names, attributes etc. mutable val_repr_info: ValReprInfo option + /// Records the "extra information" for display purposes for expression-level function definitions + /// that may be compiled as closures (that is are not-necessarily compiled as top-level methods). + mutable val_repr_info_for_display: ValReprInfo option + /// How visible is this? /// MUTABILITY: for unpickle linkage mutable val_access: Accessibility @@ -1888,6 +1895,8 @@ type Val = member SetValReprInfo: info: ValReprInfo option -> unit + member SetValReprInfoForDisplay: info: ValReprInfo option -> unit + override ToString: unit -> string /// How visible is this value, function or member? @@ -2134,6 +2143,10 @@ type Val = /// represent as "top level" bindings. member ValReprInfo: ValReprInfo option + /// Records the "extra information" for display purposes for expression-level function definitions + /// that may be compiled as closures (that is are not-necessarily compiled as top-level methods). + member ValReprInfoForDisplay: ValReprInfo option + /// Get the declared documentation for the value member XmlDoc: XmlDoc diff --git a/src/Compiler/TypedTree/TypedTreeBasics.fs b/src/Compiler/TypedTree/TypedTreeBasics.fs index b0020664ff7..e3010176807 100644 --- a/src/Compiler/TypedTree/TypedTreeBasics.fs +++ b/src/Compiler/TypedTree/TypedTreeBasics.fs @@ -41,6 +41,11 @@ module ValReprInfo = let emptyValData = ValReprInfo([], [], unnamedRetVal) + let IsEmpty info = + match info with + | ValReprInfo([], [], { Attribs = []; Name=None }) -> true + | _ -> false + let InferTyparInfo (tps: Typar list) = tps |> List.map (fun tp -> TyparReprInfo(tp.Id, tp.Kind)) let InferArgReprInfo (v: Val) : ArgReprInfo = { Attribs = []; Name= Some v.Id } @@ -59,7 +64,18 @@ let typesOfVals (v: Val list) = v |> List.map (fun v -> v.Type) let nameOfVal (v: Val) = v.LogicalName -let arityOfVal (v: Val) = (match v.ValReprInfo with None -> ValReprInfo.emptyValData | Some arities -> arities) +let arityOfVal (v: Val) = + match v.ValReprInfo with + | None -> ValReprInfo.emptyValData + | Some info -> info + +let arityOfValForDisplay (v: Val) = + match v.ValReprInfoForDisplay with + | Some info -> info + | None -> + match v.ValReprInfo with + | None -> ValReprInfo.emptyValData + | Some info -> info let tupInfoRef = TupInfo.Const false diff --git a/src/Compiler/TypedTree/TypedTreeBasics.fsi b/src/Compiler/TypedTree/TypedTreeBasics.fsi index 246a9e74baa..fe4930a71d7 100644 --- a/src/Compiler/TypedTree/TypedTreeBasics.fsi +++ b/src/Compiler/TypedTree/TypedTreeBasics.fsi @@ -29,6 +29,8 @@ module ValReprInfo = val emptyValData: ValReprInfo + val IsEmpty: ValReprInfo -> bool + val InferTyparInfo: tps: Typar list -> TyparReprInfo list val InferArgReprInfo: v: Val -> ArgReprInfo @@ -45,6 +47,8 @@ val nameOfVal: v: Val -> string val arityOfVal: v: Val -> ValReprInfo +val arityOfValForDisplay: v: Val -> ValReprInfo + val tupInfoRef: TupInfo val tupInfoStruct: TupInfo diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index fd00a1f94bd..ca7acd4cc12 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -5359,8 +5359,10 @@ let InferArityOfExpr g allowTypeDirectedDetupling ty partialArgAttribsL retAttri (ids, attribs) ||> List.map2 (fun id attribs -> { Name = id; Attribs = attribs }: ArgReprInfo )) let retInfo: ArgReprInfo = { Attribs = retAttribs; Name = None } - ValReprInfo (ValReprInfo.InferTyparInfo tps, curriedArgInfos, retInfo) + let info = ValReprInfo (ValReprInfo.InferTyparInfo tps, curriedArgInfos, retInfo) + if ValReprInfo.IsEmpty info then ValReprInfo.emptyValData else info +let x = 1 let InferArityOfExprBinding g allowTypeDirectedDetupling (v: Val) expr = match v.ValReprInfo with | Some info -> info diff --git a/src/Compiler/TypedTree/TypedTreePickle.fs b/src/Compiler/TypedTree/TypedTreePickle.fs index eda40c33fb5..3f5ba37afde 100644 --- a/src/Compiler/TypedTree/TypedTreePickle.fs +++ b/src/Compiler/TypedTree/TypedTreePickle.fs @@ -2353,6 +2353,7 @@ and u_ValData st = val_other_range = (match x1a with None -> None | Some(_, b) -> Some(b, true)) val_defn = None val_repr_info = x10 + val_repr_info_for_display = None val_const = x14 val_access = x13 val_xmldoc = defaultArg x15 XmlDoc.Empty From e3e39732adc1870d0b33a78a5480ccf8190b3edf Mon Sep 17 00:00:00 2001 From: Peter Semkin Date: Mon, 11 Jul 2022 15:55:10 +0200 Subject: [PATCH 02/11] Update --- src/Compiler/Checking/CheckExpressions.fs | 12 +++--------- src/Compiler/Checking/PostInferenceChecks.fs | 3 +-- src/Compiler/Checking/PostInferenceChecks.fsi | 4 ++-- src/Compiler/TypedTree/TypedTree.fs | 16 ++++++++-------- src/Compiler/TypedTree/TypedTree.fsi | 4 ++-- src/Compiler/TypedTree/TypedTreeBasics.fs | 2 +- src/Compiler/TypedTree/TypedTreeOps.fs | 1 - 7 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index a3114d259c5..d513a326a74 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -1903,18 +1903,12 @@ let CombineSyntacticAndInferredArities g rhsExpr prelimScheme = Some partialArityInfo -// "let"/"pat" --> TcLetBinding, SynPat, SynSimplePat: Syn* --> PrelimVal1 --> PrelimVal2 --> ValScheme --> Val -// "let rec"/"member"/...., SynPat, SynSimplePat: Syn* --> Val ---> Checking --> Incremental Generalization --> Fixup Val with inferred types - let BuildValScheme declKind partialArityInfoOpt prelimScheme = let (PrelimVal2(id, typeScheme, _, memberInfoOpt, isMutable, inlineFlag, baseOrThis, _, vis, isCompGen, hasDeclaredTypars)) = prelimScheme let valReprInfoOpt = - match partialArityInfoOpt with - | Some partialValReprInfo -> - let valReprInfo = InferGenericArityFromTyScheme typeScheme partialValReprInfo - Some valReprInfo - | None -> - None + partialArityInfoOpt + |> Option.map (InferGenericArityFromTyScheme typeScheme) + let valReprInfo, valReprInfoForDisplay = if DeclKind.MustHaveArity declKind then valReprInfoOpt, None diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index bea20761e41..1459fc99984 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -1977,8 +1977,7 @@ and AdjustAccess isHidden (cpath: unit -> CompilationPath) access = else access -and CheckBinding cenv env alwaysCheckNoReraise ctxt bind : Limit = - let (TBind(v, bindRhs, _)) = bind +and CheckBinding cenv env alwaysCheckNoReraise ctxt (TBind(v, bindRhs, _) as bind) : Limit = let vref = mkLocalValRef v let g = cenv.g let isTop = Option.isSome bind.Var.ValReprInfo diff --git a/src/Compiler/Checking/PostInferenceChecks.fsi b/src/Compiler/Checking/PostInferenceChecks.fsi index 4230c06e371..6e289af71c8 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fsi +++ b/src/Compiler/Checking/PostInferenceChecks.fsi @@ -10,7 +10,7 @@ open FSharp.Compiler.TypedTree open FSharp.Compiler.TypedTreeOps open FSharp.Compiler.TcGlobals -/// Perform the checks on the TypedTree for a file after type inference is complete. +/// Perform the checks on the TAST for a file after type inference is complete. val CheckImplFile: g: TcGlobals * amap: ImportMap * @@ -23,6 +23,6 @@ val CheckImplFile: implFileTy: ModuleOrNamespaceType * implFileContents: ModuleOrNamespaceContents * extraAttribs: Attribs * - isLastCompiland: (bool * bool) * + (bool * bool) * isInternalTestSpanStackReferring: bool -> bool * StampMap diff --git a/src/Compiler/TypedTree/TypedTree.fs b/src/Compiler/TypedTree/TypedTree.fs index 23d252f0e84..2d3f8c0943f 100644 --- a/src/Compiler/TypedTree/TypedTree.fs +++ b/src/Compiler/TypedTree/TypedTree.fs @@ -2501,7 +2501,7 @@ type ValOptionalData = mutable val_repr_info: ValReprInfo option /// Records the "extra information" for display purposes for expression-level function definitions - /// that may be compiled as closures (that is are not-necessarily compiled as top-level methods). + /// that may be compiled as closures (that is are not necessarily compiled as top-level methods). mutable val_repr_info_for_display: ValReprInfo option /// How visible is this? @@ -3009,39 +3009,39 @@ type Val = member x.SetValReprInfo info = match x.val_opt_data with | Some optData -> optData.val_repr_info <- info - | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_repr_info = info } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_repr_info = info } member x.SetValReprInfoForDisplay info = match x.val_opt_data with | Some optData -> optData.val_repr_info_for_display <- info - | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_repr_info_for_display = info } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_repr_info_for_display = info } member x.SetType ty = x.val_type <- ty member x.SetOtherRange m = match x.val_opt_data with | Some optData -> optData.val_other_range <- Some m - | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_other_range = Some m } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_other_range = Some m } member x.SetDeclaringEntity parent = match x.val_opt_data with | Some optData -> optData.val_declaring_entity <- parent - | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_declaring_entity = parent } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_declaring_entity = parent } member x.SetAttribs attribs = match x.val_opt_data with | Some optData -> optData.val_attribs <- attribs - | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_attribs = attribs } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_attribs = attribs } member x.SetMemberInfo member_info = match x.val_opt_data with | Some optData -> optData.val_member_info <- Some member_info - | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_member_info = Some member_info } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_member_info = Some member_info } member x.SetValDefn val_defn = match x.val_opt_data with | Some optData -> optData.val_defn <- Some val_defn - | None -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_defn = Some val_defn } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_defn = Some val_defn } /// Create a new value with empty, unlinked data. Only used during unpickling of F# metadata. static member NewUnlinked() : Val = diff --git a/src/Compiler/TypedTree/TypedTree.fsi b/src/Compiler/TypedTree/TypedTree.fsi index 50eec286e7b..cdcf93e4518 100644 --- a/src/Compiler/TypedTree/TypedTree.fsi +++ b/src/Compiler/TypedTree/TypedTree.fsi @@ -1783,7 +1783,7 @@ type ValOptionalData = mutable val_repr_info: ValReprInfo option /// Records the "extra information" for display purposes for expression-level function definitions - /// that may be compiled as closures (that is are not-necessarily compiled as top-level methods). + /// that may be compiled as closures (that is are not necessarily compiled as top-level methods). mutable val_repr_info_for_display: ValReprInfo option /// How visible is this? @@ -2144,7 +2144,7 @@ type Val = member ValReprInfo: ValReprInfo option /// Records the "extra information" for display purposes for expression-level function definitions - /// that may be compiled as closures (that is are not-necessarily compiled as top-level methods). + /// that may be compiled as closures (that is are not necessarily compiled as top-level methods). member ValReprInfoForDisplay: ValReprInfo option /// Get the declared documentation for the value diff --git a/src/Compiler/TypedTree/TypedTreeBasics.fs b/src/Compiler/TypedTree/TypedTreeBasics.fs index e3010176807..1ec0b619604 100644 --- a/src/Compiler/TypedTree/TypedTreeBasics.fs +++ b/src/Compiler/TypedTree/TypedTreeBasics.fs @@ -26,7 +26,7 @@ let getNameOfScopeRef sref = | ILScopeRef.Assembly aref -> aref.Name | ILScopeRef.PrimaryAssembly -> "" -/// Metadata on values (names of arguments etc. +/// Metadata on values (names of arguments etc.) module ValReprInfo = let unnamedTopArg1: ArgReprInfo = { Attribs=[]; Name=None } diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index ca7acd4cc12..cef7fe70b74 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -5362,7 +5362,6 @@ let InferArityOfExpr g allowTypeDirectedDetupling ty partialArgAttribsL retAttri let info = ValReprInfo (ValReprInfo.InferTyparInfo tps, curriedArgInfos, retInfo) if ValReprInfo.IsEmpty info then ValReprInfo.emptyValData else info -let x = 1 let InferArityOfExprBinding g allowTypeDirectedDetupling (v: Val) expr = match v.ValReprInfo with | Some info -> info From d5ebbb257168fbbe567b36313c1503ae34f197bd Mon Sep 17 00:00:00 2001 From: Peter Semkin Date: Mon, 11 Jul 2022 16:08:17 +0200 Subject: [PATCH 03/11] Update QuickInfoTests.fs --- vsintegration/tests/UnitTests/QuickInfoTests.fs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/vsintegration/tests/UnitTests/QuickInfoTests.fs b/vsintegration/tests/UnitTests/QuickInfoTests.fs index d255f0f3d34..2eba8d122ca 100644 --- a/vsintegration/tests/UnitTests/QuickInfoTests.fs +++ b/vsintegration/tests/UnitTests/QuickInfoTests.fs @@ -476,3 +476,20 @@ module Test = StringAssert.StartsWith(expectedSignature, tooltip) () + +[] +let ``Automation.LetBindings.InsideExpression``() = + let code = """ +namespace FsTest + +module Test = + do + let fu$$nc x = () +""" + + let expectedSignature = "val func: x: 'a -> unit" + + let tooltip = GetQuickInfoTextFromCode code + + StringAssert.StartsWith(expectedSignature, tooltip) + () From ff8cf853d33b4e8bfbf56728c97acd62cf07ff9c Mon Sep 17 00:00:00 2001 From: Peter Semkin Date: Mon, 11 Jul 2022 16:18:49 +0200 Subject: [PATCH 04/11] Update QuickInfoTests.fs --- .../tests/UnitTests/QuickInfoTests.fs | 49 ++++--------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/vsintegration/tests/UnitTests/QuickInfoTests.fs b/vsintegration/tests/UnitTests/QuickInfoTests.fs index 2eba8d122ca..4be1be1115b 100644 --- a/vsintegration/tests/UnitTests/QuickInfoTests.fs +++ b/vsintegration/tests/UnitTests/QuickInfoTests.fs @@ -428,65 +428,34 @@ module Test = Assert.AreEqual(expected, quickInfo) () -[] -let ``Automation.LetBindings.InsideModule``() = - let code = """ +[] -let ``Automation.LetBindings.InsideType.Instance``() = - let code = """ +""">] +[] -let ``Automation.LetBindings.InsideType.Static``() = - let code = """ +""">] +[] -let ``Automation.LetBindings.InsideExpression``() = - let code = """ +""">] +[] +let ``Automation.LetBindings`` code = let expectedSignature = "val func: x: 'a -> unit" let tooltip = GetQuickInfoTextFromCode code From 662422e1c221a26206bc15146f2b633f933d5241 Mon Sep 17 00:00:00 2001 From: Peter Semkin Date: Mon, 11 Jul 2022 16:39:05 +0200 Subject: [PATCH 05/11] Update --- vsintegration/tests/UnitTests/QuickInfoTests.fs | 1 + 1 file changed, 1 insertion(+) diff --git a/vsintegration/tests/UnitTests/QuickInfoTests.fs b/vsintegration/tests/UnitTests/QuickInfoTests.fs index 4be1be1115b..0e65489a70d 100644 --- a/vsintegration/tests/UnitTests/QuickInfoTests.fs +++ b/vsintegration/tests/UnitTests/QuickInfoTests.fs @@ -454,6 +454,7 @@ namespace FsTest module Test = do let fu$$nc x = () + () """>] let ``Automation.LetBindings`` code = let expectedSignature = "val func: x: 'a -> unit" From de49e2f14f4c0ce3c1f9567c18a9f4713ae3151d Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 11 Jul 2022 16:44:32 +0100 Subject: [PATCH 06/11] add identifier analysis script (#13486) * add identifier analysis script * add identifier analysis script --- tests/scripts/identifierAnalysisByType.fsx | 152 +++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 tests/scripts/identifierAnalysisByType.fsx diff --git a/tests/scripts/identifierAnalysisByType.fsx b/tests/scripts/identifierAnalysisByType.fsx new file mode 100644 index 00000000000..7ac8de7a20b --- /dev/null +++ b/tests/scripts/identifierAnalysisByType.fsx @@ -0,0 +1,152 @@ +// Print some stats about identifiers grouped by type +// + +#r "nuget: Ionide.ProjInfo" +#I @"..\..\artifacts\bin\fsc\Debug\net6.0\" +#r "FSharp.Compiler.Service.dll" + +open System +open System.IO +open Ionide.ProjInfo +open FSharp.Compiler.CodeAnalysis +open FSharp.Compiler.Symbols +open Ionide.ProjInfo.Types + +let argv = fsi.CommandLineArgs + +if argv.Length = 1 then + eprintfn "usage:" + eprintfn " dotnet fsi tests/scripts/identifierAnalysisByType.fsx " + eprintfn "" + eprintfn "examples:" + eprintfn " dotnet fsi tests/scripts/identifierAnalysisByType.fsx src/FSharp.Build/FSharp.Build.fsproj" + eprintfn " dotnet fsi tests/scripts/identifierAnalysisByType.fsx src/Compiler/FSharp.Compiler.Service.fsproj" + eprintfn "" + eprintfn "Sample output is at https://gist.github.com/dsyme/abfa11bebf0713251418906d55c08804" + +//let projectFile = Path.Combine(__SOURCE_DIRECTORY__, @"..\..\src\Compiler\FSharp.Compiler.Service.fsproj") +//let projectFile = Path.Combine(__SOURCE_DIRECTORY__, @"..\..\src\FSharp.Build\FSharp.Build.fsproj") +let projectFile = Path.GetFullPath(argv[1]) + +let cwd = System.Environment.CurrentDirectory |> System.IO.DirectoryInfo + +let _toolsPath = Init.init cwd None + +printfn "Cracking project options...." +let opts = + match ProjectLoader.getProjectInfo projectFile [] BinaryLogGeneration.Off [] with + | Result.Ok res -> res + | Result.Error err -> failwithf "%s" err + +let checker = FSharpChecker.Create() + +let checkerOpts = checker.GetProjectOptionsFromCommandLineArgs(projectFile, [| yield! opts.SourceFiles; yield! opts.OtherOptions |] ) + +printfn "Checking project...." +let results = checker.ParseAndCheckProject(checkerOpts) |> Async.RunSynchronously + +printfn "Grouping symbol uses...." +let symbols = results.GetAllUsesOfAllSymbols() + +let rec stripTy (ty: FSharpType) = + if ty.IsAbbreviation then stripTy ty.AbbreviatedType else ty + +let getTypeText (sym: FSharpMemberOrFunctionOrValue) = + let ty = stripTy sym.FullType + FSharpType.Prettify(ty).Format(FSharpDisplayContext.Empty) + +symbols +|> Array.choose (fun vUse -> match vUse.Symbol with :? FSharpMemberOrFunctionOrValue as v -> Some (v, vUse.Range) | _ -> None) +|> Array.filter (fun (v, _) -> v.GenericParameters.Count = 0) +|> Array.filter (fun (v, _) -> v.CurriedParameterGroups.Count = 0) +|> Array.filter (fun (v, _) -> not v.FullType.IsGenericParameter) +|> Array.map (fun (v, vUse) -> getTypeText v, v, vUse) +|> Array.filter (fun (vTypeText, v, _) -> + match vTypeText with + | "System.String" -> false + | "System.Boolean" -> false + | "System.Int32" -> false + | "System.Int64" -> false + | "System.Object" -> false + | "Microsoft.FSharp.Collections.List" -> false + | "Microsoft.FSharp.Core.Option" -> false + | s when s.EndsWith(" Microsoft.FSharp.Core.[]") -> false // for now filter array types + | _ when v.DisplayName.StartsWith "_" -> false + | _ -> true) +|> Array.groupBy (fun (vTypeText, _, _) -> vTypeText) +|> Array.map (fun (key, g) -> + key, + (g + |> Array.groupBy (fun (_, v, _) -> v.DisplayName) + |> Array.sortByDescending (snd >> Array.length))) +|> Array.filter (fun (_, g) -> g.Length > 1) +|> Array.sortByDescending (fun (key, g) -> Array.length g) +|> Array.iter (fun (key, g) -> + let key = key.Replace("Microsoft.FSharp", "FSharp").Replace("FSharp.Core.", "") + printfn "Type: %s" key + for (nm, entries) in g do + printfn " %s (%d times)" nm (Array.length entries) + for (_, _, vUse) in entries do + printfn " %s" (vUse.ToString()) + printfn "") + +(* +let isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + +let dotnet = + if isWindows then + "dotnet.exe" + else + "dotnet" +let fileExists pathToFile = + try + File.Exists(pathToFile) + with _ -> + false +// Look for global install of dotnet sdk +let getDotnetGlobalHostPath () = + let pf = Environment.GetEnvironmentVariable("ProgramW6432") + + let pf = + if String.IsNullOrEmpty(pf) then + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + else + pf + + let candidate = Path.Combine(pf, "dotnet", dotnet) + + if fileExists candidate then + Some candidate + else + // Can't find it --- give up + None + +let getDotnetHostPath () = + let probePathForDotnetHost () = + let paths = + let p = Environment.GetEnvironmentVariable("PATH") + + if not (isNull p) then + p.Split(Path.PathSeparator) + else + [||] + + paths |> Array.tryFind (fun f -> fileExists (Path.Combine(f, dotnet))) + + match (Environment.GetEnvironmentVariable("DOTNET_HOST_PATH")) with + // Value set externally + | value when not (String.IsNullOrEmpty(value)) && fileExists value -> Some value + | _ -> + // Probe for netsdk install, dotnet. and dotnet.exe is a constant offset from the location of System.Int32 + let candidate = + let assemblyLocation = Path.GetDirectoryName(typeof.Assembly.Location) + Path.GetFullPath(Path.Combine(assemblyLocation, "..", "..", "..", dotnet)) + + if fileExists candidate then + Some candidate + else + match probePathForDotnetHost () with + | Some f -> Some(Path.Combine(f, dotnet)) + | None -> getDotnetGlobalHostPath () +let dotnetExe = getDotnetHostPath () |> Option.map System.IO.FileInfo +*) From 575d5e7519fda9621730a0fceeb5334b9bc7c584 Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Mon, 11 Jul 2022 18:01:44 +0200 Subject: [PATCH 07/11] Update fantomas alpha 11 (#13481) --- .config/dotnet-tools.json | 2 +- src/Compiler/AbstractIL/il.fs | 62 ++-- src/Compiler/AbstractIL/ilnativeres.fs | 12 +- src/Compiler/AbstractIL/ilprint.fs | 60 ++-- src/Compiler/AbstractIL/ilread.fs | 81 +++--- src/Compiler/AbstractIL/ilreflect.fs | 57 ++-- src/Compiler/AbstractIL/ilsupp.fs | 6 +- src/Compiler/AbstractIL/ilsupp.fsi | 12 +- src/Compiler/AbstractIL/ilwritepdb.fs | 22 +- src/Compiler/AbstractIL/ilx.fs | 2 +- src/Compiler/AbstractIL/ilx.fsi | 2 +- src/Compiler/CodeGen/EraseClosures.fs | 16 +- src/Compiler/CodeGen/EraseUnions.fs | 17 +- src/Compiler/CodeGen/IlxGen.fs | 275 +++++++++++------- src/Compiler/Driver/CompilerConfig.fs | 26 +- src/Compiler/Driver/CompilerDiagnostics.fs | 13 +- src/Compiler/Driver/CompilerImports.fs | 29 +- src/Compiler/Driver/CompilerOptions.fs | 17 +- src/Compiler/Driver/CreateILModule.fs | 25 +- src/Compiler/Driver/FxResolver.fs | 24 +- src/Compiler/Driver/OptimizeInputs.fs | 6 +- src/Compiler/Driver/ParseAndCheckInputs.fs | 3 +- src/Compiler/Driver/ScriptClosure.fs | 3 +- src/Compiler/Driver/StaticLinking.fs | 13 +- src/Compiler/Driver/XmlDocFileWriter.fs | 7 +- src/Compiler/Driver/fsc.fs | 40 ++- src/Compiler/Service/FSharpCheckerResults.fs | 24 +- .../Service/FSharpParseFileResults.fs | 13 +- src/Compiler/Service/ItemKey.fs | 8 +- .../Service/SemanticClassification.fs | 20 +- src/Compiler/Service/ServiceAnalysis.fs | 15 +- .../Service/ServiceInterfaceStubGenerator.fs | 34 ++- src/Compiler/Service/ServiceLexing.fs | 6 +- src/Compiler/Service/ServiceNavigation.fs | 8 +- .../Service/ServiceParamInfoLocations.fs | 12 +- src/Compiler/Service/ServiceParseTreeWalk.fs | 21 +- src/Compiler/Service/ServiceParsedInputOps.fs | 8 +- src/Compiler/Service/ServiceStructure.fs | 30 +- src/Compiler/Service/service.fs | 10 +- src/Compiler/SyntaxTree/LexHelpers.fs | 14 +- src/Compiler/SyntaxTree/ParseHelpers.fs | 2 +- src/Compiler/SyntaxTree/PrettyNaming.fs | 8 +- src/Compiler/SyntaxTree/XmlDoc.fs | 5 +- src/Compiler/Utilities/FileSystem.fs | 18 +- src/Compiler/Utilities/HashMultiMap.fs | 3 +- src/Compiler/Utilities/ImmutableArray.fs | 9 +- src/Compiler/Utilities/ResizeArray.fs | 13 +- src/Compiler/Utilities/illib.fs | 11 +- src/Compiler/Utilities/range.fs | 24 +- src/Compiler/Utilities/sformat.fs | 35 ++- src/FSharp.Build/FSharpEmbedResXSource.fs | 8 +- src/FSharp.Core/QueryExtensions.fs | 2 +- src/FSharp.Core/array.fs | 11 +- src/FSharp.Core/async.fs | 19 +- src/FSharp.Core/eventmodule.fs | 6 +- src/FSharp.Core/list.fs | 13 +- src/FSharp.Core/map.fs | 6 +- src/FSharp.Core/observable.fs | 20 +- src/FSharp.Core/quotations.fs | 8 +- src/FSharp.Core/reflect.fs | 30 +- src/FSharp.Core/seq.fs | 61 ++-- .../FSharp.DependencyManager.Utilities.fs | 4 +- src/fsc/fscmain.fs | 6 +- src/fsi/console.fs | 15 +- src/fsi/fsimain.fs | 6 +- 65 files changed, 885 insertions(+), 513 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 057b9c816db..9a25558c924 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "fantomas": { - "version": "5.0.0-alpha-008", + "version": "5.0.0-alpha-011", "commands": [ "fantomas" ] diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index ed951e0a03b..3600b0e2cf4 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -25,7 +25,9 @@ open Internal.Utilities let logging = false -let _ = if logging then dprintn "* warning: Il.logging is on" +let _ = + if logging then + dprintn "* warning: Il.logging is on" let int_order = LanguagePrimitives.FastGenericComparer @@ -68,11 +70,13 @@ let memoizeNamespaceRightTable = let memoizeNamespacePartTable = ConcurrentDictionary() let splitNameAt (nm: string) idx = - if idx < 0 then failwith "splitNameAt: idx < 0" + if idx < 0 then + failwith "splitNameAt: idx < 0" let last = nm.Length - 1 - if idx > last then failwith "splitNameAt: idx > last" + if idx > last then + failwith "splitNameAt: idx > last" (nm.Substring(0, idx)), (if idx < last then nm.Substring(idx + 1, last - idx) else "") @@ -551,7 +555,8 @@ type ILAssemblyRef(data) = addC (convDigit (int32 v / 16)) addC (convDigit (int32 v % 16)) // retargetable can be true only for system assemblies that definitely have Version - if aref.Retargetable then add ", Retargetable=Yes" + if aref.Retargetable then + add ", Retargetable=Yes" b.ToString() @@ -2497,8 +2502,10 @@ let typeKindOfFlags nm (super: ILType option) flags = if name = "System.Enum" then ILTypeDefKind.Enum - elif (name = "System.Delegate" && nm <> "System.MulticastDelegate") - || name = "System.MulticastDelegate" then + elif + (name = "System.Delegate" && nm <> "System.MulticastDelegate") + || name = "System.MulticastDelegate" + then ILTypeDefKind.Delegate elif name = "System.ValueType" && nm <> "System.Enum" then ILTypeDefKind.ValueType @@ -3925,7 +3932,8 @@ let cdef_cctorCode2CodeOrCreate tag imports f (cd: ILTypeDef) = [| yield f cctor for md in mdefs do - if md.Name <> ".cctor" then yield md + if md.Name <> ".cctor" then + yield md |]) cd.With(methods = methods) @@ -4888,7 +4896,8 @@ type ILTypeSigParser(tstring: string) = // Does the type name start with a leading '['? If so, ignore it // (if the specialization type is in another module, it will be wrapped in bracket) - if here () = '[' then drop () + if here () = '[' then + drop () // 1. Iterate over beginning of type, grabbing the type name and determining if it's generic or an array let typeName = @@ -4947,8 +4956,11 @@ type ILTypeSigParser(tstring: string) = let scope = if (here () = ',' || here () = ' ') && (peek () <> '[' && peekN 2 <> '[') then let grabScopeComponent () = - if here () = ',' then drop () // ditch the ',' - if here () = ' ' then drop () // ditch the ' ' + if here () = ',' then + drop () // ditch the ',' + + if here () = ' ' then + drop () // ditch the ' ' while (peek () <> ',' && peek () <> ']' && peek () <> nil) do step () @@ -4969,8 +4981,11 @@ type ILTypeSigParser(tstring: string) = ILScopeRef.Local // strip any extraneous trailing brackets or commas - if (here () = ']') then drop () - if (here () = ',') then drop () + if (here () = ']') then + drop () + + if (here () = ',') then + drop () // build the IL type let tref = mkILTyRef (scope, typeName) @@ -5549,17 +5564,18 @@ let resolveILMethodRefWithRescope r (td: ILTypeDef) (mref: ILMethodRef) = let argTypes = mref.ArgTypes |> List.map r let retType: ILType = r mref.ReturnType - match possibles - |> List.filter (fun md -> - mref.CallingConv = md.CallingConv - && - // REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct - (md.Parameters, argTypes) - ||> List.lengthsEqAndForall2 (fun p1 p2 -> r p1.Type = p2) - && - // REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct - r md.Return.Type = retType) - with + match + possibles + |> List.filter (fun md -> + mref.CallingConv = md.CallingConv + && + // REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct + (md.Parameters, argTypes) + ||> List.lengthsEqAndForall2 (fun p1 p2 -> r p1.Type = p2) + && + // REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct + r md.Return.Type = retType) + with | [] -> failwith ( "no method named " diff --git a/src/Compiler/AbstractIL/ilnativeres.fs b/src/Compiler/AbstractIL/ilnativeres.fs index 3c0752ea8db..70846577d68 100644 --- a/src/Compiler/AbstractIL/ilnativeres.fs +++ b/src/Compiler/AbstractIL/ilnativeres.fs @@ -96,8 +96,10 @@ type CvtResFile() = reader.Read(pAdditional.data, 0, pAdditional.data.Length) |> ignore stream.Position <- stream.Position + 3L &&& ~~~ 3L - if pAdditional.pstringType.theString = Unchecked.defaultof<_> - && (pAdditional.pstringType.Ordinal = uint16 CvtResFile.RT_DLGINCLUDE) then + if + pAdditional.pstringType.theString = Unchecked.defaultof<_> + && (pAdditional.pstringType.Ordinal = uint16 CvtResFile.RT_DLGINCLUDE) + then () (* ERROR ContinueNotSupported *) else resourceNames.Add pAdditional @@ -454,7 +456,8 @@ type VersionHelper() = doBreak <- false () (* ERROR ContinueNotSupported *) (* ERROR BreakNotSupported *) - if not breakLoop then i <- i + 1 + if not breakLoop then + i <- i + 1 if hasWildcard then let mutable (i: int) = lastExplicitValue @@ -1149,7 +1152,8 @@ type NativeResourceWriter() = if id >= 0 then writer.WriteInt32 id else - if name = Unchecked.defaultof<_> then name <- String.Empty + if name = Unchecked.defaultof<_> then + name <- String.Empty writer.WriteUInt32(nameOffset ||| 0x80000000u) dataWriter.WriteUInt16(uint16 name.Length) diff --git a/src/Compiler/AbstractIL/ilprint.fs b/src/Compiler/AbstractIL/ilprint.fs index a9f95cbc1b0..1c777f278b9 100644 --- a/src/Compiler/AbstractIL/ilprint.fs +++ b/src/Compiler/AbstractIL/ilprint.fs @@ -661,16 +661,20 @@ let goutput_fdef _tref env os (fd: ILFieldDef) = output_member_access os fd.Access output_string os " " - if fd.IsStatic then output_string os " static " + if fd.IsStatic then + output_string os " static " - if fd.IsLiteral then output_string os " literal " + if fd.IsLiteral then + output_string os " literal " if fd.IsSpecialName then output_string os " specialname rtspecialname " - if fd.IsInitOnly then output_string os " initonly " + if fd.IsInitOnly then + output_string os " initonly " - if fd.NotSerialized then output_string os " notserialized " + if fd.NotSerialized then + output_string os " notserialized " goutput_typ env os fd.FieldType output_string os " " @@ -740,7 +744,8 @@ let output_code_label os lab = output_string os (formatCodeLabel lab) let goutput_local env os (l: ILLocal) = goutput_typ env os l.Type - if l.IsPinned then output_string os " pinned" + if l.IsPinned then + output_string os " pinned" let goutput_param env os (l: ILParameter) = match l.Name with @@ -985,7 +990,8 @@ let rec goutput_instr env os inst = let rank = shape.Rank output_parens (output_array ", " (goutput_typ env)) os (Array.create rank PrimaryAssemblyILGlobals.typ_Int32) | I_ldelema (ro, _, shape, tok) -> - if ro = ReadonlyAddress then output_string os "readonly. " + if ro = ReadonlyAddress then + output_string os "readonly. " if shape = ILArrayShape.SingleDimensional then output_string os "ldelema " @@ -1034,7 +1040,8 @@ let rec goutput_instr env os inst = | _ -> output_string os "" let goutput_ilmbody env os (il: ILMethodBody) = - if il.IsZeroInit then output_string os " .zeroinit\n" + if il.IsZeroInit then + output_string os " .zeroinit\n" output_string os " .maxstack " output_i32 os il.MaxStack @@ -1067,7 +1074,8 @@ let goutput_mbody is_entrypoint env os (md: ILMethodDef) = | MethodBody.IL il -> goutput_ilmbody env os il.Value | _ -> () - if is_entrypoint then output_string os " .entrypoint" + if is_entrypoint then + output_string os " .entrypoint" output_string os "\n" output_string os "}\n" @@ -1125,11 +1133,14 @@ let goutput_mdef env os (md: ILMethodDef) = let menv = ppenv_enter_method (List.length md.GenericParams) env output_string os " .method " - if md.IsHideBySig then output_string os "hidebysig " + if md.IsHideBySig then + output_string os "hidebysig " - if md.IsReqSecObj then output_string os "reqsecobj " + if md.IsReqSecObj then + output_string os "reqsecobj " - if md.IsSpecialName then output_string os "specialname " + if md.IsSpecialName then + output_string os "specialname " if md.IsUnmanagedExport then output_string os "unmanagedexp " @@ -1149,13 +1160,17 @@ let goutput_mdef env os (md: ILMethodDef) = (goutput_params menv) os md.Parameters output_string os " " - if md.IsSynchronized then output_string os "synchronized " + if md.IsSynchronized then + output_string os "synchronized " - if md.IsMustRun then output_string os "/* mustrun */ " + if md.IsMustRun then + output_string os "/* mustrun */ " - if md.IsPreserveSig then output_string os "preservesig " + if md.IsPreserveSig then + output_string os "preservesig " - if md.IsNoInline then output_string os "noinlining " + if md.IsNoInline then + output_string os "noinlining " if md.IsAggressiveInline then output_string os "aggressiveinlining " @@ -1255,13 +1270,17 @@ let rec goutput_tdef enc env contents os (cd: ILTypeDef) = output_string os layout_attr output_string os " " - if cd.IsSealed then output_string os "sealed " + if cd.IsSealed then + output_string os "sealed " - if cd.IsAbstract then output_string os "abstract " + if cd.IsAbstract then + output_string os "abstract " - if cd.IsSerializable then output_string os "serializable " + if cd.IsSerializable then + output_string os "serializable " - if cd.IsComInterop then output_string os "import " + if cd.IsComInterop then + output_string os "import " output_sqstring os cd.Name goutput_gparams env os cd.GenericParams @@ -1339,7 +1358,8 @@ let output_assemblyRef os (aref: ILAssemblyRef) = output_string os " .assembly extern " output_sqstring os aref.Name - if aref.Retargetable then output_string os " retargetable " + if aref.Retargetable then + output_string os " retargetable " output_string os " { " output_option output_hash os aref.Hash diff --git a/src/Compiler/AbstractIL/ilread.fs b/src/Compiler/AbstractIL/ilread.fs index 3b536d891fd..6ec589b3115 100644 --- a/src/Compiler/AbstractIL/ilread.fs +++ b/src/Compiler/AbstractIL/ilread.fs @@ -1379,7 +1379,8 @@ let seekReadGuidIdx (ctxt: ILMetadataReader) mdv (addr: byref) = seekReadId let seekReadBlobIdx (ctxt: ILMetadataReader) mdv (addr: byref) = seekReadIdx ctxt.blobsBigness mdv &addr let seekReadModuleRow (ctxt: ILMetadataReader) mdv idx = - if idx = 0 then failwith "cannot read Module table row 0" + if idx = 0 then + failwith "cannot read Module table row 0" let mutable addr = ctxt.rowAddr TableNames.Module idx let generation = seekReadUInt16Adv mdv &addr @@ -1846,7 +1847,9 @@ let getDataEndPointsDelayed (pectxt: PEReader) ctxtH = |> List.sort let rvaToData (ctxt: ILMetadataReader) (pectxt: PEReader) nm rva = - if rva = 0x0 then failwith "rva is zero" + if rva = 0x0 then + failwith "rva is zero" + let start = pectxt.anyV2P (nm, rva) let endPoints = (Lazy.force ctxt.dataEndPoints) @@ -2565,7 +2568,8 @@ and sigptrGetTy (ctxt: ILMetadataReader) numTypars bytes sigptr = let ccByte, sigptr = sigptrGetByte bytes sigptr let generic, cc = byteAsCallConv ccByte - if generic then failwith "fptr sig may not be generic" + if generic then + failwith "fptr sig may not be generic" let struct (numparams, sigptr) = sigptrGetZInt32 bytes sigptr let retTy, sigptr = sigptrGetTy ctxt numTypars bytes sigptr @@ -3082,16 +3086,15 @@ and seekReadEvents (ctxt: ILMetadataReader) numTypars tidx = let mdv = ctxt.mdfile.GetView() match - seekReadOptionalIndexedRow - ( - ctxt.getNumRows TableNames.EventMap, - (fun i -> i, seekReadEventMapRow ctxt mdv i), - (fun (_, row) -> fst row), - compare tidx, - false, - (fun (i, row) -> (i, snd row)) - ) - with + seekReadOptionalIndexedRow ( + ctxt.getNumRows TableNames.EventMap, + (fun i -> i, seekReadEventMapRow ctxt mdv i), + (fun (_, row) -> fst row), + compare tidx, + false, + (fun (i, row) -> (i, snd row)) + ) + with | None -> [] | Some (rowNum, beginEventIdx) -> let endEventIdx = @@ -3150,16 +3153,15 @@ and seekReadProperties (ctxt: ILMetadataReader) numTypars tidx = let mdv = ctxt.mdfile.GetView() match - seekReadOptionalIndexedRow - ( - ctxt.getNumRows TableNames.PropertyMap, - (fun i -> i, seekReadPropertyMapRow ctxt mdv i), - (fun (_, row) -> fst row), - compare tidx, - false, - (fun (i, row) -> (i, snd row)) - ) - with + seekReadOptionalIndexedRow ( + ctxt.getNumRows TableNames.PropertyMap, + (fun i -> i, seekReadPropertyMapRow ctxt mdv i), + (fun (_, row) -> fst row), + compare tidx, + false, + (fun (i, row) -> (i, snd row)) + ) + with | None -> [] | Some (rowNum, beginPropIdx) -> let endPropIdx = @@ -3592,17 +3594,21 @@ and seekReadTopCode (ctxt: ILMetadataReader) pev mdv numTypars (sz: int) start s curr <- curr + 4 (* REVIEW: this incorrectly labels all MemberRef tokens as ILMethod's: we should go look at the MemberRef sig to determine if it is a field or method *) let token_info = - if tab = TableNames.Method - || tab = TableNames.MemberRef (* REVIEW: generics or tab = TableNames.MethodSpec *) then + if + tab = TableNames.Method + || tab = TableNames.MemberRef (* REVIEW: generics or tab = TableNames.MethodSpec *) + then let (MethodData (enclTy, cc, nm, argTys, retTy, methInst)) = seekReadMethodDefOrRefNoVarargs ctxt numTypars (uncodedTokenToMethodDefOrRef (tab, idx)) ILToken.ILMethod(mkILMethSpecInTy (enclTy, cc, nm, argTys, retTy, methInst)) elif tab = TableNames.Field then ILToken.ILField(seekReadFieldDefAsFieldSpec ctxt idx) - elif tab = TableNames.TypeDef - || tab = TableNames.TypeRef - || tab = TableNames.TypeSpec then + elif + tab = TableNames.TypeDef + || tab = TableNames.TypeRef + || tab = TableNames.TypeSpec + then ILToken.ILType(seekReadTypeDefOrRef ctxt numTypars AsObject [] (uncodedTokenToTypeDefOrRefOrSpec (tab, idx))) else failwith "bad token for ldtoken" @@ -3680,7 +3686,8 @@ and seekReadMethodRVA (pectxt: PEReader) (ctxt: ILMetadataReader) (idx, nm, _int let isFatFormat = (b &&& e_CorILMethod_FormatMask) = e_CorILMethod_FatFormat if not isTinyFormat && not isFatFormat then - if logging then failwith "unknown format" + if logging then + failwith "unknown format" MethodBody.Abstract else @@ -3924,7 +3931,8 @@ and seekReadMethodRVA (pectxt: PEReader) (ctxt: ILMetadataReader) (idx, nm, _int nextSectionBase <- sectionBase + sectionSize // Convert the linear code format to the nested code format - if logging then dprintn "doing localPdbInfos2" + if logging then + dprintn "doing localPdbInfos2" let localPdbInfos2 = List.map (fun f -> f raw2nextLab) localPdbInfos @@ -3933,7 +3941,8 @@ and seekReadMethodRVA (pectxt: PEReader) (ctxt: ILMetadataReader) (idx, nm, _int let code = buildILCode nm lab2pc instrs seh localPdbInfos2 - if logging then dprintn "done checking code." + if logging then + dprintn "done checking code." { IsZeroInit = initlocals @@ -4254,10 +4263,10 @@ let openMetadataReader | Some positions -> positions let tablesStreamPhysLoc, _tablesStreamSize = - match tryFindStream [| 0x23; 0x7e |] (* #~ *) with + match tryFindStream [| 0x23; 0x7e |] (* #~ *) with | Some res -> res | None -> - match tryFindStream [| 0x23; 0x2d |] (* #-: at least one DLL I've seen uses this! *) with + match tryFindStream [| 0x23; 0x2d |] (* #-: at least one DLL I've seen uses this! *) with | Some res -> res | None -> let firstStreamOffset = seekReadInt32 mdv (streamHeadersStart + 0) @@ -5073,8 +5082,10 @@ let stableFileHeuristicApplies fileName = let createByteFileChunk opts fileName chunk = // If we're trying to reduce memory usage then we are willing to go back and re-read the binary, so we can use // a weakly-held handle to an array of bytes. - if opts.reduceMemoryUsage = ReduceMemoryFlag.Yes - && stableFileHeuristicApplies fileName then + if + opts.reduceMemoryUsage = ReduceMemoryFlag.Yes + && stableFileHeuristicApplies fileName + then WeakByteFile(fileName, chunk) :> BinaryFile else let bytes = diff --git a/src/Compiler/AbstractIL/ilreflect.fs b/src/Compiler/AbstractIL/ilreflect.fs index 06e2fc67a35..2781d8a381a 100644 --- a/src/Compiler/AbstractIL/ilreflect.fs +++ b/src/Compiler/AbstractIL/ilreflect.fs @@ -638,11 +638,13 @@ let envUpdateCreatedTypeRef emEnv (tref: ILTypeRef) = // of objects. We use System.Runtime.Serialization.FormatterServices.GetUninitializedObject to do // the fake allocation - this creates an "empty" object, even if the object doesn't have // a constructor. It is not usable in partial trust code. - if runningOnMono - && ty.IsClass - && not ty.IsAbstract - && not ty.IsGenericType - && not ty.IsGenericTypeDefinition then + if + runningOnMono + && ty.IsClass + && not ty.IsAbstract + && not ty.IsGenericType + && not ty.IsGenericTypeDefinition + then try System.Runtime.Serialization.FormatterServices.GetUninitializedObject ty |> ignore @@ -972,7 +974,9 @@ let convFieldSpec cenv emEnv fspec = nonQueryableTypeGetField parentTI fieldB else // Prior type. - if typeIsNotQueryable parentTI then + if + typeIsNotQueryable parentTI + then let parentT = getTypeConstructor parentTI let fieldInfo = queryableTypeGetField emEnv parentT fref nonQueryableTypeGetField parentTI fieldInfo @@ -1009,10 +1013,12 @@ let queryableTypeGetMethodBySearch cenv emEnv parentT (mref: ILMethodRef) = | Some a -> if // obvious case - p.IsAssignableFrom a then + p.IsAssignableFrom a + then true elif - p.IsGenericType && a.IsGenericType + p.IsGenericType + && a.IsGenericType // non obvious due to contravariance: Action where T: IFoo accepts Action (for FooImpl: IFoo) && p.GetGenericTypeDefinition().IsAssignableFrom(a.GetGenericTypeDefinition()) then @@ -1124,8 +1130,10 @@ let queryableTypeGetMethod cenv emEnv parentT (mref: ILMethodRef) : MethodInfo = queryableTypeGetMethodBySearch cenv emEnv parentT mref let nonQueryableTypeGetMethod (parentTI: Type) (methInfo: MethodInfo) : MethodInfo MaybeNull = - if (parentTI.IsGenericType - && not (equalTypes parentTI (getTypeConstructor parentTI))) then + if + (parentTI.IsGenericType + && not (equalTypes parentTI (getTypeConstructor parentTI))) + then TypeBuilder.GetMethod(parentTI, methInfo) else methInfo @@ -1141,7 +1149,9 @@ let convMethodRef cenv emEnv (parentTI: Type) (mref: ILMethodRef) = nonQueryableTypeGetMethod parentTI methB else // Prior type. - if typeIsNotQueryable parentTI then + if + typeIsNotQueryable parentTI + then let parentT = getTypeConstructor parentTI let methInfo = queryableTypeGetMethod cenv emEnv parentT mref nonQueryableTypeGetMethod parentTI methInfo @@ -1216,7 +1226,9 @@ let convConstructorSpec cenv emEnv (mspec: ILMethodSpec) = nonQueryableTypeGetConstructor parentTI consB else // Prior type. - if typeIsNotQueryable parentTI then + if + typeIsNotQueryable parentTI + then let parentT = getTypeConstructor parentTI let ctorG = queryableTypeGetConstructor cenv emEnv parentT mref nonQueryableTypeGetConstructor parentTI ctorG @@ -2134,9 +2146,11 @@ let buildFieldPass2 cenv tref (typB: TypeBuilder) emEnv (fdef: ILFieldDef) = match fdef.LiteralValue with | None -> emEnv | Some initial -> - if not fieldT.IsEnum - // it is ok to init fields with type = enum that are defined in other assemblies - || not fieldT.Assembly.IsDynamic then + if + not fieldT.IsEnum + // it is ok to init fields with type = enum that are defined in other assemblies + || not fieldT.Assembly.IsDynamic + then fieldB.SetConstant(initial.AsObject()) emEnv else @@ -2267,9 +2281,10 @@ let typeAttributesOfTypeLayout cenv emEnv x = if p.Size = None && p.Pack = None then None else - match cenv.tryFindSysILTypeRef "System.Runtime.InteropServices.StructLayoutAttribute", - cenv.tryFindSysILTypeRef "System.Runtime.InteropServices.LayoutKind" - with + match + cenv.tryFindSysILTypeRef "System.Runtime.InteropServices.StructLayoutAttribute", + cenv.tryFindSysILTypeRef "System.Runtime.InteropServices.LayoutKind" + with | Some tref1, Some tref2 -> Some( convCustomAttr @@ -2564,7 +2579,8 @@ let createTypeRef (visited: Dictionary<_, _>, created: Dictionary<_, _>) emEnv t match emEnv.emTypMap.TryFind typeRef with | Some (_, tb, _, _) -> - if not (tb.IsCreated()) then tb.CreateTypeAndLog() |> ignore + if not (tb.IsCreated()) then + tb.CreateTypeAndLog() |> ignore tb.Assembly | None -> null) @@ -2590,7 +2606,8 @@ let createTypeRef (visited: Dictionary<_, _>, created: Dictionary<_, _>) emEnv t traverseTypeRef tref let rec buildTypeDefPass4 (visited, created) nesting emEnv (tdef: ILTypeDef) = - if verbose2 then dprintf "buildTypeDefPass4 %s\n" tdef.Name + if verbose2 then + dprintf "buildTypeDefPass4 %s\n" tdef.Name let tref = mkRefForNestedILTypeDef ILScopeRef.Local (nesting, tdef) createTypeRef (visited, created) emEnv tref diff --git a/src/Compiler/AbstractIL/ilsupp.fs b/src/Compiler/AbstractIL/ilsupp.fs index 1db894b1801..fea9a764487 100644 --- a/src/Compiler/AbstractIL/ilsupp.fs +++ b/src/Compiler/AbstractIL/ilsupp.fs @@ -611,7 +611,8 @@ type ResFormatNode(tid: int32, nid: int32, lid: int32, dataOffset: int32, pbLink let bNil = Bytes.zeroCreate 3 // Align remaining fields on DWORD (nb. poor bit twiddling code taken from ildasm's dres.cpp) - if (dwFiller &&& 0x1) <> 0 then SaveChunk(bNil, 2) + if (dwFiller &&& 0x1) <> 0 then + SaveChunk(bNil, 2) //---- Constant part of the header: DWORD, WORD, WORD, DWORD, DWORD SaveChunk(dwToBytes resHdr.DataVersion) @@ -627,7 +628,8 @@ type ResFormatNode(tid: int32, nid: int32, lid: int32, dataOffset: int32, pbLink dwFiller <- dataEntry.Size &&& 0x3 - if dwFiller <> 0 then SaveChunk(bNil, 4 - dwFiller) + if dwFiller <> 0 then + SaveChunk(bNil, 4 - dwFiller) size diff --git a/src/Compiler/AbstractIL/ilsupp.fsi b/src/Compiler/AbstractIL/ilsupp.fsi index a7b9ddefcfe..e0aa2785471 100644 --- a/src/Compiler/AbstractIL/ilsupp.fsi +++ b/src/Compiler/AbstractIL/ilsupp.fsi @@ -48,14 +48,14 @@ type PdbDebugPoint = pdbSeqPointEndLine: int pdbSeqPointEndColumn: int } -val pdbReadOpen: string (* module *) -> string (* path *) -> PdbReader +val pdbReadOpen: string (* module *) -> string (* path *) -> PdbReader val pdbReadClose: PdbReader -> unit -val pdbReaderGetMethod: PdbReader -> int32 (* token *) -> PdbMethod -val pdbReaderGetMethodFromDocumentPosition: PdbReader -> PdbDocument -> int (* line *) -> int (* col *) -> PdbMethod +val pdbReaderGetMethod: PdbReader -> int32 (* token *) -> PdbMethod +val pdbReaderGetMethodFromDocumentPosition: PdbReader -> PdbDocument -> int (* line *) -> int (* col *) -> PdbMethod val pdbReaderGetDocuments: PdbReader -> PdbDocument array val pdbReaderGetDocument: - PdbReader -> string (* url *) -> byte (* guid *) [] -> byte (* guid *) [] -> byte (* guid *) [] -> PdbDocument + PdbReader -> string (* url *) -> byte (* guid *) [] -> byte (* guid *) [] -> byte (* guid *) [] -> PdbDocument val pdbDocumentGetURL: PdbDocument -> string val pdbDocumentGetType: PdbDocument -> byte (* guid *) [] @@ -72,7 +72,7 @@ val pdbScopeGetLocals: PdbMethodScope -> PdbVariable array val pdbVariableGetName: PdbVariable -> string val pdbVariableGetSignature: PdbVariable -> byte[] -val pdbVariableGetAddressAttributes: PdbVariable -> int32 (* kind *) * int32 (* addrField1 *) +val pdbVariableGetAddressAttributes: PdbVariable -> int32 (* kind *) * int32 (* addrField1 *) #endif #if !FX_NO_PDB_WRITER @@ -89,7 +89,7 @@ type idd = iddType: int32 iddData: byte[] } -val pdbInitialize: string (* .exe/.dll already written and closed *) -> string (* .pdb to write *) -> PdbWriter +val pdbInitialize: string (* .exe/.dll already written and closed *) -> string (* .pdb to write *) -> PdbWriter val pdbClose: PdbWriter -> string -> string -> unit val pdbCloseDocument: PdbDocumentWriter -> unit val pdbSetUserEntryPoint: PdbWriter -> int32 -> unit diff --git a/src/Compiler/AbstractIL/ilwritepdb.fs b/src/Compiler/AbstractIL/ilwritepdb.fs index c81cfc23ad3..55b23795bbc 100644 --- a/src/Compiler/AbstractIL/ilwritepdb.fs +++ b/src/Compiler/AbstractIL/ilwritepdb.fs @@ -751,10 +751,12 @@ type PortablePdbGenerator builder.WriteCompressedInteger offsetDelta // Check for hidden-sequence-point-record - if startLine = 0xfeefee - || endLine = 0xfeefee - || (startColumn = 0 && endColumn = 0) - || ((endLine - startLine) = 0 && (endColumn - startColumn) = 0) then + if + startLine = 0xfeefee + || endLine = 0xfeefee + || (startColumn = 0 && endColumn = 0) + || ((endLine - startLine) = 0 && (endColumn - startColumn) = 0) + then // Hidden-sequence-point-record builder.WriteCompressedInteger 0 builder.WriteCompressedInteger 0 @@ -1008,14 +1010,16 @@ let writePdbInfo showTimes outfile pdbfile info cvChunk = | Some p -> sco.StartOffset <> p.StartOffset || sco.EndOffset <> p.EndOffset | None -> true - if nested then pdbOpenScope pdbw sco.StartOffset + if nested then + pdbOpenScope pdbw sco.StartOffset sco.Locals |> Array.iter (fun v -> pdbDefineLocalVariable pdbw v.Name v.Signature v.Index) sco.Children |> Array.iter (writePdbScope (if nested then Some sco else parent)) - if nested then pdbCloseScope pdbw sco.EndOffset) + if nested then + pdbCloseScope pdbw sco.EndOffset) match minfo.RootScope with | None -> () @@ -1242,8 +1246,10 @@ and allNamesOfScopes acc (scopes: PdbMethodScope[]) = let rec pushShadowedLocals (stackGuard: StackGuard) (localsToPush: PdbLocalVar[]) (scope: PdbMethodScope) = stackGuard.Guard(fun () -> // Check if child scopes are properly nested - if scope.Children - |> Array.forall (fun child -> child.StartOffset >= scope.StartOffset && child.EndOffset <= scope.EndOffset) then + if + scope.Children + |> Array.forall (fun child -> child.StartOffset >= scope.StartOffset && child.EndOffset <= scope.EndOffset) + then let children = scope.Children |> Array.sortWith scopeSorter diff --git a/src/Compiler/AbstractIL/ilx.fs b/src/Compiler/AbstractIL/ilx.fs index 6a7adab880b..4eb18649752 100644 --- a/src/Compiler/AbstractIL/ilx.fs +++ b/src/Compiler/AbstractIL/ilx.fs @@ -39,7 +39,7 @@ type IlxUnionHasHelpers = | SpecialFSharpListHelpers | SpecialFSharpOptionHelpers -type IlxUnionRef = IlxUnionRef of boxity: ILBoxity * ILTypeRef * IlxUnionCase[] * bool (* hasHelpers: *) * IlxUnionHasHelpers +type IlxUnionRef = IlxUnionRef of boxity: ILBoxity * ILTypeRef * IlxUnionCase[] * bool (* hasHelpers: *) * IlxUnionHasHelpers type IlxUnionSpec = | IlxUnionSpec of IlxUnionRef * ILGenericArgs diff --git a/src/Compiler/AbstractIL/ilx.fsi b/src/Compiler/AbstractIL/ilx.fsi index 901117867b7..a6a008434be 100644 --- a/src/Compiler/AbstractIL/ilx.fsi +++ b/src/Compiler/AbstractIL/ilx.fsi @@ -39,7 +39,7 @@ type IlxUnionRef = boxity: ILBoxity * ILTypeRef * IlxUnionCase[] * - bool (* IsNullPermitted *) * + bool (* IsNullPermitted *) * IlxUnionHasHelpers (* HasHelpers *) type IlxUnionSpec = diff --git a/src/Compiler/CodeGen/EraseClosures.fs b/src/Compiler/CodeGen/EraseClosures.fs index 6f6646177a5..5ba6c4b50a0 100644 --- a/src/Compiler/CodeGen/EraseClosures.fs +++ b/src/Compiler/CodeGen/EraseClosures.fs @@ -500,9 +500,11 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo = // nb. should combine the term and type abstraction cases for // to allow for term and type variables to be mixed in a single // application. - if (match laterStruct with - | Lambdas_return _ -> false - | _ -> true) then + if + (match laterStruct with + | Lambdas_return _ -> false + | _ -> true) + then let nowStruct = List.foldBack (fun x y -> Lambdas_forall(x, y)) tyargsl (Lambdas_return nowReturnTy) @@ -622,9 +624,11 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo = let nowReturnTy = mkTyOfLambdas cenv laterStruct // CASE 2a - Too Many Term Arguments or Remaining Type arguments - Split the Closure Class in Two - if (match laterStruct with - | Lambdas_return _ -> false - | _ -> true) then + if + (match laterStruct with + | Lambdas_return _ -> false + | _ -> true) + then let nowStruct = List.foldBack (fun l r -> Lambdas_lambda(l, r)) nowParams (Lambdas_return nowReturnTy) diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index 1e4b3c1f591..626ddd49758 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -76,7 +76,8 @@ type UnionReprDecisions<'Union, 'Alt, 'Type> if alts.Length = 1 then SingleCase elif - not (isStruct cu) && alts.Length < TaggingThresholdFixedConstant + not (isStruct cu) + && alts.Length < TaggingThresholdFixedConstant && not (repr.RepresentAllAlternativesAsConstantFieldsInRootClass cu) then RuntimeTypes @@ -1280,12 +1281,14 @@ let mkClassUnionDef ] let ctorMeths = - if (List.isEmpty selfFields - && List.isEmpty tagFieldsInObject - && not (List.isEmpty selfMeths)) - || isStruct - || cud.UnionCases - |> Array.forall (fun alt -> repr.RepresentAlternativeAsFreshInstancesOfRootClass(info, alt)) then + if + (List.isEmpty selfFields + && List.isEmpty tagFieldsInObject + && not (List.isEmpty selfMeths)) + || isStruct + || cud.UnionCases + |> Array.forall (fun alt -> repr.RepresentAlternativeAsFreshInstancesOfRootClass(info, alt)) + then [] (* no need for a second ctor in these cases *) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 1bf87805a0b..c39508fc595 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -210,7 +210,11 @@ let ReportStatistics (oc: TextWriter) = reports oc let NewCounter nm = let mutable count = 0 - AddReport(fun oc -> if count <> 0 then oc.WriteLine(string count + " " + nm)) + + AddReport(fun oc -> + if count <> 0 then + oc.WriteLine(string count + " " + nm)) + (fun () -> count <- count + 1) let CountClosure = NewCounter "closures" @@ -653,9 +657,11 @@ and GenNamedTyAppAux (cenv: cenv) m (tyenv: TypeReprEnv) ptrsOK tcref tinst = | _ -> let tinst = DropErasedTyargs tinst // See above note on ptrsOK - if ptrsOK = PtrTypesOK - && tyconRefEq g tcref g.nativeptr_tcr - && (freeInTypes CollectTypars tinst).FreeTypars.IsEmpty then + if + ptrsOK = PtrTypesOK + && tyconRefEq g tcref g.nativeptr_tcr + && (freeInTypes CollectTypars tinst).FreeTypars.IsEmpty + then GenNamedTyAppAux cenv m tyenv ptrsOK g.ilsigptr_tcr tinst else #if !NO_TYPEPROVIDERS @@ -1910,7 +1916,8 @@ type TypeDefBuilder(tdef: ILTypeDef, tdefDiscards) = | Some (mdefDiscard, _) -> mdefDiscard ilMethodDef | None -> false - if not discard then gmethods.Add ilMethodDef + if not discard then + gmethods.Add ilMethodDef member _.NestedTypeDefs = gnested @@ -1924,7 +1931,8 @@ type TypeDefBuilder(tdef: ILTypeDef, tdefDiscards) = | Some (_, pdefDiscard) -> pdefDiscard pdef | None -> false - if not discard then AddPropertyDefToHash m gproperties pdef + if not discard then + AddPropertyDefToHash m gproperties pdef member _.PrependInstructionsToSpecificMethodDef(cond, instrs, tag, imports) = match ResizeArray.tryFindIndex cond gmethods with @@ -2138,7 +2146,8 @@ type AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbu lmtyp ) - if isStruct then tycon.SetIsStructRecordOrUnion true + if isStruct then + tycon.SetIsStructRecordOrUnion true tycon.entity_tycon_repr <- TFSharpRecdRepr( @@ -2470,10 +2479,12 @@ type CodeGenBuffer(m: range, mgbuf: AssemblyBuilder, methodName, alreadyUsedArgs member private _.EnsureNopBetweenDebugPoints() = // Always add a nop between debug points to help .NET get the stepping right // Don't do this after a FeeFee marker for hidden code - if (codebuf.Count > 0 - && (match codebuf[codebuf.Count - 1] with - | I_seqpoint sm when sm.Line <> FeeFee mgbuf.cenv -> true - | _ -> false)) then + if + (codebuf.Count > 0 + && (match codebuf[codebuf.Count - 1] with + | I_seqpoint sm when sm.Line <> FeeFee mgbuf.cenv -> true + | _ -> false)) + then codebuf.Add(AI_nop) @@ -2599,11 +2610,13 @@ type CodeGenBuffer(m: range, mgbuf: AssemblyBuilder, methodName, alreadyUsedArgs let instrs = instrs |> Array.mapi (fun idx i2 -> - if idx = 0 - && (match i2 with - | AI_nop -> true - | _ -> false) - && anyDocument.IsSome then + if + idx = 0 + && (match i2 with + | AI_nop -> true + | _ -> false) + && anyDocument.IsSome + then // This special dummy debug point says skip the start of the method hasDebugPoints <- true FeeFeeInstr mgbuf.cenv anyDocument.Value @@ -2842,7 +2855,8 @@ and GenExprPreSteps (cenv: cenv) (cgbuf: CodeGenBuffer) eenv expr sequel = let others = [ for k in cenv.namedDebugPointsForInlinedCode.Keys do - if Range.equals m k.Range then yield k.Name + if Range.equals m k.Range then + yield k.Name ] |> String.concat "," @@ -3553,9 +3567,11 @@ and GenNewArray cenv cgbuf eenv (elems: Expr list, elemTy, m) sequel = // InitializeArray is a JIT intrinsic that will result in invalid runtime CodeGen when initializing an array // of enum types. Until bug 872799 is fixed, we'll need to generate arrays the "simple" way for enum types // Also note - C# never uses InitializeArray for enum types, so this change puts us on equal footing with them. - if elems.Length <= 5 - || not cenv.options.emitConstantArraysUsingStaticDataBlobs - || (isEnumTy cenv.g elemTy) then + if + elems.Length <= 5 + || not cenv.options.emitConstantArraysUsingStaticDataBlobs + || (isEnumTy cenv.g elemTy) + then GenNewArraySimple cenv cgbuf eenv (elems, elemTy, m) sequel else // Try to emit a constant byte-blob array @@ -3648,10 +3664,12 @@ and GenNewArray cenv cgbuf eenv (elems: Expr list, elemTy, m) sequel = | _ -> false), (fun _ _ -> failwith "unreachable") - if elemsArray - |> Array.forall (function - | Expr.Const (c, _, _) -> test c - | _ -> false) then + if + elemsArray + |> Array.forall (function + | Expr.Const (c, _, _) -> test c + | _ -> false) + then let ilElemTy = GenType cenv m eenv.tyenv elemTy GenConstArray cenv cgbuf eenv ilElemTy elemsArray (fun buf -> @@ -3667,10 +3685,12 @@ and GenNewArray cenv cgbuf eenv (elems: Expr list, elemTy, m) sequel = and GenCoerce cenv cgbuf eenv (e, tgty, m, srcty) sequel = let g = cenv.g // Is this an upcast? - if TypeDefinitelySubsumesTypeNoCoercion 0 g cenv.amap m tgty srcty - && - // Do an extra check - should not be needed - TypeFeasiblySubsumesType 0 g cenv.amap m tgty NoCoerce srcty then + if + TypeDefinitelySubsumesTypeNoCoercion 0 g cenv.amap m tgty srcty + && + // Do an extra check - should not be needed + TypeFeasiblySubsumesType 0 g cenv.amap m tgty NoCoerce srcty + then if isInterfaceTy g tgty then GenExpr cenv cgbuf eenv e Continue let ilToTy = GenType cenv m eenv.tyenv tgty @@ -3838,8 +3858,10 @@ and GenFieldGet isStatic cenv cgbuf eenv (rfref: RecdFieldRef, tyargs, m) = let fspec = GenRecdFieldRef m cenv eenv.tyenv rfref tyargs let vol = if rfref.RecdField.IsVolatile then Volatile else Nonvolatile - if useGenuineField rfref.Tycon rfref.RecdField - || entityRefInThisAssembly cenv.g.compilingFSharpCore rfref.TyconRef then + if + useGenuineField rfref.Tycon rfref.RecdField + || entityRefInThisAssembly cenv.g.compilingFSharpCore rfref.TyconRef + then let instr = if isStatic then I_ldsfld(vol, fspec) @@ -4306,9 +4328,11 @@ and GenApp (cenv: cenv) cgbuf eenv (f, fty, tyargs, curriedArgs, m) sequel = // When generating debug code, generate a 'nop' after a 'call' that returns 'void' // This is what C# does, as it allows the call location to be maintained correctly in the stack frame - if cenv.options.generateDebugSymbols - && mustGenerateUnitAfterCall - && (isTailCall = Normalcall) then + if + cenv.options.generateDebugSymbols + && mustGenerateUnitAfterCall + && (isTailCall = Normalcall) + then CG.EmitInstr cgbuf (pop 0) Push0 AI_nop if isNil laterArgs then @@ -4352,22 +4376,24 @@ and CanTailcall // Can't tailcall with a struct object arg since it involves a byref // Can't tailcall with a .NET 2.0 generic constrained call since it involves a byref - if not hasStructObjArg - && Option.isNone ccallInfo - && not withinSEH - && not hasByrefArg - && not isDllImport - && not isSelfInit - && not makesNoCriticalTailcalls - && - - // We can tailcall even if we need to generate "unit", as long as we're about to throw the value away anyway as par of the return. - // We can tailcall if we don't need to generate "unit", as long as we're about to return. - (match sequelIgnoreEndScopes sequel with - | ReturnVoid - | Return -> not mustGenerateUnitAfterCall - | DiscardThen ReturnVoid -> mustGenerateUnitAfterCall - | _ -> false) then + if + not hasStructObjArg + && Option.isNone ccallInfo + && not withinSEH + && not hasByrefArg + && not isDllImport + && not isSelfInit + && not makesNoCriticalTailcalls + && + + // We can tailcall even if we need to generate "unit", as long as we're about to throw the value away anyway as par of the return. + // We can tailcall if we don't need to generate "unit", as long as we're about to return. + (match sequelIgnoreEndScopes sequel with + | ReturnVoid + | Return -> not mustGenerateUnitAfterCall + | DiscardThen ReturnVoid -> mustGenerateUnitAfterCall + | _ -> false) + then Tailcall else Normalcall @@ -5562,9 +5588,11 @@ and GenGenericParam cenv eenv (tp: Typar) = | _ -> if nm.TrimEnd([| '0' .. '9' |]).Length = 1 then nm - elif nm.Length >= 1 - && nm[0] = 'T' - && (nm.Length = 1 || not (System.Char.IsLower nm[1])) then + elif + nm.Length >= 1 + && nm[0] = 'T' + && (nm.Length = 1 || not (System.Char.IsLower nm[1])) + then nm else "T" + (String.capitalize nm) @@ -5874,14 +5902,13 @@ and GenStructStateMachine cenv cgbuf eenvouter (res: LoweredStateMachine) sequel let finfo = match - infoReader.GetRecordOrClassFieldsOfType - ( - Some fieldName, - AccessibilityLogic.AccessorDomain.AccessibleFromSomewhere, - m, - templateStructTy - ) - with + infoReader.GetRecordOrClassFieldsOfType( + Some fieldName, + AccessibilityLogic.AccessorDomain.AccessibleFromSomewhere, + m, + templateStructTy + ) + with | [ finfo ] -> finfo | _ -> error (InternalError(sprintf "expected class field %s not found" fieldName, m)) @@ -5894,14 +5921,13 @@ and GenStructStateMachine cenv cgbuf eenvouter (res: LoweredStateMachine) sequel let finfo = match - infoReader.GetRecordOrClassFieldsOfType - ( - Some fieldName, - AccessibilityLogic.AccessorDomain.AccessibleFromSomewhere, - m, - templateStructTy - ) - with + infoReader.GetRecordOrClassFieldsOfType( + Some fieldName, + AccessibilityLogic.AccessorDomain.AccessibleFromSomewhere, + m, + templateStructTy + ) + with | [ finfo ] -> finfo | _ -> error (InternalError(sprintf "expected class field %s not found" fieldName, m)) @@ -5939,7 +5965,7 @@ and GenStructStateMachine cenv cgbuf eenvouter (res: LoweredStateMachine) sequel AccessibilityLogic.AccessorDomain.AccessibleFromSomewhere imethName interfaceTy - with + with | [ meth ] when meth.IsInstance -> meth | _ -> error (InternalError(sprintf "expected method %s not found" imethName, m)) @@ -5989,7 +6015,7 @@ and GenStructStateMachine cenv cgbuf eenvouter (res: LoweredStateMachine) sequel AccessibilityLogic.AccessorDomain.AccessibleFromSomewhere imethName interfaceTy - with + with | [ meth ] when meth.IsInstance -> meth | _ -> error (InternalError(sprintf "expected method %s not found" imethName, m)) @@ -8093,9 +8119,11 @@ and GenBindingAfterDebugPoint cenv cgbuf eenv bind isStateVar startMarkOpt = // Workaround for .NET and Visual Studio restriction w.r.t debugger type proxys // Mark internal constructors in internal classes as public. let access = - if access = ILMemberAccess.Assembly - && vspec.IsConstructor - && IsHiddenTycon eenv.sigToImplRemapInfo vspec.MemberApparentEntity.Deref then + if + access = ILMemberAccess.Assembly + && vspec.IsConstructor + && IsHiddenTycon eenv.sigToImplRemapInfo vspec.MemberApparentEntity.Deref + then ILMemberAccess.Public else access @@ -8488,8 +8516,10 @@ and GenMarshal cenv attribs = match decoder.FindTypeName "SafeArrayUserDefinedSubType" "" with | "" -> None | res -> - if (safeArraySubType = ILNativeVariant.IDispatch) - || (safeArraySubType = ILNativeVariant.IUnknown) then + if + (safeArraySubType = ILNativeVariant.IDispatch) + || (safeArraySubType = ILNativeVariant.IUnknown) + then Some res else None @@ -8856,8 +8886,10 @@ and GenMethodForBinding |> AddStorageForLocalVals cenv.g (List.mapi (fun i v -> (v, Arg(numArgsUsed + i))) nonUnitNonSelfMethodVars) let eenvForMeth = - if eenvForMeth.initLocals - && HasFSharpAttribute g g.attrib_SkipLocalsInitAttribute v.Attribs then + if + eenvForMeth.initLocals + && HasFSharpAttribute g g.attrib_SkipLocalsInitAttribute v.Attribs + then { eenvForMeth with initLocals = false } else eenvForMeth @@ -8905,8 +8937,10 @@ and GenMethodForBinding let attr = TryFindFSharpBoolAttributeAssumeFalse cenv.g cenv.g.attrib_NoDynamicInvocationAttribute v.Attribs - if (not generateWitnessArgs && attr.IsSome) - || (generateWitnessArgs && attr = Some false) then + if + (not generateWitnessArgs && attr.IsSome) + || (generateWitnessArgs && attr = Some false) + then let exnArg = mkString cenv.g m (FSComp.SR.ilDynamicInvocationNotSupported (v.CompiledName g.CompilerGlobalState)) @@ -8939,7 +8973,7 @@ and GenMethodForBinding match v.Attribs |> List.tryFind (IsMatchingFSharpAttribute g g.attrib_CompiledNameAttribute) - with + with | Some (Attrib (_, _, [ AttribStringArg b ], _, _, _, _)) -> [ mkCompilationSourceNameAttr g v.LogicalName ], Some b | _ -> [], None @@ -9010,9 +9044,11 @@ and GenMethodForBinding -> let useMethodImpl = - if compileAsInstance - && ((memberInfo.MemberFlags.IsDispatchSlot && memberInfo.IsImplemented) - || memberInfo.MemberFlags.IsOverrideOrExplicitImpl) then + if + compileAsInstance + && ((memberInfo.MemberFlags.IsDispatchSlot && memberInfo.IsImplemented) + || memberInfo.MemberFlags.IsOverrideOrExplicitImpl) + then let useMethodImpl = ComputeUseMethodImpl cenv.g v @@ -9068,8 +9104,10 @@ and GenMethodForBinding if not compileAsInstance then mkILStaticMethod (ilMethTypars, mspec.Name, access, ilParams, ilReturn, ilMethodBody) - elif (memberInfo.MemberFlags.IsDispatchSlot && memberInfo.IsImplemented) - || memberInfo.MemberFlags.IsOverrideOrExplicitImpl then + elif + (memberInfo.MemberFlags.IsDispatchSlot && memberInfo.IsImplemented) + || memberInfo.MemberFlags.IsOverrideOrExplicitImpl + then let flagFixups = ComputeFlagFixupsForMemberBinding cenv v @@ -9197,7 +9235,8 @@ and GenMethodForBinding mdef.Name.StartsWithOrdinal("|") || // event add/remove method - v.val_flags.IsGeneratedEventVal then + v.val_flags.IsGeneratedEventVal + then mdef.WithSpecialName else mdef @@ -9763,7 +9802,8 @@ and GenTypeDefForCompLoc (cenv, eenv, mgbuf: AssemblyBuilder, cloc, hidden, attr TypeNameForImplicitMainMethod cloc TypeNameForInitClass cloc TypeNameForPrivateImplementationDetails cloc - ] then + ] + then [] else [ mkCompilationMappingAttr g (int SourceConstructFlags.Module) ]) @@ -9899,10 +9939,12 @@ and GenModuleBinding cenv (cgbuf: CodeGenBuffer) (qname: QualifiedNameOfFile) la // If the module has a .cctor for some mutable fields, we need to ensure that when // those fields are "touched" the InitClass .cctor is forced. The InitClass .cctor will // then fill in the value of the mutable fields. - if not mspec.IsNamespace - && (cgbuf.mgbuf.GetCurrentFields(TypeRefForCompLoc eenvinner.cloc) - |> Seq.isEmpty - |> not) then + if + not mspec.IsNamespace + && (cgbuf.mgbuf.GetCurrentFields(TypeRefForCompLoc eenvinner.cloc) + |> Seq.isEmpty + |> not) + then GenForceWholeFileInitializationAsPartOfCCtor cenv cgbuf.mgbuf @@ -10386,11 +10428,13 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = // HOWEVER, if the type doesn't override Object.Equals already. let augmentOverrideMethodDefs = - (if Option.isNone tycon.GeneratedCompareToValues - && Option.isNone tycon.GeneratedHashAndEqualsValues - && tycon.HasInterface g g.mk_IComparable_ty - && not (tycon.HasOverride g "Equals" [ g.obj_ty ]) - && not tycon.IsFSharpInterfaceTycon then + (if + Option.isNone tycon.GeneratedCompareToValues + && Option.isNone tycon.GeneratedHashAndEqualsValues + && tycon.HasInterface g g.mk_IComparable_ty + && not (tycon.HasOverride g "Equals" [ g.obj_ty ]) + && not tycon.IsFSharpInterfaceTycon + then [ GenEqualsOverrideCallingIComparable cenv (tcref, ilThisTy, ilThisTy) ] else []) @@ -10602,7 +10646,8 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = [ // If using a field then all the attributes go on the field // See also FSharp 1.0 Bug 4727: once we start compiling them as real mutable fields, you should not be able to target both "property" for "val mutable" fields in classes - if useGenuineField then yield! fspec.PropertyAttribs + if useGenuineField then + yield! fspec.PropertyAttribs yield! fspec.FieldAttribs ] @@ -10866,9 +10911,11 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = // FSharp 1.0 bug 1988: Explicitly setting the ComVisible(true) attribute on an F# type causes an F# record to be emitted in a way that enables mutation for COM interop scenarios // FSharp 3.0 feature: adding CLIMutable to a record type causes emit of default constructor, and all fields get property setters // Records that are value types do not create a default constructor with CLIMutable or ComVisible - if not isStructRecord - && (isCLIMutable - || (TryFindFSharpBoolAttribute g g.attrib_ComVisibleAttribute tycon.Attribs = Some true)) then + if + not isStructRecord + && (isCLIMutable + || (TryFindFSharpBoolAttribute g g.attrib_ComVisibleAttribute tycon.Attribs = Some true)) + then yield mkILSimpleStorageCtor (Some g.ilg.typ_Object.TypeSpec, ilThisTy, [], [], reprAccess, None, eenv.imports) if not (tycon.HasMember g "ToString" []) then @@ -11034,11 +11081,13 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = // All structs are sequential by default // Structs with no instance fields get size 1, pack 0 - if tycon.AllFieldsArray |> Array.exists (fun f -> not f.IsStatic) - || - // Reflection emit doesn't let us emit 'pack' and 'size' for generic structs. - // In that case we generate a dummy field instead - (cenv.options.workAroundReflectionEmitBugs && not tycon.TyparsNoRange.IsEmpty) then + if + tycon.AllFieldsArray |> Array.exists (fun f -> not f.IsStatic) + || + // Reflection emit doesn't let us emit 'pack' and 'size' for generic structs. + // In that case we generate a dummy field instead + (cenv.options.workAroundReflectionEmitBugs && not tycon.TyparsNoRange.IsEmpty) + then ILTypeDefLayout.Sequential { Size = None; Pack = None }, ILDefaultPInvokeEncoding.Ansi else ILTypeDefLayout.Sequential { Size = Some 1; Pack = Some 0us }, ILDefaultPInvokeEncoding.Ansi @@ -11103,9 +11152,11 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = let layout = if isStructTy g thisTy then - if (match ilTypeDefKind with - | ILTypeDefKind.ValueType -> true - | _ -> false) then + if + (match ilTypeDefKind with + | ILTypeDefKind.ValueType -> true + | _ -> false) + then // Structs with no instance fields get size 1, pack 0 ILTypeDefLayout.Sequential { Size = Some 1; Pack = Some 0us } else @@ -11206,9 +11257,11 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = // order in the sequential initialization of the file. // // In this case, the .cctor for this type must force the .cctor of the backing static class for the file. - if tycon.TyparsNoRange.IsEmpty - && tycon.MembersOfFSharpTyconSorted - |> List.exists (fun vref -> vref.Deref.IsClassConstructor) then + if + tycon.TyparsNoRange.IsEmpty + && tycon.MembersOfFSharpTyconSorted + |> List.exists (fun vref -> vref.Deref.IsClassConstructor) + then GenForceWholeFileInitializationAsPartOfCCtor cenv mgbuf lazyInitInfo tref eenv.imports m /// Generate the type for an F# exception declaration. diff --git a/src/Compiler/Driver/CompilerConfig.fs b/src/Compiler/Driver/CompilerConfig.fs index b1bca1b6092..2786e30e9a3 100644 --- a/src/Compiler/Driver/CompilerConfig.fs +++ b/src/Compiler/Driver/CompilerConfig.fs @@ -859,7 +859,8 @@ type TcConfigBuilder = | None -> () | Some n -> // nowarn:62 turns on mlCompatibility, e.g. shows ML compat items in intellisense menus - if n = 62 then tcConfigB.mlCompatibility <- true + if n = 62 then + tcConfigB.mlCompatibility <- true tcConfigB.diagnosticsOptions <- { tcConfigB.diagnosticsOptions with @@ -873,7 +874,8 @@ type TcConfigBuilder = | None -> () | Some n -> // warnon 62 turns on mlCompatibility, e.g. shows ML compat items in intellisense menus - if n = 62 then tcConfigB.mlCompatibility <- false + if n = 62 then + tcConfigB.mlCompatibility <- false tcConfigB.diagnosticsOptions <- { tcConfigB.diagnosticsOptions with @@ -941,11 +943,10 @@ type TcConfigBuilder = if FileSystem.IsInvalidPathShim path then warning (Error(FSComp.SR.buildInvalidAssemblyName (path), m)) elif - not - ( - tcConfigB.referencedDLLs - |> List.exists (fun ar2 -> equals m ar2.Range && path = ar2.Text) - ) + not ( + tcConfigB.referencedDLLs + |> List.exists (fun ar2 -> equals m ar2.Range && path = ar2.Text) + ) then // NOTE: We keep same paths if range is different. let projectReference = tcConfigB.projectReferences @@ -1052,9 +1053,10 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = else None - match data.referencedDLLs - |> List.filter (fun assemblyReference -> assemblyReference.SimpleAssemblyNameIs libraryName) - with + match + data.referencedDLLs + |> List.filter (fun assemblyReference -> assemblyReference.SimpleAssemblyNameIs libraryName) + with | [] -> defaultCoreLibraryReference, None | [ r ] | r :: _ -> nameOfDll r @@ -1179,7 +1181,9 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = let frameworkRootVersion = Path.Combine(frameworkRoot, targetFrameworkVersionValue) yield frameworkRootVersion let facades = Path.Combine(frameworkRootVersion, "Facades") - if FileSystem.DirectoryExistsShim facades then yield facades + + if FileSystem.DirectoryExistsShim facades then + yield facades match data.FxResolver.GetFrameworkRefsPackDirectory() with | Some path when FileSystem.DirectoryExistsShim(path) -> yield path diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index f8fd613b267..fba0a064091 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -1673,7 +1673,8 @@ let OutputPhasedErrorR (os: StringBuilder) (diagnostic: PhasedDiagnostic) (canSu | Some (cex, false) -> os.AppendString(MatchIncomplete2E().Format cex) | Some (cex, true) -> os.AppendString(MatchIncomplete3E().Format cex) - if isComp then os.AppendString(MatchIncomplete4E().Format) + if isComp then + os.AppendString(MatchIncomplete4E().Format) | PatternMatchCompilation.EnumMatchIncomplete (isComp, cexOpt, _) -> os.AppendString(EnumMatchIncomplete1E().Format) @@ -1683,7 +1684,8 @@ let OutputPhasedErrorR (os: StringBuilder) (diagnostic: PhasedDiagnostic) (canSu | Some (cex, false) -> os.AppendString(MatchIncomplete2E().Format cex) | Some (cex, true) -> os.AppendString(MatchIncomplete3E().Format cex) - if isComp then os.AppendString(MatchIncomplete4E().Format) + if isComp then + os.AppendString(MatchIncomplete4E().Format) | PatternMatchCompilation.RuleNeverMatched _ -> os.AppendString(RuleNeverMatchedE().Format) @@ -1695,7 +1697,9 @@ let OutputPhasedErrorR (os: StringBuilder) (diagnostic: PhasedDiagnostic) (canSu | ObsoleteWarning (s, _) -> os.AppendString(Obsolete1E().Format) - if s <> "" then os.AppendString(Obsolete2E().Format s) + + if s <> "" then + os.AppendString(Obsolete2E().Format s) | Experimental (s, _) -> os.AppendString(ExperimentalE().Format s) @@ -1990,7 +1994,8 @@ let CollectFormattedDiagnostics // Show prefix only for real files. Otherwise, we just want a truncated error like: // parse error FS0031: blah blah if - not (equals m range0) && not (equals m rangeStartup) + not (equals m range0) + && not (equals m rangeStartup) && not (equals m rangeCmdArgs) then let file = file.Replace("/", "\\") diff --git a/src/Compiler/Driver/CompilerImports.fs b/src/Compiler/Driver/CompilerImports.fs index 515bb1b3868..1e63aa45dd5 100644 --- a/src/Compiler/Driver/CompilerImports.fs +++ b/src/Compiler/Driver/CompilerImports.fs @@ -402,7 +402,8 @@ type TcConfig with seq { yield! tcConfig.GetSearchPathsForLibraryFiles() - if isHashRReference m then Path.GetDirectoryName(m.FileName) + if isHashRReference m then + Path.GetDirectoryName(m.FileName) } let resolved = TryResolveFileUsingPaths(searchPaths, m, nm) @@ -592,8 +593,10 @@ type TcConfig with // O(N^2) here over a small set of referenced assemblies. let IsResolved (originalName: string) = - if resultingResolutions - |> List.exists (fun resolution -> resolution.originalReference.Text = originalName) then + if + resultingResolutions + |> List.exists (fun resolution -> resolution.originalReference.Text = originalName) + then true else // MSBuild resolution may have unified the result of two duplicate references. Try to re-resolve now. @@ -615,8 +618,10 @@ type TcConfig with // If mode=Speculative, then we haven't reported any errors. // We report the error condition by returning an empty list of resolutions - if mode = ResolveAssemblyReferenceMode.Speculative - && unresolvedReferences.Length > 0 then + if + mode = ResolveAssemblyReferenceMode.Speculative + && unresolvedReferences.Length > 0 + then [], unresolved else resultingResolutions, unresolved @@ -736,7 +741,8 @@ type TcAssemblyResolutions(tcConfig: TcConfig, results: AssemblyResolution list, resolutions.Length = 1 - if found then asm + if found then + asm if tcConfig.implicitlyReferenceDotNetAssemblies then let references, _useDotNetFramework = @@ -1097,7 +1103,9 @@ and [] TcImports let mutable disposed = false // this doesn't need locking, it's only for debugging let mutable tcGlobals = None // this doesn't need locking, it's set during construction of the TcImports - let CheckDisposed () = if disposed then assert false + let CheckDisposed () = + if disposed then + assert false let dispose () = CheckDisposed() @@ -1116,8 +1124,11 @@ and [] TcImports let unsuccessful = [ for ccuThunk, func in contents do - if ccuThunk.IsUnresolvedReference then func () - if ccuThunk.IsUnresolvedReference then (ccuThunk, func) + if ccuThunk.IsUnresolvedReference then + func () + + if ccuThunk.IsUnresolvedReference then + (ccuThunk, func) ] ccuThunks <- ResizeArray unsuccessful) diff --git a/src/Compiler/Driver/CompilerOptions.fs b/src/Compiler/Driver/CompilerOptions.fs index e33e311eb86..b8fbfbe4f91 100644 --- a/src/Compiler/Driver/CompilerOptions.fs +++ b/src/Compiler/Driver/CompilerOptions.fs @@ -288,9 +288,11 @@ let ParseCompilerOptions (collectOtherArgument: string -> unit, blocks: Compiler let getSwitchOpt (opt: string) = // if opt is a switch, strip the '+' or '-' - if opt <> "--" - && opt.Length > 1 - && (opt.EndsWithOrdinal("+") || opt.EndsWithOrdinal("-")) then + if + opt <> "--" + && opt.Length > 1 + && (opt.EndsWithOrdinal("+") || opt.EndsWithOrdinal("-")) + then opt[0 .. opt.Length - 2] else opt @@ -368,7 +370,10 @@ let ParseCompilerOptions (collectOtherArgument: string -> unit, blocks: Compiler | CompilerOption (s, _, OptionString f, d, _) as compilerOption :: _ when optToken = s -> reportDeprecatedOption d let oa = getOptionArg compilerOption argString - if oa <> "" then f (getOptionArg compilerOption oa) + + if oa <> "" then + f (getOptionArg compilerOption oa) + t | CompilerOption (s, _, OptionInt f, d, _) as compilerOption :: _ when optToken = s -> reportDeprecatedOption d @@ -1234,7 +1239,9 @@ let noFrameworkFlag isFsc tcConfigB = tagNone, OptionUnit(fun () -> tcConfigB.implicitlyReferenceDotNetAssemblies <- false - if isFsc then tcConfigB.implicitlyResolveAssemblies <- false), + + if isFsc then + tcConfigB.implicitlyResolveAssemblies <- false), None, Some(FSComp.SR.optsNoframework ()) ) diff --git a/src/Compiler/Driver/CreateILModule.fs b/src/Compiler/Driver/CreateILModule.fs index 9039453478c..55ec3ad40a1 100644 --- a/src/Compiler/Driver/CreateILModule.fs +++ b/src/Compiler/Driver/CreateILModule.fs @@ -195,9 +195,10 @@ module MainModuleBuilder = "System.Runtime.Numerics" let numericsAssemblyRef = - match tcImports.GetImportedAssemblies() - |> List.tryFind (fun a -> a.FSharpViewOfMetadata.AssemblyName = refNumericsDllName) - with + match + tcImports.GetImportedAssemblies() + |> List.tryFind (fun a -> a.FSharpViewOfMetadata.AssemblyName = refNumericsDllName) + with | Some asm -> match asm.ILScopeRef with | ILScopeRef.Assembly aref -> Some aref @@ -581,10 +582,12 @@ module MainModuleBuilder = tcConfig.win32manifest // don't embed a manifest if target is not an exe, if manifest is specifically excluded, if another native resource is being included, or if running on mono - elif not (tcConfig.target.IsExe) - || not (tcConfig.includewin32manifest) - || not (tcConfig.win32res = "") - || runningOnMono then + elif + not (tcConfig.target.IsExe) + || not (tcConfig.includewin32manifest) + || not (tcConfig.win32res = "") + || runningOnMono + then "" // otherwise, include the default manifest else @@ -617,9 +620,11 @@ module MainModuleBuilder = tcConfig.target = CompilerTarget.Dll )) |] - if tcConfig.win32res = "" - && tcConfig.win32icon <> "" - && tcConfig.target <> CompilerTarget.Dll then + if + tcConfig.win32res = "" + && tcConfig.win32icon <> "" + && tcConfig.target <> CompilerTarget.Dll + then use ms = new MemoryStream() use iconStream = FileSystem.OpenFileForReadShim(tcConfig.win32icon) Win32ResourceConversions.AppendIconToResourceStream(ms, iconStream) diff --git a/src/Compiler/Driver/FxResolver.fs b/src/Compiler/Driver/FxResolver.fs index 2d1eb4ce7ae..d769b36678e 100644 --- a/src/Compiler/Driver/FxResolver.fs +++ b/src/Compiler/Driver/FxResolver.fs @@ -492,13 +492,14 @@ type internal FxResolver defaultMscorlibVersion // Get the ProductVersion of this framework compare with table compatible monikers - match desktopProductVersionMonikers - |> Array.tryFind (fun (major, minor, build, revision, _) -> - (majorPart >= major) - && (minorPart >= minor) - && (buildPart >= build) - && (privatePart >= revision)) - with + match + desktopProductVersionMonikers + |> Array.tryFind (fun (major, minor, build, revision, _) -> + (majorPart >= major) + && (minorPart >= minor) + && (buildPart >= build) + && (privatePart >= revision)) + with | Some (_, _, _, _, moniker) -> moniker | None -> // no TFM could be found, assume latest stable? @@ -653,7 +654,8 @@ type internal FxResolver "System.Configuration" getFSharpCoreLibraryName - if useFsiAuxLib then fsiLibraryName + if useFsiAuxLib then + fsiLibraryName // always include a default reference to System.ValueTuple.dll in scripts and out-of-project sources match getSystemValueTupleImplementationReference () with @@ -687,7 +689,8 @@ type internal FxResolver [ yield! Directory.GetFiles(implDir, "*.dll") getFSharpCoreImplementationReference () - if useFsiAuxLib then getFsiLibraryImplementationReference () + if useFsiAuxLib then + getFsiLibraryImplementationReference () ] (getDependenciesOf roots).Values |> Seq.toList @@ -979,7 +982,8 @@ type internal FxResolver [ yield! Directory.GetFiles(path, "*.dll") getFSharpCoreImplementationReference () - if useFsiAuxLib then getFsiLibraryImplementationReference () + if useFsiAuxLib then + getFsiLibraryImplementationReference () ] |> List.filter (fun f -> systemAssemblies.Contains(Path.GetFileNameWithoutExtension(f))) diff --git a/src/Compiler/Driver/OptimizeInputs.fs b/src/Compiler/Driver/OptimizeInputs.fs index bd8a76ab674..fc276a711a0 100644 --- a/src/Compiler/Driver/OptimizeInputs.fs +++ b/src/Compiler/Driver/OptimizeInputs.fs @@ -232,8 +232,10 @@ let GenerateIlxCode ) = let mainMethodInfo = - if (tcConfig.target = CompilerTarget.Dll) - || (tcConfig.target = CompilerTarget.Module) then + if + (tcConfig.target = CompilerTarget.Dll) + || (tcConfig.target = CompilerTarget.Module) + then None else Some topAttrs.mainMethodAttrs diff --git a/src/Compiler/Driver/ParseAndCheckInputs.fs b/src/Compiler/Driver/ParseAndCheckInputs.fs index 3470f97a8af..6d764f264dd 100644 --- a/src/Compiler/Driver/ParseAndCheckInputs.fs +++ b/src/Compiler/Driver/ParseAndCheckInputs.fs @@ -617,7 +617,8 @@ let ParseOneInputLexbuf (tcConfig: TcConfig, lexResourceManager, lexbuf, fileNam ) // Report the statistics for testing purposes - if tcConfig.reportNumDecls then ReportParsingStatistics res + if tcConfig.reportNumDecls then + ReportParsingStatistics res res) diff --git a/src/Compiler/Driver/ScriptClosure.fs b/src/Compiler/Driver/ScriptClosure.fs index 67adfb1e8de..868a9f80cae 100644 --- a/src/Compiler/Driver/ScriptClosure.fs +++ b/src/Compiler/Driver/ScriptClosure.fs @@ -98,7 +98,8 @@ module ScriptPreprocessClosure = let seen = Dictionary<_, bool>() member _.SetSeen check = - if not (seen.ContainsKey check) then seen.Add(check, true) + if not (seen.ContainsKey check) then + seen.Add(check, true) member _.HaveSeen check = seen.ContainsKey check diff --git a/src/Compiler/Driver/StaticLinking.fs b/src/Compiler/Driver/StaticLinking.fs index 6c23eb9b024..5ad9ff15f40 100644 --- a/src/Compiler/Driver/StaticLinking.fs +++ b/src/Compiler/Driver/StaticLinking.fs @@ -304,8 +304,10 @@ let FindDependentILModulesForStaticLinking (ctok, tcConfig: TcConfig, tcImports: let ilAssemRef = List.head remaining remaining <- List.tail remaining - if assumedIndependentSet.Contains ilAssemRef.Name - || (ilAssemRef.PublicKey = Some ecmaPublicKey) then + if + assumedIndependentSet.Contains ilAssemRef.Name + || (ilAssemRef.PublicKey = Some ecmaPublicKey) + then depModuleTable[ilAssemRef.Name] <- dummyEntry ilAssemRef.Name else if not (depModuleTable.ContainsKey ilAssemRef.Name) then match tcImports.TryFindDllInfo(ctok, rangeStartup, ilAssemRef.Name, lookupOnly = false) with @@ -502,10 +504,11 @@ let StaticLink (ctok, tcConfig: TcConfig, tcImports: TcImports, ilGlobals: ILGlo | Some provAssemStaticLinkInfo -> (importedBinary, provAssemStaticLinkInfo) ] #endif - if not tcConfig.standalone - && tcConfig.extraStaticLinkRoots.IsEmpty + if + not tcConfig.standalone + && tcConfig.extraStaticLinkRoots.IsEmpty #if !NO_TYPEPROVIDERS - && providerGeneratedAssemblies.IsEmpty + && providerGeneratedAssemblies.IsEmpty #endif then id diff --git a/src/Compiler/Driver/XmlDocFileWriter.fs b/src/Compiler/Driver/XmlDocFileWriter.fs index 97125744ace..fe6ac2a3fac 100644 --- a/src/Compiler/Driver/XmlDocFileWriter.fs +++ b/src/Compiler/Driver/XmlDocFileWriter.fs @@ -63,7 +63,8 @@ module XmlDocWriter = let ptext = defaultArg path "" - if mspec.IsModule then doModuleMemberSig ptext mspec + if mspec.IsModule then + doModuleMemberSig ptext mspec let vals = mtype.AllValsAndMembers @@ -116,7 +117,9 @@ module XmlDocWriter = let rec doModule (mspec: ModuleOrNamespace) = let mtype = mspec.ModuleOrNamespaceType - if mspec.IsModule then modulMember mspec + + if mspec.IsModule then + modulMember mspec let vals = mtype.AllValsAndMembers diff --git a/src/Compiler/Driver/fsc.fs b/src/Compiler/Driver/fsc.fs index b0519d50a8d..84fd4742d6d 100644 --- a/src/Compiler/Driver/fsc.fs +++ b/src/Compiler/Driver/fsc.fs @@ -149,7 +149,8 @@ type ConsoleLoggerProvider() = /// Notify the exiter if any error has occurred let AbortOnError (diagnosticsLogger: DiagnosticsLogger, exiter: Exiter) = - if diagnosticsLogger.ErrorCount > 0 then exiter.Exit 1 + if diagnosticsLogger.ErrorCount > 0 then + exiter.Exit 1 let TypeCheck ( @@ -382,7 +383,8 @@ module InterfaceFileWriter = for impl in declaredImpls do writeToFile os impl - if tcConfig.printSignatureFile <> "" then os.Dispose() + if tcConfig.printSignatureFile <> "" then + os.Dispose() let extensionForFile (filePath: string) = if (List.exists (FileSystemUtils.checkSuffix filePath) FSharpMLCompatFileSuffixes) then @@ -489,11 +491,13 @@ let main1 // See Bug 735819 let lcidFromCodePage = - if (Console.OutputEncoding.CodePage <> 65001) - && (Console.OutputEncoding.CodePage - <> Thread.CurrentThread.CurrentUICulture.TextInfo.OEMCodePage) - && (Console.OutputEncoding.CodePage - <> Thread.CurrentThread.CurrentUICulture.TextInfo.ANSICodePage) then + if + (Console.OutputEncoding.CodePage <> 65001) + && (Console.OutputEncoding.CodePage + <> Thread.CurrentThread.CurrentUICulture.TextInfo.OEMCodePage) + && (Console.OutputEncoding.CodePage + <> Thread.CurrentThread.CurrentUICulture.TextInfo.ANSICodePage) + then Thread.CurrentThread.CurrentUICulture <- CultureInfo("en-US") Some 1033 else @@ -553,7 +557,8 @@ let main1 tcConfigB.conditionalDefines <- "COMPILED" :: tcConfigB.conditionalDefines // Display the banner text, if necessary - if not bannerAlreadyPrinted then DisplayBannerText tcConfigB + if not bannerAlreadyPrinted then + DisplayBannerText tcConfigB // Create tcGlobals and frameworkTcImports let outfile, pdbfile, assemblyName = @@ -633,7 +638,8 @@ let main1 printfn "%+A" input printf "\n" - if tcConfig.parseOnly then exiter.Exit 0 + if tcConfig.parseOnly then + exiter.Exit 0 if not tcConfig.continueAfterParseFailure then AbortOnError(diagnosticsLogger, exiter) @@ -659,7 +665,8 @@ let main1 if not tcConfig.continueAfterParseFailure then AbortOnError(diagnosticsLogger, exiter) - if tcConfig.importAllReferencesOnly then exiter.Exit 0 + if tcConfig.importAllReferencesOnly then + exiter.Exit 0 // Build the initial type checking environment ReportTime tcConfig "Typecheck" @@ -912,7 +919,8 @@ let main2 ilSourceDocs)) = - if tcConfig.typeCheckOnly then exiter.Exit 0 + if tcConfig.typeCheckOnly then + exiter.Exit 0 generatedCcu.Contents.SetAttribs(generatedCcu.Contents.Attribs @ topAttrs.assemblyAttrs) @@ -945,7 +953,7 @@ let main2 "AssemblyVersionAttribute" topAttrs.assemblyAttrs tcConfig.deterministic - with + with | Some v -> match tcConfig.version with | VersionNone -> Some v @@ -1351,9 +1359,11 @@ let main6 AbortOnError(diagnosticsLogger, exiter) // Don't copy referenced FSharp.core.dll if we are building FSharp.Core.dll - if (tcConfig.copyFSharpCore = CopyFSharpCoreFlag.Yes) - && not tcConfig.compilingFSharpCore - && not tcConfig.standalone then + if + (tcConfig.copyFSharpCore = CopyFSharpCoreFlag.Yes) + && not tcConfig.compilingFSharpCore + && not tcConfig.standalone + then CopyFSharpCore(outfile, tcConfig.referencedDLLs) ReportTime tcConfig "Exiting" diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index d11ae3d895b..c7f4e0ce0f0 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -381,8 +381,10 @@ type internal TypeCheckInfo if contained then match bestAlmostIncludedSoFar with | Some (rightm: range, _, _) -> - if posGt possm.End rightm.End - || (posEq possm.End rightm.End && posGt possm.Start rightm.Start) then + if + posGt possm.End rightm.End + || (posEq possm.End rightm.End && posGt possm.Start rightm.Start) + then bestAlmostIncludedSoFar <- Some(possm, env, ad) | _ -> bestAlmostIncludedSoFar <- Some(possm, env, ad)) @@ -914,9 +916,10 @@ type internal TypeCheckInfo match TryToResolveLongIdentAsType ncenv nenv m plid with | Some x -> tryTcrefOfAppTy g x | None -> - match lastDotPos - |> Option.orElseWith (fun _ -> FindFirstNonWhitespacePosition lineStr (colAtEndOfNamesAndResidue - 1)) - with + match + lastDotPos + |> Option.orElseWith (fun _ -> FindFirstNonWhitespacePosition lineStr (colAtEndOfNamesAndResidue - 1)) + with | Some p when lineStr[p] = '.' -> match FindFirstNonWhitespacePosition lineStr (p - 1) with | Some colAtEndOfNames -> @@ -1154,7 +1157,7 @@ type internal TypeCheckInfo match GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, plid, false) |> toCompletionItems - with + with | [], _, _ -> // no record fields found, return completion list as if we were outside any computation expression GetDeclaredItems( @@ -2395,19 +2398,22 @@ module internal ParseAndCheckFile = let errors = [ for err, severity in diagnostics do - if severity = FSharpDiagnosticSeverity.Error then err + if severity = FSharpDiagnosticSeverity.Error then + err ] let warnings = [ for err, severity in diagnostics do - if severity = FSharpDiagnosticSeverity.Warning then err + if severity = FSharpDiagnosticSeverity.Warning then + err ] let infos = [ for err, severity in diagnostics do - if severity = FSharpDiagnosticSeverity.Info then err + if severity = FSharpDiagnosticSeverity.Info then + err ] let message = HashLoadedSourceHasIssues(infos, warnings, errors, rangeOfHashLoad) diff --git a/src/Compiler/Service/FSharpParseFileResults.fs b/src/Compiler/Service/FSharpParseFileResults.fs index 3959c84da3f..c2ee71a022e 100644 --- a/src/Compiler/Service/FSharpParseFileResults.fs +++ b/src/Compiler/Service/FSharpParseFileResults.fs @@ -498,7 +498,8 @@ type FSharpParseFileResults(diagnostics: FSharpDiagnostic[], input: ParsedInput, let findBreakPoints () = let checkRange m = [ - if isMatchRange m && not m.IsSynthetic then yield m + if isMatchRange m && not m.IsSynthetic then + yield m ] let walkBindSeqPt sp = @@ -559,7 +560,8 @@ type FSharpParseFileResults(diagnostics: FSharpDiagnostic[], input: ParsedInput, | _ -> false // This extends the range of the implicit debug point for 'do expr' range to include the 'do' - if extendDebugPointForDo then yield! checkRange m + if extendDebugPointForDo then + yield! checkRange m let useImplicitDebugPoint = match spInfo with @@ -944,9 +946,10 @@ type FSharpParseFileResults(diagnostics: FSharpDiagnostic[], input: ParsedInput, if pos.Column = 0 then // we have a breakpoint that was set with mouse at line start - match locations - |> List.filter (fun m -> m.StartLine = m.EndLine && pos.Line = m.StartLine) - with + match + locations + |> List.filter (fun m -> m.StartLine = m.EndLine && pos.Line = m.StartLine) + with | [] -> match locations |> List.filter (fun m -> rangeContainsPos m pos) with | [] -> diff --git a/src/Compiler/Service/ItemKey.fs b/src/Compiler/Service/ItemKey.fs index 2854da14a25..261d6ec094f 100644 --- a/src/Compiler/Service/ItemKey.fs +++ b/src/Compiler/Service/ItemKey.fs @@ -150,7 +150,9 @@ type ItemKeyStore(mmf: MemoryMappedFile, length) = while reader.Offset < reader.Length do let m = this.ReadRange &reader let keyString2 = this.ReadKeyString &reader - if keyString1.SequenceEqual keyString2 then results.Add m + + if keyString1.SequenceEqual keyString2 then + results.Add m results :> range seq @@ -271,7 +273,9 @@ and [] ItemKeyStoreBuilder() = and writeTypar (isStandalone: bool) (typar: Typar) = match typar.Solution with | Some ty -> writeType isStandalone ty - | _ -> if isStandalone then writeInt64 typar.Stamp + | _ -> + if isStandalone then + writeInt64 typar.Stamp let writeValRef (vref: ValRef) = match vref.MemberInfo with diff --git a/src/Compiler/Service/SemanticClassification.fs b/src/Compiler/Service/SemanticClassification.fs index c95195db8ff..bdbc73d783a 100644 --- a/src/Compiler/Service/SemanticClassification.fs +++ b/src/Compiler/Service/SemanticClassification.fs @@ -93,12 +93,14 @@ module TcResolutionsExtensions = | _ -> None let (|KeywordIntrinsicValue|_|) (vref: ValRef) = - if valRefEq g g.raise_vref vref - || valRefEq g g.reraise_vref vref - || valRefEq g g.typeof_vref vref - || valRefEq g g.typedefof_vref vref - || valRefEq g g.sizeof_vref vref - || valRefEq g g.nameof_vref vref then + if + valRefEq g g.raise_vref vref + || valRefEq g g.reraise_vref vref + || valRefEq g g.typeof_vref vref + || valRefEq g g.typedefof_vref vref + || valRefEq g g.sizeof_vref vref + || valRefEq g g.nameof_vref vref + then Some() else None @@ -257,8 +259,10 @@ module TcResolutionsExtensions = match minfos with | [] -> add m SemanticClassificationType.Method | _ -> - if minfos - |> List.forall (fun minfo -> minfo.IsExtensionMember || minfo.IsCSharpStyleExtensionMember) then + if + minfos + |> List.forall (fun minfo -> minfo.IsExtensionMember || minfo.IsCSharpStyleExtensionMember) + then add m SemanticClassificationType.ExtensionMethod else add m SemanticClassificationType.Method diff --git a/src/Compiler/Service/ServiceAnalysis.fs b/src/Compiler/Service/ServiceAnalysis.fs index 09e3545e8ad..38af8f7156c 100644 --- a/src/Compiler/Service/ServiceAnalysis.fs +++ b/src/Compiler/Service/ServiceAnalysis.fs @@ -40,7 +40,8 @@ module UnusedOpens = // fv.IsExtensionMember is always false for C# extension methods returning by `MembersFunctionsAndValues`, // so we have to check Extension attribute instead. // (note: fv.IsExtensionMember has proper value for symbols returning by GetAllUsesOfAllSymbolsInFile though) - if fv.HasAttribute() then fv + if fv.HasAttribute() then + fv for apCase in entity.ActivePatternCases do apCase @@ -429,11 +430,13 @@ module UnusedDeclarations = symbolsUses |> Seq.distinctBy (fun su -> su.Range) // Account for "hidden" uses, like a val in a member val definition. These aren't relevant |> Seq.choose (fun (su: FSharpSymbolUse) -> - if su.IsFromDefinition - && su.Symbol.DeclarationLocation.IsSome - && (isScript || su.IsPrivateToFile) - && not (su.Symbol.DisplayName.StartsWith "_") - && isPotentiallyUnusedDeclaration su.Symbol then + if + su.IsFromDefinition + && su.Symbol.DeclarationLocation.IsSome + && (isScript || su.IsPrivateToFile) + && not (su.Symbol.DisplayName.StartsWith "_") + && isPotentiallyUnusedDeclaration su.Symbol + then Some(su, usages.Contains su.Symbol.DeclarationLocation.Value) else None) diff --git a/src/Compiler/Service/ServiceInterfaceStubGenerator.fs b/src/Compiler/Service/ServiceInterfaceStubGenerator.fs index 5458e129ffd..410d02dc786 100644 --- a/src/Compiler/Service/ServiceInterfaceStubGenerator.fs +++ b/src/Compiler/Service/ServiceInterfaceStubGenerator.fs @@ -206,9 +206,11 @@ module InterfaceStubGenerator = let nm = match arg.Name with | None -> - if arg.Type.HasTypeDefinition - && arg.Type.TypeDefinition.CompiledName = "unit" - && arg.Type.TypeDefinition.Namespace = Some "Microsoft.FSharp.Core" then + if + arg.Type.HasTypeDefinition + && arg.Type.TypeDefinition.CompiledName = "unit" + && arg.Type.TypeDefinition.Namespace = Some "Microsoft.FSharp.Core" + then "()" else sprintf "arg%d" (namesWithIndices |> Map.toSeq |> Seq.map snd |> Seq.sumBy Set.count |> max 1) @@ -303,8 +305,10 @@ module InterfaceStubGenerator = let internal normalizePropertyName (v: FSharpMemberOrFunctionOrValue) = let displayName = v.DisplayName - if (v.IsPropertyGetterMethod && displayName.StartsWithOrdinal("get_")) - || (v.IsPropertySetterMethod && displayName.StartsWithOrdinal("set_")) then + if + (v.IsPropertyGetterMethod && displayName.StartsWithOrdinal("get_")) + || (v.IsPropertySetterMethod && displayName.StartsWithOrdinal("set_")) + then displayName[4..] else displayName @@ -362,7 +366,8 @@ module InterfaceStubGenerator = [ if v.InlineAnnotation = FSharpInlineAnnotation.AlwaysInline then yield "inline" - if v.Accessibility.IsInternal then yield "internal" + if v.Accessibility.IsInternal then + yield "internal" ] let argInfos, retType = getArgTypes ctx v @@ -371,9 +376,13 @@ module InterfaceStubGenerator = // A couple of helper methods for emitting close declarations of members and stub method bodies. let closeDeclaration (returnType: string) (writer: ColumnIndentedTextWriter) = - if verboseMode then writer.Write(": {0}", returnType) + if verboseMode then + writer.Write(": {0}", returnType) + writer.Write(" = ", returnType) - if verboseMode then writer.WriteLine("") + + if verboseMode then + writer.WriteLine("") let writeImplementation (ctx: Context) (writer: ColumnIndentedTextWriter) = match verboseMode, ctx.MethodBody with @@ -435,7 +444,10 @@ module InterfaceStubGenerator = let closeDeclaration = closeDeclaration retType let writeImplementation = writeImplementation ctx let writer = ctx.Writer - if isEventMember v then writer.WriteLine("[]") + + if isEventMember v then + writer.WriteLine("[]") + writer.Write("member ") for modifier in modifiers do @@ -464,7 +476,9 @@ module InterfaceStubGenerator = writer.Write(")") writer.Write(" = ") - if verboseMode then writer.WriteLine("") + + if verboseMode then + writer.WriteLine("") writer |> writeImplementation writer.Unindent ctx.Indentation diff --git a/src/Compiler/Service/ServiceLexing.fs b/src/Compiler/Service/ServiceLexing.fs index 9ecdbb823a4..9f14d717af2 100644 --- a/src/Compiler/Service/ServiceLexing.fs +++ b/src/Compiler/Service/ServiceLexing.fs @@ -683,8 +683,10 @@ module internal LexerStateEncoding = let kind2 = ((nestingValue &&& 0b000000000011) >>> 0) [ - if tag1 then i1, decodeStringStyle kind1, range0 - if tag2 then i2, decodeStringStyle kind2, range0 + if tag1 then + i1, decodeStringStyle kind1, range0 + if tag2 then + i2, decodeStringStyle kind2, range0 ] (colorState, ncomments, pos, ifDefs, hardwhite, stringKind, stringNest) diff --git a/src/Compiler/Service/ServiceNavigation.fs b/src/Compiler/Service/ServiceNavigation.fs index f162076d44e..68b7eb268f9 100755 --- a/src/Compiler/Service/ServiceNavigation.fs +++ b/src/Compiler/Service/ServiceNavigation.fs @@ -831,7 +831,9 @@ module NavigateTo = and walkSynModuleOrNamespaceSig (inp: SynModuleOrNamespaceSig) container = let (SynModuleOrNamespaceSig (longId = lid; kind = kind; decls = decls)) = inp let isModule = kind.IsModule - if isModule then addModule lid true container + + if isModule then + addModule lid true container let container = { @@ -900,7 +902,9 @@ module NavigateTo = and walkSynModuleOrNamespace inp container = let (SynModuleOrNamespace (longId = lid; kind = kind; decls = decls)) = inp let isModule = kind.IsModule - if isModule then addModule lid false container + + if isModule then + addModule lid false container let container = { diff --git a/src/Compiler/Service/ServiceParamInfoLocations.fs b/src/Compiler/Service/ServiceParamInfoLocations.fs index 35b4b777d8a..ff34dd392d4 100755 --- a/src/Compiler/Service/ServiceParamInfoLocations.fs +++ b/src/Compiler/Service/ServiceParamInfoLocations.fs @@ -222,8 +222,10 @@ module internal ParameterLocationsImpl = let lidm = lidwd.Range let betweenTheBrackets = mkRange wholem.FileName openm.Start wholem.End - if SyntaxTraversal.rangeContainsPosEdgesExclusive betweenTheBrackets pos - && args |> List.forall isStaticArg then + if + SyntaxTraversal.rangeContainsPosEdgesExclusive betweenTheBrackets pos + && args |> List.forall isStaticArg + then let commasAndCloseParen = [ for c in commas -> c.End ] @ [ wholem.End ] Some( @@ -344,8 +346,10 @@ module internal ParameterLocationsImpl = | None -> let typeArgsm = mkRange openm.FileName openm.Start wholem.End - if SyntaxTraversal.rangeContainsPosEdgesExclusive typeArgsm pos - && tyArgs |> List.forall isStaticArg then + if + SyntaxTraversal.rangeContainsPosEdgesExclusive typeArgsm pos + && tyArgs |> List.forall isStaticArg + then let commasAndCloseParen = [ for c in commas -> c.End ] @ [ wholem.End ] let argRanges = diff --git a/src/Compiler/Service/ServiceParseTreeWalk.fs b/src/Compiler/Service/ServiceParseTreeWalk.fs index 32e20db6486..e2eedc9ba47 100755 --- a/src/Compiler/Service/ServiceParseTreeWalk.fs +++ b/src/Compiler/Service/ServiceParseTreeWalk.fs @@ -246,14 +246,15 @@ module SyntaxTraversal = else None) diveResults - with + with | [] -> // No entity's range contained the desired position. However the ranges in the parse tree only span actual characters present in the file. // The cursor may be at whitespace between entities or after everything, so find the nearest entity with the range left of the position. let mutable e = diveResults.Head for r in diveResults do - if posGt pos (fst r).Start then e <- r + if posGt pos (fst r).Start then + e <- r snd (e) () | [ x ] -> x () @@ -396,9 +397,11 @@ module SyntaxTraversal = // special-case:caret is located in the offside position below inherit // inherit A() // $ - if not (rangeContainsPos expr.Range pos) - && sepOpt.IsNone - && pos.Column = inheritRange.StartColumn then + if + not (rangeContainsPos expr.Range pos) + && sepOpt.IsNone + && pos.Column = inheritRange.StartColumn + then visitor.VisitRecordField(path, None, None) else traverseSynExpr expr) @@ -451,9 +454,11 @@ module SyntaxTraversal = // special case: caret is below field binding // field x = 5 // $ - if not (rangeContainsPos e.Range pos) - && sepOpt.IsNone - && pos.Column = offsideColumn then + if + not (rangeContainsPos e.Range pos) + && sepOpt.IsNone + && pos.Column = offsideColumn + then visitor.VisitRecordField(path, copyOpt, None) else traverseSynExpr expr) diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index f61893d0eaf..757cd90a264 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -1539,7 +1539,9 @@ module ParsedInput = None override this.VisitModuleOrNamespace(_, SynModuleOrNamespace (longId = longId; range = range)) = - if rangeContainsPos range pos then path <- path @ longId + if rangeContainsPos range pos then + path <- path @ longId + None // we should traverse the rest of the AST to find the smallest module } @@ -1916,7 +1918,9 @@ module ParsedInput = List.iter walkAttribute attrs List.iter walkTyparDecl typars List.iter walkTypeConstraint constraints - if isTypeExtensionOrAlias then addLongIdent longIdent + + if isTypeExtensionOrAlias then + addLongIdent longIdent and walkTypeDefnRepr inp = match inp with diff --git a/src/Compiler/Service/ServiceStructure.fs b/src/Compiler/Service/ServiceStructure.fs index 8e3a96112ca..995e4e4d3e9 100644 --- a/src/Compiler/Service/ServiceStructure.fs +++ b/src/Compiler/Service/ServiceStructure.fs @@ -319,24 +319,28 @@ module Structure = | SynExpr.App (atomicFlag, isInfix, funcExpr, argExpr, r) -> // seq exprs, custom operators, etc - if ExprAtomicFlag.NonAtomic = atomicFlag - && not isInfix - && (match funcExpr with - | SynExpr.Ident _ -> true - | _ -> false) - && (match argExpr with - | SynExpr.ComputationExpr _ -> false - | _ -> true) then + if + ExprAtomicFlag.NonAtomic = atomicFlag + && not isInfix + && (match funcExpr with + | SynExpr.Ident _ -> true + | _ -> false) + && (match argExpr with + | SynExpr.ComputationExpr _ -> false + | _ -> true) + then // if the argExpr is a computation expression another match will handle the outlining // these cases must be removed to prevent creating unnecessary tags for the same scope let collapse = Range.endToEnd funcExpr.Range r rcheck Scope.SpecialFunc Collapse.Below r collapse - elif ExprAtomicFlag.NonAtomic = atomicFlag - && (not isInfix) - && (match argExpr with - | SynExpr.ComputationExpr _ -> true - | _ -> false) then + elif + ExprAtomicFlag.NonAtomic = atomicFlag + && (not isInfix) + && (match argExpr with + | SynExpr.ComputationExpr _ -> true + | _ -> false) + then let collapse = Range.startToEnd argExpr.Range r let collapse = Range.modBoth 1 1 collapse rcheck Scope.ComputationExpr Collapse.Same r collapse diff --git a/src/Compiler/Service/service.fs b/src/Compiler/Service/service.fs index 023c0ddfe2a..20fd5956c43 100644 --- a/src/Compiler/Service/service.fs +++ b/src/Compiler/Service/service.fs @@ -334,11 +334,13 @@ type BackgroundCompiler // these cross-project references to FSharp.Core are VisualFSharp.sln and FSharp.sln. The ramification // of this is that you need to build FSharp.Core to get intellisense in those projects. - if (try + if + (try Path.GetFileNameWithoutExtension(nm) - with _ -> - "") - <> GetFSharpCoreLibraryName() then + with _ -> + "") + <> GetFSharpCoreLibraryName() + then { new IProjectReference with member x.EvaluateRawContents() = node { diff --git a/src/Compiler/SyntaxTree/LexHelpers.fs b/src/Compiler/SyntaxTree/LexHelpers.fs index c9b201b9445..67f6c78f558 100644 --- a/src/Compiler/SyntaxTree/LexHelpers.fs +++ b/src/Compiler/SyntaxTree/LexHelpers.fs @@ -211,7 +211,8 @@ let stringBufferIsBytes (buf: ByteBuffer) = let mutable ok = true for i = 0 to bytes.Length / 2 - 1 do - if bytes.Span[i * 2 + 1] <> 0uy then ok <- false + if bytes.Span[i * 2 + 1] <> 0uy then + ok <- false ok @@ -237,15 +238,20 @@ let hexdigit d = else failwith "hexdigit" let unicodeGraphShort (s: string) = - if s.Length <> 4 then failwith "unicodegraph" + if s.Length <> 4 then + failwith "unicodegraph" + uint16 (hexdigit s[0] * 4096 + hexdigit s[1] * 256 + hexdigit s[2] * 16 + hexdigit s[3]) let hexGraphShort (s: string) = - if s.Length <> 2 then failwith "hexgraph" + if s.Length <> 2 then + failwith "hexgraph" + uint16 (hexdigit s[0] * 16 + hexdigit s[1]) let unicodeGraphLong (s: string) = - if s.Length <> 8 then failwith "unicodeGraphLong" + if s.Length <> 8 then + failwith "unicodeGraphLong" let high = hexdigit s[0] * 4096 + hexdigit s[1] * 256 + hexdigit s[2] * 16 + hexdigit s[3] in diff --git a/src/Compiler/SyntaxTree/ParseHelpers.fs b/src/Compiler/SyntaxTree/ParseHelpers.fs index bcaebd20b92..ff7a44e98a4 100644 --- a/src/Compiler/SyntaxTree/ParseHelpers.fs +++ b/src/Compiler/SyntaxTree/ParseHelpers.fs @@ -25,7 +25,7 @@ open Internal.Utilities.Text.Parsing /// information about the grammar at the point where the error occurred, e.g. what tokens /// are valid to shift next at that point in the grammar. This information is processed in CompileOps.fs. [] -exception SyntaxError of obj (* ParseErrorContext<_> *) * range: range +exception SyntaxError of obj (* ParseErrorContext<_> *) * range: range exception IndentationProblem of string * range diff --git a/src/Compiler/SyntaxTree/PrettyNaming.fs b/src/Compiler/SyntaxTree/PrettyNaming.fs index ad02a04b1b7..6e25b5c6360 100755 --- a/src/Compiler/SyntaxTree/PrettyNaming.fs +++ b/src/Compiler/SyntaxTree/PrettyNaming.fs @@ -527,7 +527,8 @@ let DoesIdentifierNeedBackticks (name: string) : bool = /// A utility to help determine if an identifier needs to be quoted let AddBackticksToIdentifierIfNeeded (name: string) : string = if - DoesIdentifierNeedBackticks name && not (name.StartsWithOrdinal("`")) + DoesIdentifierNeedBackticks name + && not (name.StartsWithOrdinal("`")) && not (name.EndsWithOrdinal("`")) then "``" + name + "``" @@ -820,7 +821,10 @@ let TryDemangleGenericNameAndPos (n: string) = while res && i < n.Length do let char = n[i] - if not (char >= '0' && char <= '9') then res <- false + + if not (char >= '0' && char <= '9') then + res <- false + i <- i + 1 if res then ValueSome pos else ValueNone diff --git a/src/Compiler/SyntaxTree/XmlDoc.fs b/src/Compiler/SyntaxTree/XmlDoc.fs index 81dbde3ca22..72c657d2911 100644 --- a/src/Compiler/SyntaxTree/XmlDoc.fs +++ b/src/Compiler/SyntaxTree/XmlDoc.fs @@ -262,7 +262,10 @@ type PreXmlDoc = let lines = Array.map fst preLines let m = Array.reduce unionRanges (Array.map snd preLines) let doc = XmlDoc(lines, m) - if check then doc.Check(paramNamesOpt) + + if check then + doc.Check(paramNamesOpt) + doc member internal x.Range = diff --git a/src/Compiler/Utilities/FileSystem.fs b/src/Compiler/Utilities/FileSystem.fs index 465adeac51d..bdd64e87b69 100644 --- a/src/Compiler/Utilities/FileSystem.fs +++ b/src/Compiler/Utilities/FileSystem.fs @@ -127,7 +127,8 @@ type ByteArrayMemory(bytes: byte[], offset, length) = ByteArrayMemory(Array.empty, 0, 0) :> ByteMemory override _.CopyTo stream = - if length > 0 then stream.Write(bytes, offset, length) + if length > 0 then + stream.Write(bytes, offset, length) override _.Copy(srcOffset, dest, destOffset, count) = checkCount count @@ -412,7 +413,8 @@ module internal FileSystemUtils = let checkSuffix (path: string) (suffix: string) = path.EndsWithOrdinalIgnoreCase(suffix) let hasExtensionWithValidate (validate: bool) (s: string) = - if validate then (checkPathForIllegalChars s) + if validate then + (checkPathForIllegalChars s) let sLen = s.Length @@ -437,7 +439,8 @@ module internal FileSystemUtils = Path.GetFileName(path) let fileNameWithoutExtensionWithValidate (validate: bool) path = - if validate then checkPathForIllegalChars path + if validate then + checkPathForIllegalChars path Path.GetFileNameWithoutExtension(path) @@ -563,7 +566,8 @@ type DefaultFileSystem() as this = let stream = new MemoryMappedStream(mmf, length) - if not stream.CanRead then invalidOp "Cannot read file" + if not stream.CanRead then + invalidOp "Cannot read file" stream :> Stream @@ -881,7 +885,8 @@ type internal ByteStream = } member b.ReadByte() = - if b.pos >= b.max then failwith "end of stream" + if b.pos >= b.max then + failwith "end of stream" let res = b.bytes[b.pos] b.pos <- b.pos + 1 @@ -948,7 +953,8 @@ type internal ByteBuffer = Bytes.blit old 0 buf.bbArray 0 buf.bbCurrent - if buf.useArrayPool then ArrayPool.Shared.Return old + if buf.useArrayPool then + ArrayPool.Shared.Return old member buf.AsMemory() = buf.CheckDisposed() diff --git a/src/Compiler/Utilities/HashMultiMap.fs b/src/Compiler/Utilities/HashMultiMap.fs index cb750676fe3..b88af5d77eb 100644 --- a/src/Compiler/Utilities/HashMultiMap.fs +++ b/src/Compiler/Utilities/HashMultiMap.fs @@ -170,7 +170,8 @@ type internal HashMultiMap<'Key, 'Value>(size: int, comparer: IEqualityComparer< member s.Remove(x) = match s.TryFind x.Key with | Some v -> - if Unchecked.equals v x.Value then s.Remove(x.Key) + if Unchecked.equals v x.Value then + s.Remove(x.Key) true | _ -> false diff --git a/src/Compiler/Utilities/ImmutableArray.fs b/src/Compiler/Utilities/ImmutableArray.fs index 5311efa5e0c..985799856c0 100644 --- a/src/Compiler/Utilities/ImmutableArray.fs +++ b/src/Compiler/Utilities/ImmutableArray.fs @@ -18,7 +18,8 @@ module ImmutableArray = | 0 -> ImmutableArray.Empty | 1 -> ImmutableArray.Create(f 0) | n -> - if n < 0 then invalidArg "n" "Below zero." + if n < 0 then + invalidArg "n" "Below zero." let builder = ImmutableArray.CreateBuilder(n) @@ -180,7 +181,8 @@ module ImmutableArray = let builder = ImmutableArray.CreateBuilder(arr.Length) for i = 0 to arr.Length - 1 do - if predicate arr[i] then builder.Add(arr[i]) + if predicate arr[i] then + builder.Add(arr[i]) builder.Capacity <- builder.Count builder.MoveToImmutable() @@ -199,7 +201,8 @@ module ImmutableArray = for i = 0 to arr.Length - 1 do let result = chooser arr[i] - if result.IsSome then builder.Add(result.Value) + if result.IsSome then + builder.Add(result.Value) builder.Capacity <- builder.Count builder.MoveToImmutable() diff --git a/src/Compiler/Utilities/ResizeArray.fs b/src/Compiler/Utilities/ResizeArray.fs index e96c775f972..cd6e405129c 100644 --- a/src/Compiler/Utilities/ResizeArray.fs +++ b/src/Compiler/Utilities/ResizeArray.fs @@ -26,7 +26,8 @@ module internal ResizeArray = if start2 < 0 then invalidArg "start2" "index must be positive" - if len < 0 then invalidArg "len" "length must be positive" + if len < 0 then + invalidArg "len" "length must be positive" if start1 + len > length arr1 then invalidArg "start1" "(start1+len) out of range" @@ -52,7 +53,8 @@ module internal ResizeArray = if start < 0 then invalidArg "start" "index must be positive" - if len < 0 then invalidArg "len" "length must be positive" + if len < 0 then + invalidArg "len" "length must be positive" if start + len > length arr then invalidArg "len" "length must be positive" @@ -63,7 +65,8 @@ module internal ResizeArray = if start < 0 then invalidArg "start" "index must be positive" - if len < 0 then invalidArg "len" "length must be positive" + if len < 0 then + invalidArg "len" "length must be positive" if start + len > length arr then invalidArg "len" "length must be positive" @@ -203,7 +206,9 @@ module internal ResizeArray = for i = 0 to length arr - 1 do let x = arr[i] - if f x then res.Add(x) + + if f x then + res.Add(x) res diff --git a/src/Compiler/Utilities/illib.fs b/src/Compiler/Utilities/illib.fs index 7d99073da91..3c1172aec7d 100644 --- a/src/Compiler/Utilities/illib.fs +++ b/src/Compiler/Utilities/illib.fs @@ -199,7 +199,8 @@ module Array = let mutable i = 0 while eq && i < len do - if not (inp[i] === res[i]) then eq <- false + if not (inp[i] === res[i]) then + eq <- false i <- i + 1 @@ -1082,9 +1083,11 @@ type MemoizationTable<'T, 'U>(compute: 'T -> 'U, keyComparer: IEqualityComparer< let table = new ConcurrentDictionary<'T, 'U>(keyComparer) member t.Apply x = - if (match canMemoize with - | None -> true - | Some f -> f x) then + if + (match canMemoize with + | None -> true + | Some f -> f x) + then match table.TryGetValue x with | true, res -> res | _ -> diff --git a/src/Compiler/Utilities/range.fs b/src/Compiler/Utilities/range.fs index 035a5de80f4..bbd6a9f0673 100755 --- a/src/Compiler/Utilities/range.fs +++ b/src/Compiler/Utilities/range.fs @@ -343,9 +343,11 @@ type Range(code1: int64, code2: int64) = member m.DebugCode = let name = m.FileName - if name = unknownFileName - || name = startupFileName - || name = commandLineArgsFileName then + if + name = unknownFileName + || name = startupFileName + || name = commandLineArgsFileName + then name else @@ -460,20 +462,26 @@ module Range = else // If all identical then return m1. This preserves NotedSourceConstruct when no merging takes place - if m1.Code1 = m2.Code1 && m1.Code2 = m2.Code2 then + if + m1.Code1 = m2.Code1 && m1.Code2 = m2.Code2 + then m1 else let start = - if (m1.StartLine > m2.StartLine - || (m1.StartLine = m2.StartLine && m1.StartColumn > m2.StartColumn)) then + if + (m1.StartLine > m2.StartLine + || (m1.StartLine = m2.StartLine && m1.StartColumn > m2.StartColumn)) + then m2 else m1 let finish = - if (m1.EndLine > m2.EndLine - || (m1.EndLine = m2.EndLine && m1.EndColumn > m2.EndColumn)) then + if + (m1.EndLine > m2.EndLine + || (m1.EndLine = m2.EndLine && m1.EndColumn > m2.EndColumn)) + then m1 else m2 diff --git a/src/Compiler/Utilities/sformat.fs b/src/Compiler/Utilities/sformat.fs index 2c2a4096573..42b13e28ff9 100644 --- a/src/Compiler/Utilities/sformat.fs +++ b/src/Compiler/Utilities/sformat.fs @@ -632,7 +632,8 @@ module Display = Breaks(next + 1, outer, stack) let popBreak (Breaks (next, outer, stack)) = - if next = 0 then raise (Failure "popBreak: underflow") + if next = 0 then + raise (Failure "popBreak: underflow") let topBroke = stack[next - 1] < 0 @@ -1312,12 +1313,14 @@ module Display = let possibleKeyValueL v = let tyv = v.GetType() - if word = "map" - && (match v with - | null -> false - | _ -> true) - && tyv.IsGenericType - && tyv.GetGenericTypeDefinition() = typedefof> then + if + word = "map" + && (match v with + | null -> false + | _ -> true) + && tyv.IsGenericType + && tyv.GetGenericTypeDefinition() = typedefof> + then nestedObjL depthLim Precedence.BracketIfTuple @@ -1529,8 +1532,10 @@ module Display = "-infinity" elif Double.IsPositiveInfinity(d) then "infinity" - elif opts.FloatingPointFormat[0] = 'g' - && String.forall (fun c -> Char.IsDigit(c) || c = '-') s then + elif + opts.FloatingPointFormat[0] = 'g' + && String.forall (fun c -> Char.IsDigit(c) || c = '-') s + then s + ".0" else s @@ -1545,11 +1550,13 @@ module Display = "-infinity" elif Single.IsPositiveInfinity(d) then "infinity" - elif opts.FloatingPointFormat.Length >= 1 - && opts.FloatingPointFormat[0] = 'g' - && float32 (Int32.MinValue) < d - && d < float32 (Int32.MaxValue) - && float32 (int32 (d)) = d then + elif + opts.FloatingPointFormat.Length >= 1 + && opts.FloatingPointFormat[0] = 'g' + && float32 (Int32.MinValue) < d + && d < float32 (Int32.MaxValue) + && float32 (int32 (d)) = d + then (Convert.ToInt32 d).ToString(opts.FormatProvider) + ".0" else d.ToString(opts.FloatingPointFormat, opts.FormatProvider)) diff --git a/src/FSharp.Build/FSharpEmbedResXSource.fs b/src/FSharp.Build/FSharpEmbedResXSource.fs index 39d44f052eb..4b34660b2a8 100644 --- a/src/FSharp.Build/FSharpEmbedResXSource.fs +++ b/src/FSharp.Build/FSharpEmbedResXSource.fs @@ -41,9 +41,11 @@ module internal {1} = let sourcePath = Path.Combine(_outputPath, justFileName + ".fs") // simple up-to-date check - if File.Exists(resx) - && File.Exists(sourcePath) - && File.GetLastWriteTimeUtc(resx) <= File.GetLastWriteTimeUtc(sourcePath) then + if + File.Exists(resx) + && File.Exists(sourcePath) + && File.GetLastWriteTimeUtc(resx) <= File.GetLastWriteTimeUtc(sourcePath) + then printMessage (sprintf "Skipping generation: '%s' since it is up-to-date." sourcePath) Some(sourcePath) else diff --git a/src/FSharp.Core/QueryExtensions.fs b/src/FSharp.Core/QueryExtensions.fs index f9d0ffd72fb..220618ae563 100644 --- a/src/FSharp.Core/QueryExtensions.fs +++ b/src/FSharp.Core/QueryExtensions.fs @@ -212,7 +212,7 @@ module internal Adapters = type ConversionDescription = | TupleConv of ConversionDescription list | RecordConv of Type * ConversionDescription list - | GroupingConv (* origKeyType: *) of Type (* origElemType: *) * Type * ConversionDescription + | GroupingConv (* origKeyType: *) of Type (* origElemType: *) * Type * ConversionDescription | SeqConv of ConversionDescription | NoConv diff --git a/src/FSharp.Core/array.fs b/src/FSharp.Core/array.fs index 1dff8103bda..8c2fa8470fa 100644 --- a/src/FSharp.Core/array.fs +++ b/src/FSharp.Core/array.fs @@ -17,7 +17,8 @@ open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators module Array = let inline checkNonNull argName arg = - if isNull arg then nullArg argName + if isNull arg then + nullArg argName let inline indexNotFound () = raise (KeyNotFoundException(SR.GetString(SR.keyNotFoundAlt))) @@ -1601,7 +1602,9 @@ module Array = for i = 1 to array.Length - 1 do let curr = array.[i] - if curr < acc then acc <- curr + + if curr < acc then + acc <- curr acc @@ -1636,7 +1639,9 @@ module Array = for i = 1 to array.Length - 1 do let curr = array.[i] - if curr > acc then acc <- curr + + if curr > acc then + acc <- curr acc diff --git a/src/FSharp.Core/async.fs b/src/FSharp.Core/async.fs index 46cd93a84ee..e907040c94c 100644 --- a/src/FSharp.Core/async.fs +++ b/src/FSharp.Core/async.fs @@ -412,7 +412,8 @@ type AsyncActivation<'T>(contents: AsyncActivationContents<'T>) = ok <- true res finally - if not ok then ctxt.OnExceptionRaised() + if not ok then + ctxt.OnExceptionRaised() member ctxt.PostWithTrampoline (syncCtxt: SynchronizationContext) (f: unit -> AsyncReturn) = let holder = contents.aux.trampolineHolder @@ -486,7 +487,8 @@ module AsyncPrimitives = result <- userCode arg ok <- true finally - if not ok then ctxt.OnExceptionRaised() + if not ok then + ctxt.OnExceptionRaised() if ok then AsyncActivation<'T>.HijackCheckThenCall ctxt ctxt.cont result @@ -508,7 +510,8 @@ module AsyncPrimitives = result <- part2 result1 ok <- true finally - if not ok then ctxt.OnExceptionRaised() + if not ok then + ctxt.OnExceptionRaised() if ok then Invoke result ctxt @@ -525,7 +528,8 @@ module AsyncPrimitives = res <- userCode result1 ok <- true finally - if not ok then ctxt.OnExceptionRaised() + if not ok then + ctxt.OnExceptionRaised() if ok then res.Invoke ctxt else fake () @@ -543,7 +547,8 @@ module AsyncPrimitives = resOpt <- filterFunction (edi.GetAssociatedSourceException()) ok <- true finally - if not ok then ctxt.OnExceptionRaised() + if not ok then + ctxt.OnExceptionRaised() if ok then match resOpt with @@ -990,7 +995,9 @@ module AsyncPrimitives = else // In this case the ResultCell has already been disposed, e.g. due to a timeout. // The result is dropped on the floor. - if disposed then + if + disposed + then [] else result <- Some res diff --git a/src/FSharp.Core/eventmodule.fs b/src/FSharp.Core/eventmodule.fs index cd9dc68a76d..fc3c2eabd64 100644 --- a/src/FSharp.Core/eventmodule.fs +++ b/src/FSharp.Core/eventmodule.fs @@ -22,7 +22,11 @@ module Event = [] let filter predicate (sourceEvent: IEvent<'Delegate, 'T>) = let ev = new Event<_>() - sourceEvent.Add(fun x -> if predicate x then ev.Trigger x) + + sourceEvent.Add(fun x -> + if predicate x then + ev.Trigger x) + ev.Publish [] diff --git a/src/FSharp.Core/list.fs b/src/FSharp.Core/list.fs index fbf8089610d..e0dff3d7adb 100644 --- a/src/FSharp.Core/list.fs +++ b/src/FSharp.Core/list.fs @@ -15,7 +15,8 @@ open System.Collections.Generic module List = let inline checkNonNull argName arg = - if isNull arg then nullArg argName + if isNull arg then + nullArg argName let inline indexNotFound () = raise (KeyNotFoundException(SR.GetString(SR.keyNotFoundAlt))) @@ -742,7 +743,8 @@ module List = let mutable acc = h for x in t do - if x > acc then acc <- x + if x > acc then + acc <- x acc @@ -771,7 +773,8 @@ module List = let mutable acc = h for x in t do - if x < acc then acc <- x + if x < acc then + acc <- x acc @@ -910,7 +913,9 @@ module List = match curr with | [] -> invalidArg "index" "index must be within bounds of the list" | h :: t -> - if i < index then coll.Add(h) //items before index we keep + if i < index then + coll.Add(h) //items before index we keep + curr <- t i <- i + 1 diff --git a/src/FSharp.Core/map.fs b/src/FSharp.Core/map.fs index 0d510239f32..9fad005450e 100644 --- a/src/FSharp.Core/map.fs +++ b/src/FSharp.Core/map.fs @@ -1040,7 +1040,8 @@ and KeyCollection<'Key, 'Value when 'Key: comparison>(parent: Map<'Key, 'Value>) parent.ContainsKey x member _.CopyTo(arr, index) = - if isNull arr then nullArg "arr" + if isNull arr then + nullArg "arr" if index < 0 then invalidArg "index" "index must be positive" @@ -1090,7 +1091,8 @@ and ValueCollection<'Key, 'Value when 'Key: comparison>(parent: Map<'Key, 'Value parent.Exists(fun _ value -> Unchecked.equals value x) member _.CopyTo(arr, index) = - if isNull arr then nullArg "arr" + if isNull arr then + nullArg "arr" if index < 0 then invalidArg "index" "index must be positive" diff --git a/src/FSharp.Core/observable.fs b/src/FSharp.Core/observable.fs index d1bcd160313..eb34c62c850 100644 --- a/src/FSharp.Core/observable.fs +++ b/src/FSharp.Core/observable.fs @@ -12,11 +12,12 @@ open Microsoft.FSharp.Control module Observable = let inline protect f succeed fail = - match (try - Choice1Of2(f ()) - with e -> - Choice2Of2 e) - with + match + (try + Choice1Of2(f ()) + with e -> + Choice2Of2 e) + with | Choice1Of2 x -> (succeed x) | Choice2Of2 e -> (fail e) @@ -34,7 +35,8 @@ module Observable = interface IObserver<'T> with member x.OnNext value = - if not stopped then x.Next value + if not stopped then + x.Next value member x.OnError e = if not stopped then @@ -166,7 +168,8 @@ module Observable = source1.Subscribe { new IObserver<'T> with member x.OnNext(v) = - if not stopped then observer.OnNext v + if not stopped then + observer.OnNext v member x.OnError(e) = if not stopped then @@ -186,7 +189,8 @@ module Observable = source2.Subscribe { new IObserver<'T> with member x.OnNext(v) = - if not stopped then observer.OnNext v + if not stopped then + observer.OnNext v member x.OnError(e) = if not stopped then diff --git a/src/FSharp.Core/quotations.fs b/src/FSharp.Core/quotations.fs index a309d9c1816..54ca7e2e3c4 100644 --- a/src/FSharp.Core/quotations.fs +++ b/src/FSharp.Core/quotations.fs @@ -1469,9 +1469,11 @@ module Patterns = else // If a known-number-of-arguments-including-object-argument has been given then check that - if (match knownArgCount with - | ValueNone -> false - | ValueSome n -> n <> (if methInfo.IsStatic then 0 else 1) + nargTs) then + if + (match knownArgCount with + | ValueNone -> false + | ValueSome n -> n <> (if methInfo.IsStatic then 0 else 1) + nargTs) + then false else diff --git a/src/FSharp.Core/reflect.fs b/src/FSharp.Core/reflect.fs index 4bc089765fb..76dbb87c490 100644 --- a/src/FSharp.Core/reflect.fs +++ b/src/FSharp.Core/reflect.fs @@ -1172,10 +1172,12 @@ type FSharpType = // No assembly passed therefore just get framework local version of Tuple let asm = typeof.Assembly - if types - |> Array.exists (function - | null -> true - | _ -> false) then + if + types + |> Array.exists (function + | null -> true + | _ -> false) + then invalidArg "types" (SR.GetString(SR.nullsNotAllowedInArray)) mkTupleType false asm types @@ -1183,10 +1185,12 @@ type FSharpType = static member MakeTupleType(asm: Assembly, types: Type[]) = checkNonNull "types" types - if types - |> Array.exists (function - | null -> true - | _ -> false) then + if + types + |> Array.exists (function + | null -> true + | _ -> false) + then invalidArg "types" (SR.GetString(SR.nullsNotAllowedInArray)) mkTupleType false asm types @@ -1194,10 +1198,12 @@ type FSharpType = static member MakeStructTupleType(asm: Assembly, types: Type[]) = checkNonNull "types" types - if types - |> Array.exists (function - | null -> true - | _ -> false) then + if + types + |> Array.exists (function + | null -> true + | _ -> false) + then invalidArg "types" (SR.GetString(SR.nullsNotAllowedInArray)) mkTupleType true asm types diff --git a/src/FSharp.Core/seq.fs b/src/FSharp.Core/seq.fs index b04ecfa3ec8..18d89ce07f7 100644 --- a/src/FSharp.Core/seq.fs +++ b/src/FSharp.Core/seq.fs @@ -214,7 +214,9 @@ module Internal = member _.Current = box (get ()) member _.MoveNext() = - if not started then started <- true + if not started then + started <- true + curr <- None while (curr.IsNone && e.MoveNext()) do @@ -244,7 +246,9 @@ module Internal = member _.MoveNext() = let rec next () = - if not started then started <- true + if not started then + started <- true + e.MoveNext() && (f e.Current || next ()) next () @@ -304,7 +308,8 @@ module Internal = current <- (Unchecked.defaultof<_>) // cache node unprimed, initialised on demand. let getCurrent () = - if index = unstarted then notStarted () + if index = unstarted then + notStarted () if index = completed then alreadyFinished () @@ -507,7 +512,8 @@ module Internal = interface System.IDisposable with member _.Dispose() = - if not finished then disposeG g + if not finished then + disposeG g // Internal type, used to optimize Enumerator/Generator chains type LazyGeneratorWrappingEnumerator<'T>(e: IEnumerator<'T>) = @@ -791,7 +797,9 @@ module Seq = while (Option.isNone res && e.MoveNext()) do let c = e.Current - if predicate c then res <- Some c + + if predicate c then + res <- Some c res @@ -1316,7 +1324,8 @@ module Seq = let hashSet = HashSet<'T>(HashIdentity.Structural<'T>) for v in source do - if hashSet.Add v then yield v + if hashSet.Add v then + yield v } [] @@ -1484,7 +1493,9 @@ module Seq = while e.MoveNext() do let curr = e.Current - if curr < acc then acc <- curr + + if curr < acc then + acc <- curr acc @@ -1522,7 +1533,9 @@ module Seq = while e.MoveNext() do let curr = e.Current - if curr > acc then acc <- curr + + if curr > acc then + acc <- curr acc @@ -1593,8 +1606,10 @@ module Seq = let mutable ok = false while e.MoveNext() do - if (latest <- e.Current - (ok || not (predicate latest))) then + if + (latest <- e.Current + (ok || not (predicate latest))) + then ok <- true yield latest } @@ -1741,11 +1756,15 @@ module Seq = if e.MoveNext() then let cached = HashSet(itemsToExclude, HashIdentity.Structural) let next = e.Current - if cached.Add next then yield next + + if cached.Add next then + yield next while e.MoveNext() do let next = e.Current - if cached.Add next then yield next + + if cached.Add next then + yield next } [] @@ -1794,7 +1813,9 @@ module Seq = let mutable i = 0 for item in source do - if i <> index then yield item + if i <> index then + yield item + i <- i + 1 if i <= index then @@ -1848,11 +1869,14 @@ module Seq = let mutable i = 0 for item in source do - if i = index then yield value + if i = index then + yield value + yield item i <- i + 1 - if i = index then yield value + if i = index then + yield value if i < index then invalidArg "index" "index must be within bounds of the array" @@ -1867,11 +1891,14 @@ module Seq = let mutable i = 0 for item in source do - if i = index then yield! values + if i = index then + yield! values + yield item i <- i + 1 - if i = index then yield! values // support inserting at the end + if i = index then + yield! values // support inserting at the end if i < index then invalidArg "index" "index must be within bounds of the array" diff --git a/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Utilities.fs b/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Utilities.fs index 6d2a990efc2..8a1b526837a 100644 --- a/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Utilities.fs +++ b/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Utilities.fs @@ -308,7 +308,9 @@ module internal Utilities = // Use enabled feeds only (see NuGet.Commands.ListSourceRunner.Run) and strip off the flags. if source.Length > 0 && source.[0] = 'E' then let pos = source.IndexOf(" ") - if pos >= 0 then "i", source.Substring(pos).Trim() + + if pos >= 0 then + "i", source.Substring(pos).Trim() } let computeSha256HashOfBytes (bytes: byte[]) : byte[] = SHA256.Create().ComputeHash(bytes) diff --git a/src/fsc/fscmain.fs b/src/fsc/fscmain.fs index 9eae6cba0e4..ebdf21af60d 100644 --- a/src/fsc/fscmain.fs +++ b/src/fsc/fscmain.fs @@ -26,8 +26,10 @@ let main (argv) = let compilerName = // the 64 bit desktop version of the compiler is name fscAnyCpu.exe, all others are fsc.exe - if Environment.Is64BitProcess - && typeof.Assembly.GetName().Name <> "System.Private.CoreLib" then + if + Environment.Is64BitProcess + && typeof.Assembly.GetName().Name <> "System.Private.CoreLib" + then "fscAnyCpu.exe" else "fsc.exe" diff --git a/src/fsi/console.fs b/src/fsi/console.fs index 05f242990b2..b64849394d3 100644 --- a/src/fsi/console.fs +++ b/src/fsi/console.fs @@ -247,8 +247,10 @@ type internal ReadLineConsole() = checkLeftEdge false let writeChar (c) = - if Console.CursorTop = Console.BufferHeight - 1 - && Console.CursorLeft = Console.BufferWidth - 1 then + if + Console.CursorTop = Console.BufferHeight - 1 + && Console.CursorLeft = Console.BufferWidth - 1 + then //printf "bottom right!\n" anchor <- { anchor with top = (anchor).top - 1 } @@ -278,7 +280,8 @@ type internal ReadLineConsole() = let mutable position = -1 for i = 0 to input.Length - 1 do - if (i = curr) then position <- output.Length + if (i = curr) then + position <- output.Length let c = input.Chars(i) @@ -287,7 +290,8 @@ type internal ReadLineConsole() = else output.Append(c) |> ignore - if (curr = input.Length) then position <- output.Length + if (curr = input.Length) then + position <- output.Length // render the current text, computing a new value for "rendered" let old_rendered = rendered @@ -419,7 +423,8 @@ type internal ReadLineConsole() = if (line = "\x1A") then null else - if (line.Length > 0) then history.AddLast(line) + if (line.Length > 0) then + history.AddLast(line) line diff --git a/src/fsi/fsimain.fs b/src/fsi/fsimain.fs index b94a152c171..ae6513f00cc 100644 --- a/src/fsi/fsimain.fs +++ b/src/fsi/fsimain.fs @@ -411,8 +411,10 @@ let MainMain argv = || x = "/shadowcopyreferences+" || x = "--shadowcopyreferences+") - if AppDomain.CurrentDomain.IsDefaultAppDomain() - && argv |> Array.exists isShadowCopy then + if + AppDomain.CurrentDomain.IsDefaultAppDomain() + && argv |> Array.exists isShadowCopy + then let setupInformation = AppDomain.CurrentDomain.SetupInformation setupInformation.ShadowCopyFiles <- "true" let helper = AppDomain.CreateDomain("FSI_Domain", null, setupInformation) From b8aaf2d272ef537c4da40938147e416d376bba29 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 11 Jul 2022 20:18:51 +0100 Subject: [PATCH 08/11] Allow lower-case DU cases when RequireQualifiedAccess is specified (#13432) * Allow lower-case DU cases when RequireQualifiedAccess is specified * Fix PR suggestions and Add more testing * Protect feature under preview version * Add a NotUpperCaseConstructorWithoutRQA warning to be raised in lang version preview * Fix formatting --- src/Compiler/Checking/CheckDeclarations.fs | 30 ++++++---- src/Compiler/Checking/CheckDeclarations.fsi | 2 + src/Compiler/Driver/CompilerDiagnostics.fs | 5 ++ src/Compiler/FSComp.txt | 1 + src/Compiler/FSStrings.resx | 3 + src/Compiler/Facilities/LanguageFeatures.fs | 3 + src/Compiler/Facilities/LanguageFeatures.fsi | 1 + src/Compiler/xlf/FSComp.txt.cs.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.de.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.es.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.fr.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.it.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.ja.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.ko.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.pl.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.ru.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.tr.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 ++ src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 ++ src/Compiler/xlf/FSStrings.cs.xlf | 5 ++ src/Compiler/xlf/FSStrings.de.xlf | 5 ++ src/Compiler/xlf/FSStrings.es.xlf | 5 ++ src/Compiler/xlf/FSStrings.fr.xlf | 5 ++ src/Compiler/xlf/FSStrings.it.xlf | 5 ++ src/Compiler/xlf/FSStrings.ja.xlf | 5 ++ src/Compiler/xlf/FSStrings.ko.xlf | 5 ++ src/Compiler/xlf/FSStrings.pl.xlf | 5 ++ src/Compiler/xlf/FSStrings.pt-BR.xlf | 5 ++ src/Compiler/xlf/FSStrings.ru.xlf | 5 ++ src/Compiler/xlf/FSStrings.tr.xlf | 5 ++ src/Compiler/xlf/FSStrings.zh-Hans.xlf | 5 ++ src/Compiler/xlf/FSStrings.zh-Hant.xlf | 5 ++ .../E_LowercaseWhenRequireQualifiedAccess.fsx | 22 +++++++ .../LowercaseWhenRequireQualifiedAccess.fsx | 44 ++++++++++++++ .../Conformance/UnionTypes/UnionTypes.fs | 58 +++++++++++++++++++ 36 files changed, 289 insertions(+), 10 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/E_LowercaseWhenRequireQualifiedAccess.fsx create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/LowercaseWhenRequireQualifiedAccess.fsx diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 9fd052bdd4b..cc7de71eceb 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -378,6 +378,8 @@ let ImplicitlyOpenOwnNamespace tcSink g amap scopem enclosingNamespacePath (env: exception NotUpperCaseConstructor of range: range +exception NotUpperCaseConstructorWithoutRQA of range: range + let CheckNamespaceModuleOrTypeName (g: TcGlobals) (id: Ident) = // type names '[]' etc. are used in fslib if not g.compilingFSharpCore && id.idText.IndexOfAny IllegalCharactersInTypeAndNamespaceNames <> -1 then @@ -453,7 +455,7 @@ module TcRecdUnionAndEnumDeclarations = // Bind other elements of type definitions (constructors etc.) //------------------------------------------------------------------------- - let CheckUnionCaseName (cenv: cenv) (id: Ident) = + let CheckUnionCaseName (cenv: cenv) (id: Ident) hasRQAAttribute = let g = cenv.g let name = id.idText if name = "Tags" then @@ -461,8 +463,13 @@ module TcRecdUnionAndEnumDeclarations = CheckNamespaceModuleOrTypeName g id - if not (String.isLeadingIdentifierCharacterUpperCase name) && name <> opNameCons && name <> opNameNil then - errorR(NotUpperCaseConstructor(id.idRange)) + if g.langVersion.SupportsFeature(LanguageFeature.LowercaseDUWhenRequireQualifiedAccess) then + + if not (String.isLeadingIdentifierCharacterUpperCase name) && not hasRQAAttribute && name <> opNameCons && name <> opNameNil then + errorR(NotUpperCaseConstructorWithoutRQA(id.idRange)) + else + if not (String.isLeadingIdentifierCharacterUpperCase name) && name <> opNameCons && name <> opNameNil then + errorR(NotUpperCaseConstructor(id.idRange)) let ValidateFieldNames (synFields: SynField list, tastFields: RecdField list) = let seen = Dictionary() @@ -479,13 +486,13 @@ module TcRecdUnionAndEnumDeclarations = | _ -> seen.Add(f.LogicalName, sf)) - let TcUnionCaseDecl (cenv: cenv) env parent thisTy thisTyInst tpenv (SynUnionCase(Attributes synAttrs, SynIdent(id, _), args, xmldoc, vis, m, _)) = + let TcUnionCaseDecl (cenv: cenv) env parent thisTy thisTyInst tpenv hasRQAAttribute (SynUnionCase(Attributes synAttrs, SynIdent(id, _), args, xmldoc, vis, m, _)) = let g = cenv.g let attrs = TcAttributes cenv env AttributeTargets.UnionCaseDecl synAttrs // the attributes of a union case decl get attached to the generated "static factory" method let vis, _ = ComputeAccessAndCompPath env None m vis None parent let vis = CombineReprAccess parent vis - CheckUnionCaseName cenv id + CheckUnionCaseName cenv id hasRQAAttribute let rfields, recordTy = match args with @@ -526,8 +533,8 @@ module TcRecdUnionAndEnumDeclarations = let xmlDoc = xmldoc.ToXmlDoc(true, Some names) Construct.NewUnionCase id rfields recordTy attrs xmlDoc vis - let TcUnionCaseDecls cenv env parent (thisTy: TType) thisTyInst tpenv unionCases = - let unionCasesR = unionCases |> List.map (TcUnionCaseDecl cenv env parent thisTy thisTyInst tpenv) + let TcUnionCaseDecls (cenv: cenv) env (parent: ParentRef) (thisTy: TType) (thisTyInst: TypeInst) hasRQAAttribute tpenv unionCases = + let unionCasesR = unionCases |> List.map (TcUnionCaseDecl cenv env parent thisTy thisTyInst tpenv hasRQAAttribute) unionCasesR |> CheckDuplicates (fun uc -> uc.Id) "union case" let TcEnumDecl cenv env parent thisTy fieldTy (SynEnumCase(attributes=Attributes synAttrs; ident= SynIdent(id,_); value=v; xmlDoc=xmldoc; range=m)) = @@ -3188,7 +3195,9 @@ module EstablishTypeDefinitionCores = structLayoutAttributeCheck false noAllowNullLiteralAttributeCheck() - TcRecdUnionAndEnumDeclarations.CheckUnionCaseName cenv unionCaseName + + let hasRQAAttribute = HasFSharpAttribute cenv.g cenv.g.attrib_RequireQualifiedAccessAttribute tycon.Attribs + TcRecdUnionAndEnumDeclarations.CheckUnionCaseName cenv unionCaseName hasRQAAttribute let unionCase = Construct.NewUnionCase unionCaseName [] thisTy [] XmlDoc.Empty tycon.Accessibility writeFakeUnionCtorsToSink [ unionCase ] Construct.MakeUnionRepr [ unionCase ], None, NoSafeInitInfo @@ -3219,8 +3228,9 @@ module EstablishTypeDefinitionCores = noAbstractClassAttributeCheck() noAllowNullLiteralAttributeCheck() structLayoutAttributeCheck false - let unionCases = TcRecdUnionAndEnumDeclarations.TcUnionCaseDecls cenv envinner innerParent thisTy thisTyInst tpenv unionCases - + + let hasRQAAttribute = HasFSharpAttribute cenv.g cenv.g.attrib_RequireQualifiedAccessAttribute tycon.Attribs + let unionCases = TcRecdUnionAndEnumDeclarations.TcUnionCaseDecls cenv envinner innerParent thisTy thisTyInst hasRQAAttribute tpenv unionCases if tycon.IsStructRecordOrUnionTycon && unionCases.Length > 1 then let fieldNames = [ for uc in unionCases do for ft in uc.FieldTable.TrueInstanceFieldsAsList do yield ft.LogicalName ] if fieldNames |> List.distinct |> List.length <> fieldNames.Length then diff --git a/src/Compiler/Checking/CheckDeclarations.fsi b/src/Compiler/Checking/CheckDeclarations.fsi index c4590557ede..631e9fb5812 100644 --- a/src/Compiler/Checking/CheckDeclarations.fsi +++ b/src/Compiler/Checking/CheckDeclarations.fsi @@ -76,3 +76,5 @@ val CheckOneSigFile: Cancellable exception NotUpperCaseConstructor of range: range + +exception NotUpperCaseConstructorWithoutRQA of range: range diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index fba0a064091..f3537b7bbc0 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -124,6 +124,7 @@ let GetRangeOfDiagnostic (diagnostic: PhasedDiagnostic) = | LetRecCheckedAtRuntime m | UpperCaseIdentifierInPattern m | NotUpperCaseConstructor m + | NotUpperCaseConstructorWithoutRQA m | RecursiveUseCheckedAtRuntime (_, _, m) | LetRecEvaluatedOutOfOrder (_, _, _, m) | DiagnosticWithText (_, _, m) @@ -270,6 +271,7 @@ let GetDiagnosticNumber (diagnostic: PhasedDiagnostic) = | UseOfAddressOfOperator _ -> 51 | DefensiveCopyWarning _ -> 52 | NotUpperCaseConstructor _ -> 53 + | NotUpperCaseConstructorWithoutRQA _ -> 53 | TypeIsImplicitlyAbstract _ -> 54 // 55 cannot be reused | DeprecatedThreadStaticBindingWarning _ -> 56 @@ -435,6 +437,7 @@ let ErrorFromApplyingDefault2E () = Message("ErrorFromApplyingDefault2", "") let ErrorsFromAddingSubsumptionConstraintE () = Message("ErrorsFromAddingSubsumptionConstraint", "%s%s%s") let UpperCaseIdentifierInPatternE () = Message("UpperCaseIdentifierInPattern", "") let NotUpperCaseConstructorE () = Message("NotUpperCaseConstructor", "") +let NotUpperCaseConstructorWithoutRQAE () = Message("NotUpperCaseConstructorWithoutRQA", "") let FunctionExpectedE () = Message("FunctionExpected", "") let BakedInMemberConstraintNameE () = Message("BakedInMemberConstraintName", "%s") let BadEventTransformationE () = Message("BadEventTransformation", "") @@ -771,6 +774,8 @@ let OutputPhasedErrorR (os: StringBuilder) (diagnostic: PhasedDiagnostic) (canSu | NotUpperCaseConstructor _ -> os.AppendString(NotUpperCaseConstructorE().Format) + | NotUpperCaseConstructorWithoutRQA _ -> os.AppendString(NotUpperCaseConstructorWithoutRQAE().Format) + | ErrorFromAddingConstraint (_, e, _) -> OutputExceptionR os e #if !NO_TYPEPROVIDERS diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index a6ce206cc8f..97e24679878 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1543,6 +1543,7 @@ featureStructActivePattern,"struct representation for active patterns" featureRelaxWhitespace2,"whitespace relaxation v2" featureReallyLongList,"list literals of any size" featureErrorOnDeprecatedRequireQualifiedAccess,"give error on deprecated access of construct with RequireQualifiedAccess attribute" +featureLowercaseDUWhenRequireQualifiedAccess,"Allow lowercase DU when RequireQualifiedAccess attribute" 3353,fsiInvalidDirective,"Invalid directive '#%s %s'" 3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." diff --git a/src/Compiler/FSStrings.resx b/src/Compiler/FSStrings.resx index bf1c66b0f29..51f172fbbea 100644 --- a/src/Compiler/FSStrings.resx +++ b/src/Compiler/FSStrings.resx @@ -1107,4 +1107,7 @@ internal error: {0} + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + \ No newline at end of file diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index a0033a5d2b7..77b93032baa 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -49,6 +49,7 @@ type LanguageFeature = | DelegateTypeNameResolutionFix | ReallyLongLists | ErrorOnDeprecatedRequireQualifiedAccess + | LowercaseDUWhenRequireQualifiedAccess /// LanguageVersion management type LanguageVersion(versionText) = @@ -111,6 +112,7 @@ type LanguageVersion(versionText) = LanguageFeature.BetterExceptionPrinting, previewVersion LanguageFeature.ReallyLongLists, previewVersion LanguageFeature.ErrorOnDeprecatedRequireQualifiedAccess, previewVersion + LanguageFeature.LowercaseDUWhenRequireQualifiedAccess, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -210,6 +212,7 @@ type LanguageVersion(versionText) = | LanguageFeature.DelegateTypeNameResolutionFix -> FSComp.SR.featureDelegateTypeNameResolutionFix () | LanguageFeature.ReallyLongLists -> FSComp.SR.featureReallyLongList () | LanguageFeature.ErrorOnDeprecatedRequireQualifiedAccess -> FSComp.SR.featureErrorOnDeprecatedRequireQualifiedAccess () + | LanguageFeature.LowercaseDUWhenRequireQualifiedAccess -> FSComp.SR.featureLowercaseDUWhenRequireQualifiedAccess () /// Get a version string associated with the given feature. member _.GetFeatureVersionString feature = diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index ec884903b49..8227c947c77 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -39,6 +39,7 @@ type LanguageFeature = | DelegateTypeNameResolutionFix | ReallyLongLists | ErrorOnDeprecatedRequireQualifiedAccess + | LowercaseDUWhenRequireQualifiedAccess /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 2982b373922..f006f4b4879 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -192,6 +192,11 @@ rozhraní s vícenásobným obecným vytvářením instancí + + Allow lowercase DU when RequireQualifiedAccess attribute + Allow lowercase DU when RequireQualifiedAccess attribute + + ML compatibility revisions Revize kompatibility ML diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index cd9d6d81bb8..bcff666cca2 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -192,6 +192,11 @@ Schnittstellen mit mehrfacher generischer Instanziierung + + Allow lowercase DU when RequireQualifiedAccess attribute + Allow lowercase DU when RequireQualifiedAccess attribute + + ML compatibility revisions ML-Kompatibilitätsrevisionen diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index f833bc6e76c..f0b34cd199e 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -192,6 +192,11 @@ interfaces con creación de instancias genéricas múltiples + + Allow lowercase DU when RequireQualifiedAccess attribute + Allow lowercase DU when RequireQualifiedAccess attribute + + ML compatibility revisions Revisiones de compatibilidad de ML diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index c949833a13a..e1faaa3ee52 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -192,6 +192,11 @@ interfaces avec plusieurs instanciations génériques + + Allow lowercase DU when RequireQualifiedAccess attribute + Allow lowercase DU when RequireQualifiedAccess attribute + + ML compatibility revisions Réviseurs de compatibilité ML diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index a9b2e133bde..bc3b6d77268 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -192,6 +192,11 @@ interfacce con più creazioni di istanze generiche + + Allow lowercase DU when RequireQualifiedAccess attribute + Allow lowercase DU when RequireQualifiedAccess attribute + + ML compatibility revisions Revisioni della compatibilità di Ml diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index d0637747c7a..f82dbf9c798 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -192,6 +192,11 @@ 複数のジェネリックのインスタンス化を含むインターフェイス + + Allow lowercase DU when RequireQualifiedAccess attribute + Allow lowercase DU when RequireQualifiedAccess attribute + + ML compatibility revisions ML 互換性のリビジョン diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index fbbfdfbf306..1095e6c1729 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -192,6 +192,11 @@ 여러 제네릭 인스턴스화가 포함된 인터페이스 + + Allow lowercase DU when RequireQualifiedAccess attribute + Allow lowercase DU when RequireQualifiedAccess attribute + + ML compatibility revisions ML 호환성 개정 diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index fbfb4f7e730..e5ad0012774 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -192,6 +192,11 @@ interfejsy z wieloma ogólnymi wystąpieniami + + Allow lowercase DU when RequireQualifiedAccess attribute + Allow lowercase DU when RequireQualifiedAccess attribute + + ML compatibility revisions Poprawki dotyczące zgodności Machine Learning diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 83b76374d27..35f58279210 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -192,6 +192,11 @@ interfaces com várias instanciações genéricas + + Allow lowercase DU when RequireQualifiedAccess attribute + Allow lowercase DU when RequireQualifiedAccess attribute + + ML compatibility revisions Revisões de compatibilidade de ML diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 93db1f6740a..d6d6e210791 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -192,6 +192,11 @@ интерфейсы с множественным универсальным созданием экземпляра + + Allow lowercase DU when RequireQualifiedAccess attribute + Allow lowercase DU when RequireQualifiedAccess attribute + + ML compatibility revisions Редакции совместимости ML diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index acff017e25a..5440ee40f47 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -192,6 +192,11 @@ birden çok genel örnek oluşturma içeren arabirimler + + Allow lowercase DU when RequireQualifiedAccess attribute + Allow lowercase DU when RequireQualifiedAccess attribute + + ML compatibility revisions ML uyumluluk düzeltmeleri diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 778f26de5e3..c9f007f023c 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -192,6 +192,11 @@ 具有多个泛型实例化的接口 + + Allow lowercase DU when RequireQualifiedAccess attribute + Allow lowercase DU when RequireQualifiedAccess attribute + + ML compatibility revisions ML 兼容性修订 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 81e0c44f38b..d9ad22c51f4 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -192,6 +192,11 @@ 具有多個泛型具現化的介面 + + Allow lowercase DU when RequireQualifiedAccess attribute + Allow lowercase DU when RequireQualifiedAccess attribute + + ML compatibility revisions ML 相容性修訂 diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf index 924659eb22a..849a9018ef5 100644 --- a/src/Compiler/xlf/FSStrings.cs.xlf +++ b/src/Compiler/xlf/FSStrings.cs.xlf @@ -7,6 +7,11 @@ Nejméně jedna informační zpráva v načteném souboru\n + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + symbol '..^' symbol ..^ diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf index 9462806409e..79176e0e2f1 100644 --- a/src/Compiler/xlf/FSStrings.de.xlf +++ b/src/Compiler/xlf/FSStrings.de.xlf @@ -7,6 +7,11 @@ Mindestens eine Informationsmeldung in der geladenen Datei.\n + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + symbol '..^' Symbol "..^" diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf index b4b8b4531e4..8b09a7c5903 100644 --- a/src/Compiler/xlf/FSStrings.es.xlf +++ b/src/Compiler/xlf/FSStrings.es.xlf @@ -7,6 +7,11 @@ Uno o más mensajes informativos en el archivo cargado.\n + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + symbol '..^' símbolo "..^" diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf index 53e4eb6cff4..f88d8e7182b 100644 --- a/src/Compiler/xlf/FSStrings.fr.xlf +++ b/src/Compiler/xlf/FSStrings.fr.xlf @@ -7,6 +7,11 @@ Un ou plusieurs messages d’information dans le fichier chargé.\n + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + symbol '..^' symbole '..^' diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf index d8cf6e9c21e..e46a3cb54d6 100644 --- a/src/Compiler/xlf/FSStrings.it.xlf +++ b/src/Compiler/xlf/FSStrings.it.xlf @@ -7,6 +7,11 @@ Uno o più messaggi informativi nel file caricato.\n + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + symbol '..^' simbolo '..^' diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf index ad32096733b..b0a149427b1 100644 --- a/src/Compiler/xlf/FSStrings.ja.xlf +++ b/src/Compiler/xlf/FSStrings.ja.xlf @@ -7,6 +7,11 @@ 読み込まれたファイル内の 1 つ以上の情報メッセージ。\n + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + symbol '..^' シンボル '..^' diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf index 8e112d8d28c..da9ee85444d 100644 --- a/src/Compiler/xlf/FSStrings.ko.xlf +++ b/src/Compiler/xlf/FSStrings.ko.xlf @@ -7,6 +7,11 @@ 로드된 파일에 하나 이상의 정보 메시지가 있습니다.\n + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + symbol '..^' 기호 '..^' diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf index fe6c8536f87..f89d330d272 100644 --- a/src/Compiler/xlf/FSStrings.pl.xlf +++ b/src/Compiler/xlf/FSStrings.pl.xlf @@ -7,6 +7,11 @@ Jeden lub więcej komunikatów informacyjnych w załadowanym pliku.\n + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + symbol '..^' symbol „..^” diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf index 8dc8c546ffc..a6f597c97aa 100644 --- a/src/Compiler/xlf/FSStrings.pt-BR.xlf +++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf @@ -7,6 +7,11 @@ Uma ou mais mensagens informativas no arquivo carregado.\n + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + symbol '..^' símbolo '..^' diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf index 6979fe42d9f..310b7437a2e 100644 --- a/src/Compiler/xlf/FSStrings.ru.xlf +++ b/src/Compiler/xlf/FSStrings.ru.xlf @@ -7,6 +7,11 @@ Одно или несколько информационных сообщений в загруженном файле.\n + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + symbol '..^' символ "..^" diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf index 54328fdea3f..c5cbc423360 100644 --- a/src/Compiler/xlf/FSStrings.tr.xlf +++ b/src/Compiler/xlf/FSStrings.tr.xlf @@ -7,6 +7,11 @@ Yüklenen dosyada bir veya daha fazla bilgi mesajı.\n + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + symbol '..^' '..^' sembolü diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf index 95130a6391f..be3604df4bf 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf @@ -7,6 +7,11 @@ 加载文件 .\n 中有一条或多条信息性消息 + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + symbol '..^' 符号 "..^" diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf index 5ff1442b5c3..67e6c25370e 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf @@ -7,6 +7,11 @@ 已載入檔案中的一或多個資訊訊息。\n + + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute + + symbol '..^' 符號 '..^' diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/E_LowercaseWhenRequireQualifiedAccess.fsx b/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/E_LowercaseWhenRequireQualifiedAccess.fsx new file mode 100644 index 00000000000..a7e7a928e36 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/E_LowercaseWhenRequireQualifiedAccess.fsx @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + + + + +type DU1 = | ``not.allowed`` + +type DU2 = ``not.allowed`` + +[] +type DU3 = | ``not.allowed`` + +[] +type DU4 = ``not.allowed`` + +type DU5 = | a + +type DU6 = a + +type du1 = du1 of string + +type du2 = | du2 of string \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/LowercaseWhenRequireQualifiedAccess.fsx b/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/LowercaseWhenRequireQualifiedAccess.fsx new file mode 100644 index 00000000000..e9080c19964 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/LowercaseWhenRequireQualifiedAccess.fsx @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + + + + +[] +type DU1 = + | a + | b + | c + +[] +type DU2 = + | a of int + | B of string + | C + +[] +type DU3 = | a + +[] +type DU4 = a + +[] +type du1 = du1 of string + +[] +type du2 = | du2 of string + +let a = DU1.a +let b = du2.du2 +let c = DU2.a(1) +let d = du2.du2("du2") +let e = du1.du1("du1") + +let f du1 = + match du1 with + | DU1.a -> () + | DU1.b -> () + | DU1.c -> () + +f DU1.c + + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/UnionTypes.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/UnionTypes.fs index 1e27322bfbd..39f4fac3804 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/UnionTypes.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/UnionTypes.fs @@ -509,6 +509,64 @@ module UnionTypes = |> verifyCompileAndRun |> shouldSucceed + //SOURCE=LowercaseWhenRequireQualifiedAccess.fsx # LowercaseWhenRequireQualifiedAccess.fsx + [] + let ``LowercaseWhenRequireQualifiedAccess_fs in langversion 6`` compilation = + compilation + |> withLangVersion60 + |> verifyCompile + |> shouldFail + + //SOURCE=LowercaseWhenRequireQualifiedAccess.fsx # LowercaseWhenRequireQualifiedAccess.fsx + [] + let ``LowercaseWhenRequireQualifiedAccess_fs in preview`` compilation = + compilation + |> withLangVersionPreview + |> verifyCompileAndRun + |> shouldSucceed + + //SOURCE=E_LowercaseWhenRequireQualifiedAccess.fsx # E_LowercaseWhenRequireQualifiedAccess.fsx + [] + let ``E_LowercaseWhenRequireQualifiedAccess_fs in preview`` compilation = + compilation + |> withLangVersionPreview + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 883, Line 6, Col 14, Line 6, Col 29, "Invalid namespace, module, type or union case name"); + (Error 53, Line 6, Col 14, Line 6, Col 29, "Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute"); + (Error 883, Line 8, Col 12, Line 8, Col 27, "Invalid namespace, module, type or union case name"); + (Error 53, Line 8, Col 12, Line 8, Col 27, "Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute"); + (Error 883, Line 11, Col 14, Line 11, Col 29, "Invalid namespace, module, type or union case name"); + (Error 883, Line 14, Col 12, Line 14, Col 27, "Invalid namespace, module, type or union case name"); + (Error 53, Line 16, Col 14, Line 16, Col 15, "Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute"); + (Error 53, Line 18, Col 12, Line 18, Col 13, "Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute"); + (Error 53, Line 20, Col 12, Line 20, Col 15, "Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute"); + (Error 53, Line 22, Col 14, Line 22, Col 17, "Lowercase discriminated union cases are only allowed when using RequireQualifiedAccess attribute") + ] + + //SOURCE=E_LowercaseWhenRequireQualifiedAccess.fsx # E_LowercaseWhenRequireQualifiedAccess.fsx + [] + let ``E_LowercaseWhenRequireQualifiedAccess_fs in langversion 6`` compilation = + compilation + |> withLangVersion60 + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 883, Line 6, Col 14, Line 6, Col 29, "Invalid namespace, module, type or union case name"); + (Error 53, Line 6, Col 14, Line 6, Col 29, "Discriminated union cases and exception labels must be uppercase identifiers"); + (Error 883, Line 8, Col 12, Line 8, Col 27, "Invalid namespace, module, type or union case name"); + (Error 53, Line 8, Col 12, Line 8, Col 27, "Discriminated union cases and exception labels must be uppercase identifiers"); + (Error 883, Line 11, Col 14, Line 11, Col 29, "Invalid namespace, module, type or union case name"); + (Error 53, Line 11, Col 14, Line 11, Col 29, "Discriminated union cases and exception labels must be uppercase identifiers"); + (Error 883, Line 14, Col 12, Line 14, Col 27, "Invalid namespace, module, type or union case name"); + (Error 53, Line 14, Col 12, Line 14, Col 27, "Discriminated union cases and exception labels must be uppercase identifiers"); + (Error 53, Line 16, Col 14, Line 16, Col 15, "Discriminated union cases and exception labels must be uppercase identifiers"); + (Error 53, Line 18, Col 12, Line 18, Col 13, "Discriminated union cases and exception labels must be uppercase identifiers"); + (Error 53, Line 20, Col 12, Line 20, Col 15, "Discriminated union cases and exception labels must be uppercase identifiers"); + (Error 53, Line 22, Col 14, Line 22, Col 17, "Discriminated union cases and exception labels must be uppercase identifiers") + ] + //SOURCE=W_GenericFunctionValuedStaticProp02.fs SCFLAGS="--test:ErrorRanges --warnaserror-" # W_GenericFunctionValuedStaticProp02.fs [] let ``W_GenericFunctionValuedStaticProp02_fs`` compilation = From 0c1eba0671d0edb86e97618e0a7678a7550befe4 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 11 Jul 2022 22:18:35 +0100 Subject: [PATCH 09/11] regularize some names (#13489) * normalize some names * format code * fix build --- azure-pipelines.yml | 1 + src/Compiler/AbstractIL/ilreflect.fs | 8 +- src/Compiler/AbstractIL/ilx.fs | 2 +- .../Checking/CheckComputationExpressions.fs | 14 +- src/Compiler/Checking/CheckDeclarations.fs | 64 ++-- src/Compiler/Checking/CheckExpressions.fs | 271 ++++++++------- src/Compiler/Checking/CheckExpressions.fsi | 2 +- src/Compiler/Checking/CheckFormatStrings.fs | 16 +- src/Compiler/Checking/CheckPatterns.fs | 54 +-- src/Compiler/Checking/ConstraintSolver.fs | 102 +++--- src/Compiler/Checking/FindUnsolved.fs | 2 +- src/Compiler/Checking/InfoReader.fs | 22 +- src/Compiler/Checking/InfoReader.fsi | 6 +- src/Compiler/Checking/MethodCalls.fs | 181 +++++----- src/Compiler/Checking/MethodOverrides.fs | 16 +- src/Compiler/Checking/MethodOverrides.fsi | 2 +- src/Compiler/Checking/NameResolution.fs | 16 +- src/Compiler/Checking/NicePrint.fs | 179 +++++----- src/Compiler/Checking/NicePrint.fsi | 19 +- .../Checking/PatternMatchCompilation.fs | 24 +- src/Compiler/Checking/PostInferenceChecks.fs | 41 ++- src/Compiler/Checking/QuotationTranslator.fs | 38 +- src/Compiler/Checking/SignatureConformance.fs | 24 +- src/Compiler/Checking/TypeHierarchy.fs | 42 +-- src/Compiler/Checking/TypeRelations.fs | 65 ++-- src/Compiler/Checking/import.fs | 10 +- src/Compiler/Checking/infos.fs | 34 +- src/Compiler/CodeGen/IlxGen.fs | 84 ++--- src/Compiler/Driver/CompilerDiagnostics.fs | 7 +- src/Compiler/Facilities/TextLayoutRender.fs | 2 +- src/Compiler/Interactive/fsi.fs | 6 +- src/Compiler/Optimize/Optimizer.fs | 26 +- src/Compiler/Service/FSharpCheckerResults.fs | 26 +- src/Compiler/Service/ItemKey.fs | 8 +- .../Service/SemanticClassification.fs | 4 +- .../Service/ServiceDeclarationLists.fs | 59 ++-- src/Compiler/Service/ServiceNavigation.fs | 124 +++---- .../Service/ServiceParamInfoLocations.fs | 36 +- src/Compiler/Service/ServiceParsedInputOps.fs | 4 +- src/Compiler/Service/ServiceStructure.fs | 78 ++--- src/Compiler/Symbols/Exprs.fs | 30 +- src/Compiler/Symbols/SymbolHelpers.fs | 12 +- src/Compiler/Symbols/SymbolPatterns.fs | 8 +- src/Compiler/Symbols/Symbols.fs | 45 +-- src/Compiler/SyntaxTree/SyntaxTreeOps.fs | 38 +- src/Compiler/SyntaxTree/SyntaxTreeOps.fsi | 8 +- src/Compiler/TypedTree/TcGlobals.fs | 14 +- src/Compiler/TypedTree/TypedTree.fs | 44 +-- src/Compiler/TypedTree/TypedTree.fsi | 10 +- src/Compiler/TypedTree/TypedTreeBasics.fs | 16 +- src/Compiler/TypedTree/TypedTreeBasics.fsi | 8 +- src/Compiler/TypedTree/TypedTreeOps.fs | 327 +++++++++--------- src/Compiler/TypedTree/TypedTreeOps.fsi | 2 +- src/Compiler/TypedTree/TypedTreePickle.fs | 8 +- src/Compiler/pars.fsy | 216 ++++++------ src/FSharp.Core/Linq.fs | 4 +- src/FSharp.Core/quotations.fs | 8 +- tests/scripts/identifierAnalysisByType.fsx | 5 +- 58 files changed, 1274 insertions(+), 1248 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fa95b151619..93e24046b2d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,6 +12,7 @@ trigger: exclude: - .github/* - docs/ + - tests/scripts/ - attributions.md - CODE_OF_CONDUCT.md - DEVGUIDE.md diff --git a/src/Compiler/AbstractIL/ilreflect.fs b/src/Compiler/AbstractIL/ilreflect.fs index 2781d8a381a..a37fa6b1ae0 100644 --- a/src/Compiler/AbstractIL/ilreflect.fs +++ b/src/Compiler/AbstractIL/ilreflect.fs @@ -479,11 +479,11 @@ module Zmap = let equalTypes (s: Type) (t: Type) = s.Equals t -let equalTypeLists ss tt = - List.lengthsEqAndForall2 equalTypes ss tt +let equalTypeLists (tys1: Type list) (tys2: Type list) = + List.lengthsEqAndForall2 equalTypes tys1 tys2 -let equalTypeArrays ss tt = - Array.lengthsEqAndForall2 equalTypes ss tt +let equalTypeArrays (tys1: Type[]) (tys2: Type[]) = + Array.lengthsEqAndForall2 equalTypes tys1 tys2 let getGenericArgumentsOfType (typT: Type) = if typT.IsGenericType then diff --git a/src/Compiler/AbstractIL/ilx.fs b/src/Compiler/AbstractIL/ilx.fs index 4eb18649752..e91ad50d712 100644 --- a/src/Compiler/AbstractIL/ilx.fs +++ b/src/Compiler/AbstractIL/ilx.fs @@ -75,7 +75,7 @@ type IlxClosureApps = let rec instAppsAux n inst apps = match apps with | Apps_tyapp (ty, rest) -> Apps_tyapp(instILTypeAux n inst ty, instAppsAux n inst rest) - | Apps_app (dty, rest) -> Apps_app(instILTypeAux n inst dty, instAppsAux n inst rest) + | Apps_app (domainTy, rest) -> Apps_app(instILTypeAux n inst domainTy, instAppsAux n inst rest) | Apps_done retTy -> Apps_done(instILTypeAux n inst retTy) let rec instLambdasAux n inst lambdas = diff --git a/src/Compiler/Checking/CheckComputationExpressions.fs b/src/Compiler/Checking/CheckComputationExpressions.fs index ee42cc97fbe..c8a9501e475 100644 --- a/src/Compiler/Checking/CheckComputationExpressions.fs +++ b/src/Compiler/Checking/CheckComputationExpressions.fs @@ -224,10 +224,10 @@ let TcComputationExpression (cenv: cenv) env (overallTy: OverallTy) tpenv (mWhol // Give bespoke error messages for the FSharp.Core "query" builder let isQuery = match stripDebugPoints interpExpr with - | Expr.Val (vf, _, m) -> - let item = Item.CustomBuilder (vf.DisplayName, vf) + | Expr.Val (vref, _, m) -> + let item = Item.CustomBuilder (vref.DisplayName, vref) CallNameResolutionSink cenv.tcSink (m, env.NameEnv, item, emptyTyparInst, ItemOccurence.Use, env.eAccessRights) - valRefEq cenv.g vf cenv.g.query_value_vref + valRefEq cenv.g vref cenv.g.query_value_vref | _ -> false /// Make a builder.Method(...) call @@ -1909,8 +1909,8 @@ let TcSequenceExpression (cenv: cenv) env tpenv comp (overallTy: OverallTy) m = // This transformation is visible in quotations and thus needs to remain. | (TPat_as (TPat_wild _, PatternValBinding (v, _), _), [_], - DebugPoints(Expr.App (Expr.Val (vf, _, _), _, [genEnumElemTy], [yieldExpr], _mYield), recreate)) - when valRefEq cenv.g vf cenv.g.seq_singleton_vref -> + DebugPoints(Expr.App (Expr.Val (vref, _, _), _, [genEnumElemTy], [yieldExpr], _mYield), recreate)) + when valRefEq cenv.g vref cenv.g.seq_singleton_vref -> // The debug point mFor is attached to the 'map' // The debug point mIn is attached to the lambda @@ -2051,11 +2051,11 @@ let TcSequenceExpression (cenv: cenv) env tpenv comp (overallTy: OverallTy) m = error(Error(FSComp.SR.tcUseForInSequenceExpression(), m)) | SynExpr.Match (spMatch, expr, clauses, _m, _trivia) -> - let inputExpr, matchty, tpenv = TcExprOfUnknownType cenv env tpenv expr + let inputExpr, inputTy, tpenv = TcExprOfUnknownType cenv env tpenv expr let tclauses, tpenv = (tpenv, clauses) ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, _, sp, _)) -> - let patR, condR, vspecs, envinner, tpenv = TcMatchPattern cenv matchty env tpenv pat cond + let patR, condR, vspecs, envinner, tpenv = TcMatchPattern cenv inputTy env tpenv pat cond let envinner = match sp with | DebugPointAtTarget.Yes -> { envinner with eIsControlFlow = true } diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index cc7de71eceb..b8192ef5f01 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -291,9 +291,9 @@ let OpenModuleOrNamespaceRefs tcSink g amap scopem root env mvvs openDeclaration env /// Adjust the TcEnv to account for opening a type implied by an `open type` declaration -let OpenTypeContent tcSink g amap scopem env (typ: TType) openDeclaration = +let OpenTypeContent tcSink g amap scopem env (ty: TType) openDeclaration = let env = - { env with eNameResEnv = AddTypeContentsToNameEnv g amap env.eAccessRights scopem env.eNameResEnv typ } + { env with eNameResEnv = AddTypeContentsToNameEnv g amap env.eAccessRights scopem env.eNameResEnv ty } CallEnvSink tcSink (scopem, env.NameEnv, env.eAccessRights) CallOpenDeclarationSink tcSink openDeclaration env @@ -665,16 +665,16 @@ let TcOpenTypeDecl (cenv: cenv) mOpenDecl scopem env (synType: SynType, m) = checkLanguageFeatureError g.langVersion LanguageFeature.OpenTypeDeclaration mOpenDecl - let typ, _tpenv = TcType cenv NoNewTypars CheckCxs ItemOccurence.Open env emptyUnscopedTyparEnv synType + let ty, _tpenv = TcType cenv NoNewTypars CheckCxs ItemOccurence.Open env emptyUnscopedTyparEnv synType - if not (isAppTy g typ) then + if not (isAppTy g ty) then error(Error(FSComp.SR.tcNamedTypeRequired("open type"), m)) - if isByrefTy g typ then + if isByrefTy g ty then error(Error(FSComp.SR.tcIllegalByrefsInOpenTypeDeclaration(), m)) - let openDecl = OpenDeclaration.Create (SynOpenDeclTarget.Type (synType, m), [], [typ], scopem, false) - let env = OpenTypeContent cenv.tcSink g cenv.amap scopem env typ openDecl + let openDecl = OpenDeclaration.Create (SynOpenDeclTarget.Type (synType, m), [], [ty], scopem, false) + let env = OpenTypeContent cenv.tcSink g cenv.amap scopem env ty openDecl env, [openDecl] let TcOpenDecl (cenv: cenv) mOpenDecl scopem env target = @@ -1067,7 +1067,7 @@ module MutRecBindingChecking = Phase2BInherit (inheritsExpr, baseValOpt), innerState // Phase2B: let and let rec value and function definitions - | Phase2AIncrClassBindings (tcref, binds, isStatic, isRec, bindsm) -> + | Phase2AIncrClassBindings (tcref, binds, isStatic, isRec, mBinds) -> let envForBinding = if isStatic then envStatic else envInstance let binds, bindRs, env, tpenv = if isRec then @@ -1080,12 +1080,12 @@ module MutRecBindingChecking = else // Type check local binding - let binds, env, tpenv = TcLetBindings cenv envForBinding ExprContainerInfo (ClassLetBinding isStatic) tpenv (binds, bindsm, scopem) + let binds, env, tpenv = TcLetBindings cenv envForBinding ExprContainerInfo (ClassLetBinding isStatic) tpenv (binds, mBinds, scopem) let binds, bindRs = binds |> List.map (function | TMDefLet(bind, _) -> [bind], IncrClassBindingGroup([bind], isStatic, false) - | TMDefDo(e, _) -> [], IncrClassDo(e, isStatic, bindsm) + | TMDefDo(e, _) -> [], IncrClassDo(e, isStatic, mBinds) | _ -> error(InternalError("unexpected definition kind", tcref.Range))) |> List.unzip List.concat binds, bindRs, env, tpenv @@ -1480,7 +1480,7 @@ module MutRecBindingChecking = envForDecls) /// Phase 2: Check the members and 'let' definitions in a mutually recursive group of definitions. - let TcMutRecDefns_Phase2_Bindings (cenv: cenv) envInitial tpenv bindsm scopem mutRecNSInfo (envMutRecPrelimWithReprs: TcEnv) (mutRecDefns: MutRecDefnsPhase2Info) = + let TcMutRecDefns_Phase2_Bindings (cenv: cenv) envInitial tpenv mBinds scopem mutRecNSInfo (envMutRecPrelimWithReprs: TcEnv) (mutRecDefns: MutRecDefnsPhase2Info) = let g = cenv.g let denv = envMutRecPrelimWithReprs.DisplayEnv @@ -1608,12 +1608,12 @@ module MutRecBindingChecking = (fun morpher shape -> shape |> MutRecShapes.iterTyconsAndLets (p23 >> morpher) morpher) MutRecShape.Lets (fun morpher shape -> shape |> MutRecShapes.mapTyconsAndLets (fun (tyconOpt, fixupValueExprBinds, methodBinds) -> tyconOpt, (morpher fixupValueExprBinds @ methodBinds)) morpher) - bindsm + mBinds defnsEs, envMutRec /// Check and generalize the interface implementations, members, 'let' definitions in a mutually recursive group of definitions. -let TcMutRecDefns_Phase2 (cenv: cenv) envInitial bindsm scopem mutRecNSInfo (envMutRec: TcEnv) (mutRecDefns: MutRecDefnsPhase2Data) = +let TcMutRecDefns_Phase2 (cenv: cenv) envInitial mBinds scopem mutRecNSInfo (envMutRec: TcEnv) (mutRecDefns: MutRecDefnsPhase2Data) = let g = cenv.g let interfacesFromTypeDefn envForTycon tyconMembersData = let (MutRecDefnsPhase2DataForTycon(_, _, declKind, tcref, _, _, declaredTyconTypars, members, _, _, _)) = tyconMembersData @@ -1727,7 +1727,7 @@ let TcMutRecDefns_Phase2 (cenv: cenv) envInitial bindsm scopem mutRecNSInfo (env (intfTypes, slotImplSets) ||> List.map2 (interfaceMembersFromTypeDefn tyconData) |> List.concat MutRecDefnsPhase2InfoForTycon(tyconOpt, tcref, declaredTyconTypars, declKind, obinds @ ibinds, fixupFinalAttrs)) - MutRecBindingChecking.TcMutRecDefns_Phase2_Bindings cenv envInitial tpenv bindsm scopem mutRecNSInfo envMutRec binds + MutRecBindingChecking.TcMutRecDefns_Phase2_Bindings cenv envInitial tpenv mBinds scopem mutRecNSInfo envMutRec binds with exn -> errorRecovery exn scopem; [], envMutRec @@ -3436,37 +3436,37 @@ module EstablishTypeDefinitionCores = match stripTyparEqns ty with | TType_anon (_,l) | TType_tuple (_, l) -> accInAbbrevTypes l acc - | TType_ucase (UnionCaseRef(tc, _), tinst) - | TType_app (tc, tinst, _) -> - let tycon2 = tc.Deref + | TType_ucase (UnionCaseRef(tcref2, _), tinst) + | TType_app (tcref2, tinst, _) -> + let tycon2 = tcref2.Deref let acc = accInAbbrevTypes tinst acc // Record immediate recursive references if ListSet.contains (===) tycon2 tycons then (tycon, tycon2) :: acc // Expand the representation of abbreviations - elif tc.IsTypeAbbrev then - accInAbbrevType (reduceTyconRefAbbrev tc tinst) acc + elif tcref2.IsTypeAbbrev then + accInAbbrevType (reduceTyconRefAbbrev tcref2 tinst) acc // Otherwise H - explore the instantiation. else acc - | TType_fun (d, r, _) -> - accInAbbrevType d (accInAbbrevType r acc) + | TType_fun (domainTy, rangeTy, _) -> + accInAbbrevType domainTy (accInAbbrevType rangeTy acc) | TType_var _ -> acc - | TType_forall (_, r) -> accInAbbrevType r acc + | TType_forall (_, bodyTy) -> accInAbbrevType bodyTy acc - | TType_measure ms -> accInMeasure ms acc - - and accInMeasure ms acc = - match stripUnitEqns ms with - | Measure.Con tc when ListSet.contains (===) tc.Deref tycons -> - (tycon, tc.Deref) :: acc - | Measure.Con tc when tc.IsTypeAbbrev -> - accInMeasure (reduceTyconRefAbbrevMeasureable tc) acc + | TType_measure measureTy -> accInMeasure measureTy acc + + and accInMeasure measureTy acc = + match stripUnitEqns measureTy with + | Measure.Const tcref when ListSet.contains (===) tcref.Deref tycons -> + (tycon, tcref.Deref) :: acc + | Measure.Const tcref when tcref.IsTypeAbbrev -> + accInMeasure (reduceTyconRefAbbrevMeasureable tcref) acc | Measure.Prod (ms1, ms2) -> accInMeasure ms1 (accInMeasure ms2 acc) - | Measure.Inv ms -> accInMeasure ms acc + | Measure.Inv invTy -> accInMeasure invTy acc | _ -> acc and accInAbbrevTypes tys acc = @@ -3477,7 +3477,7 @@ module EstablishTypeDefinitionCores = | Some ty -> accInAbbrevType ty [] let edges = List.collect edgesFrom tycons - let graph = Graph ((fun tc -> tc.Stamp), tycons, edges) + let graph = Graph ((fun tycon -> tycon.Stamp), tycons, edges) graph.IterateCycles (fun path -> let tycon = path.Head // The thing is cyclic. Set the abbreviation and representation to be "None" to stop later VS crashes diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index d513a326a74..7e3baef258b 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -987,28 +987,28 @@ let UnifyFunctionType extraInfo cenv denv mFunExpr ty = let ReportImplicitlyIgnoredBoolExpression denv m ty expr = let checkExpr m expr = match stripDebugPoints expr with - | Expr.App (Expr.Val (vf, _, _), _, _, exprs, _) when vf.LogicalName = opNameEquals -> + | Expr.App (Expr.Val (vref, _, _), _, _, exprs, _) when vref.LogicalName = opNameEquals -> match List.map stripDebugPoints exprs with - | Expr.App (Expr.Val (propRef, _, _), _, _, Expr.Val (vf, _, _) :: _, _) :: _ -> + | Expr.App (Expr.Val (propRef, _, _), _, _, Expr.Val (vref, _, _) :: _, _) :: _ -> if propRef.IsPropertyGetterMethod then let propertyName = propRef.PropertyName let hasCorrespondingSetter = match propRef.DeclaringEntity with | Parent entityRef -> entityRef.MembersOfFSharpTyconSorted - |> List.exists (fun valRef -> valRef.IsPropertySetterMethod && valRef.PropertyName = propertyName) + |> List.exists (fun vref -> vref.IsPropertySetterMethod && vref.PropertyName = propertyName) | _ -> false if hasCorrespondingSetter then - UnitTypeExpectedWithPossiblePropertySetter (denv, ty, vf.DisplayName, propertyName, m) + UnitTypeExpectedWithPossiblePropertySetter (denv, ty, vref.DisplayName, propertyName, m) else UnitTypeExpectedWithEquality (denv, ty, m) else UnitTypeExpectedWithEquality (denv, ty, m) - | Expr.Op (TOp.ILCall (_, _, _, _, _, _, _, ilMethRef, _, _, _), _, Expr.Val (vf, _, _) :: _, _) :: _ when ilMethRef.Name.StartsWithOrdinal("get_") -> - UnitTypeExpectedWithPossiblePropertySetter (denv, ty, vf.DisplayName, ChopPropertyName(ilMethRef.Name), m) - | Expr.Val (vf, _, _) :: _ -> - UnitTypeExpectedWithPossibleAssignment (denv, ty, vf.IsMutable, vf.DisplayName, m) + | Expr.Op (TOp.ILCall (_, _, _, _, _, _, _, ilMethRef, _, _, _), _, Expr.Val (vref, _, _) :: _, _) :: _ when ilMethRef.Name.StartsWithOrdinal("get_") -> + UnitTypeExpectedWithPossiblePropertySetter (denv, ty, vref.DisplayName, ChopPropertyName(ilMethRef.Name), m) + | Expr.Val (vref, _, _) :: _ -> + UnitTypeExpectedWithPossibleAssignment (denv, ty, vref.IsMutable, vref.DisplayName, m) | _ -> UnitTypeExpectedWithEquality (denv, ty, m) | _ -> UnitTypeExpected (denv, ty, m) @@ -1041,8 +1041,8 @@ let UnifyUnitType (cenv: cenv) (env: TcEnv) m ty expr = match env.eContextInfo with | ContextInfo.SequenceExpression seqTy -> - let lifted = mkSeqTy g ty - if typeEquiv g seqTy lifted then + let liftedTy = mkSeqTy g ty + if typeEquiv g seqTy liftedTy then warning (Error (FSComp.SR.implicitlyDiscardedInSequenceExpression(NicePrint.prettyStringOfTy denv ty), m)) else if isListTy g ty || isArrayTy g ty || typeEquiv g seqTy ty then @@ -1100,7 +1100,7 @@ let TcConst (cenv: cenv) (overallTy: TType) m env synConst = let _, tcref = ForceRaise(ResolveTypeLongIdent cenv.tcSink cenv.nameResolver ItemOccurence.Use OpenQualified env.eNameResEnv ad tc TypeNameResolutionStaticArgsInfo.DefiniteEmpty PermitDirectReferenceToGeneratedType.No) match tcref.TypeOrMeasureKind with | TyparKind.Type -> error(Error(FSComp.SR.tcExpectedUnitOfMeasureNotType(), m)) - | TyparKind.Measure -> Measure.Con tcref + | TyparKind.Measure -> Measure.Const tcref | SynMeasure.Power(ms, exponent, _) -> Measure.RationalPower (tcMeasure ms, TcSynRationalConst exponent) | SynMeasure.Product(ms1, ms2, _) -> Measure.Prod(tcMeasure ms1, tcMeasure ms2) @@ -1114,7 +1114,7 @@ let TcConst (cenv: cenv) (overallTy: TType) m env synConst = | SynMeasure.Var(_, m) -> error(Error(FSComp.SR.tcNonZeroConstantCannotHaveGenericUnit(), m)) | SynMeasure.Paren(measure, _) -> tcMeasure measure - let unif expected = UnifyTypes cenv env m overallTy expected + let unif expectedTy = UnifyTypes cenv env m overallTy expectedTy let unifyMeasureArg iszero tcr = let measureTy = @@ -1312,7 +1312,7 @@ let MakeMemberDataAndMangledNameForMemberVal(g, tcref, isExtrinsic, attrs, implS // NOTE: This value is initially only set for interface implementations and those overrides // where we manage to pre-infer which abstract is overridden by the method. It is filled in // properly when we check the allImplemented implementation checks at the end of the inference scope. - ImplementedSlotSigs=implSlotTys |> List.map (fun ity -> TSlotSig(logicalName, ity, [], [], [], None)) } + ImplementedSlotSigs=implSlotTys |> List.map (fun intfTy -> TSlotSig(logicalName, intfTy, [], [], [], None)) } let isInstance = MemberIsCompiledAsInstance g tcref isExtrinsic memberInfo attrs @@ -1529,8 +1529,8 @@ let MakeAndPublishVal (cenv: cenv) env (altActualParent, inSig, declKind, valRec let vis = if MemberIsExplicitImpl g memberInfo then let slotSig = List.head memberInfo.ImplementedSlotSigs - match slotSig.ImplementedType with - | TType_app (tyconref, _, _) -> Some tyconref.Accessibility + match slotSig.DeclaringType with + | TType_app (tcref, _, _) -> Some tcref.Accessibility | _ -> None else None @@ -1714,14 +1714,14 @@ let AdjustRecType (v: Val) vscheme = /// Record the generated value expression as a place where we will have to /// adjust using AdjustAndForgetUsesOfRecValue at a letrec point. Every use of a value /// under a letrec gets used at the _same_ type instantiation. -let RecordUseOfRecValue cenv valRecInfo (vrefTgt: ValRef) vexp m = +let RecordUseOfRecValue cenv valRecInfo (vrefTgt: ValRef) vExpr m = match valRecInfo with | ValInRecScope isComplete -> - let fixupPoint = ref vexp + let fixupPoint = ref vExpr cenv.recUses <- cenv.recUses.Add (vrefTgt.Deref, (fixupPoint, m, isComplete)) Expr.Link fixupPoint | ValNotInRecScope -> - vexp + vExpr type RecursiveUseFixupPoints = RecursiveUseFixupPoints of (Expr ref * range) list @@ -2161,9 +2161,9 @@ let rec ApplyUnionCaseOrExn (makerForUnionCase, makerForExnTag) m (cenv: cenv) e let ucref = ucinfo.UnionCaseRef CheckUnionCaseAttributes g ucref m |> CommitOperationResult CheckUnionCaseAccessible cenv.amap m ad ucref |> ignore - let gtyp2 = actualResultTyOfUnionCase ucinfo.TypeInst ucref + let resTy = actualResultTyOfUnionCase ucinfo.TypeInst ucref let inst = mkTyparInst ucref.TyconRef.TyparsNoRange ucinfo.TypeInst - UnifyTypes cenv env m overallTy gtyp2 + UnifyTypes cenv env m overallTy resTy let mkf = makerForUnionCase(ucref, ucinfo.TypeInst) mkf, actualTysOfUnionCaseFields inst ucref, [ for f in ucref.AllFieldsAsList -> f.Id ] | _ -> invalidArg "item" "not a union case or exception reference" @@ -2346,11 +2346,11 @@ module GeneralizationHelpers = let relevantUniqueSubtypeConstraint (tp: Typar) = // Find a single subtype constraint match tp.Constraints |> List.partition (function TyparConstraint.CoercesTo _ -> true | _ -> false) with - | [TyparConstraint.CoercesTo(cxty, _)], others -> + | [TyparConstraint.CoercesTo(tgtTy, _)], others -> // Throw away null constraints if they are implied - if others |> List.exists (function TyparConstraint.SupportsNull _ -> not (TypeSatisfiesNullConstraint g m cxty) | _ -> true) + if others |> List.exists (function TyparConstraint.SupportsNull _ -> not (TypeSatisfiesNullConstraint g m tgtTy) | _ -> true) then None - else Some cxty + else Some tgtTy | _ -> None @@ -2745,8 +2745,8 @@ module EventDeclarationNormalization = let rec private RenameBindingPattern f declPattern = match declPattern with - | SynPat.FromParseError(p, _) -> RenameBindingPattern f p - | SynPat.Typed(pat', _, _) -> RenameBindingPattern f pat' + | SynPat.FromParseError(innerPat, _) -> RenameBindingPattern f innerPat + | SynPat.Typed(innerPat, _, _) -> RenameBindingPattern f innerPat | SynPat.Named (SynIdent(id,_), x2, vis2, m) -> SynPat.Named (SynIdent(ident(f id.idText, id.idRange), None), x2, vis2, m) | SynPat.InstanceMember(thisId, id, toolId, vis2, m) -> SynPat.InstanceMember(thisId, ident(f id.idText, id.idRange), toolId, vis2, m) | _ -> error(Error(FSComp.SR.tcOnlySimplePatternsInLetRec(), declPattern.Range)) @@ -2848,11 +2848,11 @@ let TcValEarlyGeneralizationConsistencyCheck cenv (env: TcEnv) (v: Val, valRecIn match valRecInfo with | ValInRecScope isComplete when isComplete && not (isNil tinst) -> cenv.css.PushPostInferenceCheck (preDefaults=false, check=fun () -> - let tpsorig, tau2 = tryDestForallTy g vTy - if not (isNil tpsorig) then - let tpsorig = NormalizeDeclaredTyparsForEquiRecursiveInference g tpsorig - let tau3 = instType (mkTyparInst tpsorig tinst) tau2 - if not (AddCxTypeEqualsTypeUndoIfFailed env.DisplayEnv cenv.css m tau tau3) then + let vTypars, vTauTy = tryDestForallTy g vTy + if not (isNil vTypars) then + let vTypars = NormalizeDeclaredTyparsForEquiRecursiveInference g vTypars + let vTauTy = instType (mkTyparInst vTypars tinst) vTauTy + if not (AddCxTypeEqualsTypeUndoIfFailed env.DisplayEnv cenv.css m tau vTauTy) then let txt = buildString (fun buf -> NicePrint.outputQualifiedValSpec env.DisplayEnv cenv.infoReader buf (mkLocalValRef v)) error(Error(FSComp.SR.tcInferredGenericTypeGivesRiseToInconsistency(v.DisplayName, txt), m))) | _ -> () @@ -2933,26 +2933,26 @@ let TcVal checkAttributes (cenv: cenv) env (tpenv: UnscopedTyparEnv) (vref: ValR warning(Error(FSComp.SR.tcDoesNotAllowExplicitTypeArguments(v.DisplayName), m)) match valRecInfo with | ValInRecScope false -> - let tpsorig, tau = vref.GeneralizedType - let (tinst: TypeInst), tpenv = checkTys tpenv (tpsorig |> List.map (fun tp -> tp.Kind)) + let vTypars, vTauTy = vref.GeneralizedType + let tinst, tpenv = checkTys tpenv (vTypars |> List.map (fun tp -> tp.Kind)) checkInst tinst - if tpsorig.Length <> tinst.Length then error(Error(FSComp.SR.tcTypeParameterArityMismatch(tpsorig.Length, tinst.Length), m)) + if vTypars.Length <> tinst.Length then error(Error(FSComp.SR.tcTypeParameterArityMismatch(vTypars.Length, tinst.Length), m)) - let tau2 = instType (mkTyparInst tpsorig tinst) tau + let vRecTauTy = instType (mkTyparInst vTypars tinst) vTauTy - (tpsorig, tinst) ||> List.iter2 (fun tp ty -> + (vTypars, tinst) ||> List.iter2 (fun tp ty -> try UnifyTypes cenv env m (mkTyparTy tp) ty - with _ -> error (Recursion(env.DisplayEnv, v.Id, tau2, tau, m))) + with _ -> error (Recursion(env.DisplayEnv, v.Id, vRecTauTy, vTauTy, m))) - tpsorig, vrefFlags, tinst, tau2, tpenv + vTypars, vrefFlags, tinst, vRecTauTy, tpenv | ValInRecScope true | ValNotInRecScope -> - let tpsorig, tps, tpTys, tau = FreshenPossibleForallTy g m TyparRigidity.Flexible vTy + let vTypars, tps, tpTys, vTauTy = FreshenPossibleForallTy g m TyparRigidity.Flexible vTy - let (tinst: TypeInst), tpenv = checkTys tpenv (tps |> List.map (fun tp -> tp.Kind)) + let tinst, tpenv = checkTys tpenv (tps |> List.map (fun tp -> tp.Kind)) checkInst tinst @@ -2960,9 +2960,9 @@ let TcVal checkAttributes (cenv: cenv) env (tpenv: UnscopedTyparEnv) (vref: ValR List.iter2 (UnifyTypes cenv env m) tpTys tinst - TcValEarlyGeneralizationConsistencyCheck cenv env (v, valRecInfo, tinst, vTy, tau, m) + TcValEarlyGeneralizationConsistencyCheck cenv env (v, valRecInfo, tinst, vTy, vTauTy, m) - tpsorig, vrefFlags, tinst, tau, tpenv + vTypars, vrefFlags, tinst, vTauTy, tpenv let exprForVal = Expr.Val (vref, vrefFlags, m) let exprForVal = mkTyAppExpr m (exprForVal, vTy) tinst @@ -3259,7 +3259,7 @@ let BuildILFieldGet g amap m objExpr (finfo: ILFieldInfo) = let isStruct = finfo.IsValueType let boxity = if isStruct then AsValue else AsObject let tinst = finfo.TypeInst - let fieldType = finfo.FieldType (amap, m) + let fieldTy = finfo.FieldType (amap, m) #if !NO_TYPEPROVIDERS let ty = tyOfExpr g objExpr match finfo with @@ -3269,7 +3269,7 @@ let BuildILFieldGet g amap m objExpr (finfo: ILFieldInfo) = | None -> error (Error(FSComp.SR.tcTPFieldMustBeLiteral(), m)) | Some lit -> - Expr.Const (TcFieldInit m lit, m, fieldType) + Expr.Const (TcFieldInit m lit, m, fieldTy) | _ -> #endif let wrap, objExpr, _readonly, _writeonly = mkExprAddrOfExpr g isStruct false NeverMutates objExpr None m @@ -3278,7 +3278,7 @@ let BuildILFieldGet g amap m objExpr (finfo: ILFieldInfo) = // polymorphic code, after inlining etc. * let fspec = mkILFieldSpec(fref, mkILNamedTy boxity fref.DeclaringTypeRef []) // Add an I_nop if this is an initonly field to make sure we never recognize it as an lvalue. See mkExprAddrOfExpr. - wrap (mkAsmExpr (([ mkNormalLdfld fspec ] @ (if finfo.IsInitOnly then [ AI_nop ] else [])), tinst, [objExpr], [fieldType], m)) + wrap (mkAsmExpr (([ mkNormalLdfld fspec ] @ (if finfo.IsInitOnly then [ AI_nop ] else [])), tinst, [objExpr], [fieldTy], m)) /// Checks that setting a field value does not set a literal or initonly field let private CheckFieldLiteralArg (finfo: ILFieldInfo) argExpr m = @@ -3431,28 +3431,28 @@ let AnalyzeArbitraryExprAsEnumerable (cenv: cenv) (env: TcEnv) localAlloc m expr let tryType (exprToSearchForGetEnumeratorAndItem, tyToSearchForGetEnumeratorAndItem) = match findMethInfo true m "GetEnumerator" tyToSearchForGetEnumeratorAndItem with | Exception exn -> Exception exn - | Result getEnumerator_minfo -> + | Result getEnumeratorMethInfo -> - let getEnumerator_minst = FreshenMethInfo m getEnumerator_minfo - let retTypeOfGetEnumerator = getEnumerator_minfo.GetFSharpReturnType(cenv.amap, m, getEnumerator_minst) - if hasArgs getEnumerator_minfo getEnumerator_minst then err true tyToSearchForGetEnumeratorAndItem else + let getEnumeratorMethInst = FreshenMethInfo m getEnumeratorMethInfo + let getEnumeratorRetTy = getEnumeratorMethInfo.GetFSharpReturnType(cenv.amap, m, getEnumeratorMethInst) + if hasArgs getEnumeratorMethInfo getEnumeratorMethInst then err true tyToSearchForGetEnumeratorAndItem else - match findMethInfo false m "MoveNext" retTypeOfGetEnumerator with + match findMethInfo false m "MoveNext" getEnumeratorRetTy with | Exception exn -> Exception exn - | Result moveNext_minfo -> + | Result moveNextMethInfo -> - let moveNext_minst = FreshenMethInfo m moveNext_minfo - let retTypeOfMoveNext = moveNext_minfo.GetFSharpReturnType(cenv.amap, m, moveNext_minst) - if not (typeEquiv g g.bool_ty retTypeOfMoveNext) then err false retTypeOfGetEnumerator else - if hasArgs moveNext_minfo moveNext_minst then err false retTypeOfGetEnumerator else + let moveNextMethInst = FreshenMethInfo m moveNextMethInfo + let moveNextRetTy = moveNextMethInfo.GetFSharpReturnType(cenv.amap, m, moveNextMethInst) + if not (typeEquiv g g.bool_ty moveNextRetTy) then err false getEnumeratorRetTy else + if hasArgs moveNextMethInfo moveNextMethInst then err false getEnumeratorRetTy else - match findMethInfo false m "get_Current" retTypeOfGetEnumerator with + match findMethInfo false m "get_Current" getEnumeratorRetTy with | Exception exn -> Exception exn - | Result get_Current_minfo -> + | Result getCurrentMethInfo -> - let get_Current_minst = FreshenMethInfo m get_Current_minfo - if hasArgs get_Current_minfo get_Current_minst then err false retTypeOfGetEnumerator else - let enumElemTy = get_Current_minfo.GetFSharpReturnType(cenv.amap, m, get_Current_minst) + let getCurrentMethInst = FreshenMethInfo m getCurrentMethInfo + if hasArgs getCurrentMethInfo getCurrentMethInst then err false getEnumeratorRetTy else + let enumElemTy = getCurrentMethInfo.GetFSharpReturnType(cenv.amap, m, getCurrentMethInst) // Compute the element type of the strongly typed enumerator // @@ -3496,23 +3496,23 @@ let AnalyzeArbitraryExprAsEnumerable (cenv: cenv) (env: TcEnv) localAlloc m expr else enumElemTy - let isEnumeratorTypeStruct = isStructTy g retTypeOfGetEnumerator - let originalRetTypeOfGetEnumerator = retTypeOfGetEnumerator + let isEnumeratorTypeStruct = isStructTy g getEnumeratorRetTy + let originalRetTypeOfGetEnumerator = getEnumeratorRetTy - let (enumeratorVar, enumeratorExpr), retTypeOfGetEnumerator = + let (enumeratorVar, enumeratorExpr), getEnumeratorRetTy = if isEnumeratorTypeStruct then if localAlloc then - mkMutableCompGenLocal m "enumerator" retTypeOfGetEnumerator, retTypeOfGetEnumerator + mkMutableCompGenLocal m "enumerator" getEnumeratorRetTy, getEnumeratorRetTy else - let refCellTyForRetTypeOfGetEnumerator = mkRefCellTy g retTypeOfGetEnumerator + let refCellTyForRetTypeOfGetEnumerator = mkRefCellTy g getEnumeratorRetTy let v, e = mkMutableCompGenLocal m "enumerator" refCellTyForRetTypeOfGetEnumerator - (v, mkRefCellGet g m retTypeOfGetEnumerator e), refCellTyForRetTypeOfGetEnumerator + (v, mkRefCellGet g m getEnumeratorRetTy e), refCellTyForRetTypeOfGetEnumerator else - mkCompGenLocal m "enumerator" retTypeOfGetEnumerator, retTypeOfGetEnumerator + mkCompGenLocal m "enumerator" getEnumeratorRetTy, getEnumeratorRetTy let getEnumExpr, getEnumTy = - let getEnumExpr, getEnumTy as res = BuildPossiblyConditionalMethodCall cenv env PossiblyMutates m false getEnumerator_minfo NormalValUse getEnumerator_minst [exprToSearchForGetEnumeratorAndItem] [] + let getEnumExpr, getEnumTy as res = BuildPossiblyConditionalMethodCall cenv env PossiblyMutates m false getEnumeratorMethInfo NormalValUse getEnumeratorMethInst [exprToSearchForGetEnumeratorAndItem] [] if not isEnumeratorTypeStruct || localAlloc then res else // wrap enumerators that are represented as mutable structs into ref cells @@ -3520,8 +3520,8 @@ let AnalyzeArbitraryExprAsEnumerable (cenv: cenv) (env: TcEnv) localAlloc m expr let getEnumTy = mkRefCellTy g getEnumTy getEnumExpr, getEnumTy - let guardExpr, guardTy = BuildPossiblyConditionalMethodCall cenv env DefinitelyMutates m false moveNext_minfo NormalValUse moveNext_minst [enumeratorExpr] [] - let currentExpr, currentTy = BuildPossiblyConditionalMethodCall cenv env DefinitelyMutates m true get_Current_minfo NormalValUse get_Current_minst [enumeratorExpr] [] + let guardExpr, guardTy = BuildPossiblyConditionalMethodCall cenv env DefinitelyMutates m false moveNextMethInfo NormalValUse moveNextMethInst [enumeratorExpr] [] + let currentExpr, currentTy = BuildPossiblyConditionalMethodCall cenv env DefinitelyMutates m true getCurrentMethInfo NormalValUse getCurrentMethInst [enumeratorExpr] [] let currentExpr = mkCoerceExpr(currentExpr, enumElemTy, currentExpr.Range, currentTy) let currentExpr, enumElemTy = // Implicitly dereference byref for expr 'for x in ...' @@ -3531,7 +3531,7 @@ let AnalyzeArbitraryExprAsEnumerable (cenv: cenv) (env: TcEnv) localAlloc m expr else currentExpr, enumElemTy - Result(enumeratorVar, enumeratorExpr, retTypeOfGetEnumerator, enumElemTy, getEnumExpr, getEnumTy, guardExpr, guardTy, currentExpr) + Result(enumeratorVar, enumeratorExpr, getEnumeratorRetTy, enumElemTy, getEnumExpr, getEnumTy, guardExpr, guardTy, currentExpr) // First try the original known static type match (if isArray1DTy g exprTy then Exception (Failure "") else tryType (expr, exprTy)) with @@ -3570,12 +3570,12 @@ let ConvertArbitraryExprToEnumerable (cenv: cenv) ty (env: TcEnv) (expr: Expr) = expr, enumElemTy else let enumerableVar, enumerableExpr = mkCompGenLocal m "inputSequence" ty - let enumeratorVar, _, retTypeOfGetEnumerator, enumElemTy, getEnumExpr, _, guardExpr, guardTy, betterCurrentExpr = + let enumeratorVar, _, getEnumeratorRetTy, enumElemTy, getEnumExpr, _, guardExpr, guardTy, betterCurrentExpr = AnalyzeArbitraryExprAsEnumerable cenv env false m ty enumerableExpr let expr = mkCompGenLet m enumerableVar expr - (mkCallSeqOfFunctions g m retTypeOfGetEnumerator enumElemTy + (mkCallSeqOfFunctions g m getEnumeratorRetTy enumElemTy (mkUnitDelayLambda g m getEnumExpr) (mkLambda m enumeratorVar (guardExpr, guardTy)) (mkLambda m enumeratorVar (betterCurrentExpr, enumElemTy))) @@ -3921,28 +3921,28 @@ let buildApp cenv expr resultTy arg m = match expr, arg with // Special rule for building applications of the 'x && y' operator - | ApplicableExpr(_, Expr.App (Expr.Val (vf, _, _), _, _, [x0], _), _), _ - when valRefEq g vf g.and_vref - || valRefEq g vf g.and2_vref -> + | ApplicableExpr(_, Expr.App (Expr.Val (vref, _, _), _, _, [x0], _), _), _ + when valRefEq g vref g.and_vref + || valRefEq g vref g.and2_vref -> MakeApplicableExprNoFlex cenv (mkLazyAnd g m x0 arg), resultTy // Special rule for building applications of the 'x || y' operator - | ApplicableExpr(_, Expr.App (Expr.Val (vf, _, _), _, _, [x0], _), _), _ - when valRefEq g vf g.or_vref - || valRefEq g vf g.or2_vref -> + | ApplicableExpr(_, Expr.App (Expr.Val (vref, _, _), _, _, [x0], _), _), _ + when valRefEq g vref g.or_vref + || valRefEq g vref g.or2_vref -> MakeApplicableExprNoFlex cenv (mkLazyOr g m x0 arg ), resultTy // Special rule for building applications of the 'reraise' operator - | ApplicableExpr(_, Expr.App (Expr.Val (vf, _, _), _, _, [], _), _), _ - when valRefEq g vf g.reraise_vref -> + | ApplicableExpr(_, Expr.App (Expr.Val (vref, _, _), _, _, [], _), _), _ + when valRefEq g vref g.reraise_vref -> // exprTy is of type: "unit -> 'a". Break it and store the 'a type here, used later as return type. MakeApplicableExprNoFlex cenv (mkCompGenSequential m arg (mkReraise m resultTy)), resultTy // Special rules for NativePtr.ofByRef to generalize result. // See RFC FS-1053.md - | ApplicableExpr(_, Expr.App (Expr.Val (vf, _, _), _, _, [], _), _), _ - when (valRefEq g vf g.nativeptr_tobyref_vref) -> + | ApplicableExpr(_, Expr.App (Expr.Val (vref, _, _), _, _, [], _), _), _ + when (valRefEq g vref g.nativeptr_tobyref_vref) -> let argTy = NewInferenceType g let resultTy = mkByrefTyWithInference g argTy (NewByRefKindInferenceType g m) @@ -3952,10 +3952,10 @@ let buildApp cenv expr resultTy arg m = // address of an expression. // // See also RFC FS-1053.md - | ApplicableExpr(_, Expr.App (Expr.Val (vf, _, _), _, _, [], _), _), _ - when valRefEq g vf g.addrof_vref -> + | ApplicableExpr(_, Expr.App (Expr.Val (vref, _, _), _, _, [], _), _), _ + when valRefEq g vref g.addrof_vref -> - let wrap, e1a', readonly, _writeonly = mkExprAddrOfExpr g true false AddressOfOp arg (Some vf) m + let wrap, e1a', readonly, _writeonly = mkExprAddrOfExpr g true false AddressOfOp arg (Some vref) m // Assert the result type to be readonly if we couldn't take the address let resultTy = let argTy = tyOfExpr g arg @@ -3977,11 +3977,11 @@ let buildApp cenv expr resultTy arg m = // Special rules for building applications of the &&expr' operators, which gets the // address of an expression. - | ApplicableExpr(_, Expr.App (Expr.Val (vf, _, _), _, _, [], _), _), _ - when valRefEq g vf g.addrof2_vref -> + | ApplicableExpr(_, Expr.App (Expr.Val (vref, _, _), _, _, [], _), _), _ + when valRefEq g vref g.addrof2_vref -> warning(UseOfAddressOfOperator m) - let wrap, e1a', _readonly, _writeonly = mkExprAddrOfExpr g true false AddressOfOp arg (Some vf) m + let wrap, e1a', _readonly, _writeonly = mkExprAddrOfExpr g true false AddressOfOp arg (Some vref) m MakeApplicableExprNoFlex cenv (wrap(e1a')), resultTy | _ when isByrefTy g resultTy -> @@ -4598,7 +4598,7 @@ and TcLongIdent kindOpt cenv newOk checkConstraints occ env tpenv synLongId = error(Error(FSComp.SR.tcExpectedUnitOfMeasureNotType(), m)) TType_measure (NewErrorMeasure ()), tpenv | _, TyparKind.Measure -> - TType_measure (Measure.Con tcref), tpenv + TType_measure (Measure.Const tcref), tpenv | _, TyparKind.Type -> TcTypeApp cenv newOk checkConstraints occ env tpenv m tcref tinstEnclosing [] @@ -4631,7 +4631,7 @@ and TcLongIdentAppType kindOpt cenv newOk checkConstraints occ env tpenv longId match args, postfix with | [arg], true -> let ms, tpenv = TcMeasure cenv newOk checkConstraints occ env tpenv arg m - TType_measure (Measure.Prod(Measure.Con tcref, ms)), tpenv + TType_measure (Measure.Prod(Measure.Const tcref, ms)), tpenv | _, _ -> errorR(Error(FSComp.SR.tcUnitsOfMeasureInvalidInTypeConstructor(), m)) @@ -5111,8 +5111,8 @@ and TcNestedTypeApplication cenv newOk checkConstraints occ env tpenv mWholeType /// This means the range of syntactic expression forms that can be used here is limited. and ConvSynPatToSynExpr synPat = match synPat with - | SynPat.FromParseError(p, _) -> - ConvSynPatToSynExpr p + | SynPat.FromParseError(innerPat, _) -> + ConvSynPatToSynExpr innerPat | SynPat.Const (c, m) -> SynExpr.Const (c, m) @@ -5120,8 +5120,8 @@ and ConvSynPatToSynExpr synPat = | SynPat.Named (SynIdent(id,_), _, None, _) -> SynExpr.Ident id - | SynPat.Typed (p, cty, m) -> - SynExpr.Typed (ConvSynPatToSynExpr p, cty, m) + | SynPat.Typed (innerPat, tgtTy, m) -> + SynExpr.Typed (ConvSynPatToSynExpr innerPat, tgtTy, m) | SynPat.LongIdent (longDotId=SynLongIdent(longId, dotms, trivia) as synLongId; argPats=args; accessibility=None; range=m) -> let args = match args with SynArgPats.Pats args -> args | _ -> failwith "impossible: active patterns can be used only with SynConstructorArgs.Pats" @@ -5135,8 +5135,8 @@ and ConvSynPatToSynExpr synPat = | SynPat.Tuple (isStruct, args, m) -> SynExpr.Tuple (isStruct, List.map ConvSynPatToSynExpr args, [], m) - | SynPat.Paren (p, _) -> - ConvSynPatToSynExpr p + | SynPat.Paren (innerPat, _) -> + ConvSynPatToSynExpr innerPat | SynPat.ArrayOrList (isArray, args, m) -> SynExpr.ArrayOrList (isArray,List.map ConvSynPatToSynExpr args, m) @@ -5151,26 +5151,26 @@ and ConvSynPatToSynExpr synPat = error(Error(FSComp.SR.tcInvalidArgForParameterizedPattern(), synPat.Range)) /// Check a long identifier 'Case' or 'Case argsR' that has been resolved to an active pattern case -and TcPatLongIdentActivePatternCase warnOnUpper cenv (env: TcEnv) vFlags patEnv ty (lidRange, item, apref, args, m) = +and TcPatLongIdentActivePatternCase warnOnUpper cenv (env: TcEnv) vFlags patEnv ty (mLongId, item, apref, args, m) = let g = cenv.g let (TcPatLinearEnv(tpenv, names, takenNames)) = patEnv let (APElemRef (apinfo, vref, idx, isStructRetTy)) = apref // Report information about the 'active recognizer' occurrence to IDE - CallNameResolutionSink cenv.tcSink (lidRange, env.NameEnv, item, emptyTyparInst, ItemOccurence.Pattern, env.eAccessRights) + CallNameResolutionSink cenv.tcSink (mLongId, env.NameEnv, item, emptyTyparInst, ItemOccurence.Pattern, env.eAccessRights) // TOTAL/PARTIAL ACTIVE PATTERNS - let _, vexp, _, _, tinst, _ = TcVal true cenv env tpenv vref None None m - let vexp = MakeApplicableExprWithFlex cenv env vexp - let vexpty = vexp.Type + let _, vExpr, _, _, tinst, _ = TcVal true cenv env tpenv vref None None m + let vExpr = MakeApplicableExprWithFlex cenv env vExpr + let vExprTy = vExpr.Type let activePatArgsAsSynPats, patArg = match args with | [] -> [], SynPat.Const(SynConst.Unit, m) | _ -> // This bit of type-directed analysis ensures that parameterized partial active patterns returning unit do not need to take an argument - let dtys, retTy = stripFunTy g vexpty + let dtys, retTy = stripFunTy g vExprTy if dtys.Length = args.Length + 1 && ((isOptionTy g retTy && isUnitTy g (destOptionTy g retTy)) || @@ -5189,9 +5189,9 @@ and TcPatLongIdentActivePatternCase warnOnUpper cenv (env: TcEnv) vFlags patEnv let delayed = activePatArgsAsSynExprs - |> List.map (fun arg -> DelayedApp(ExprAtomicFlag.NonAtomic, false, None, arg, unionRanges lidRange arg.Range)) + |> List.map (fun arg -> DelayedApp(ExprAtomicFlag.NonAtomic, false, None, arg, unionRanges mLongId arg.Range)) - let activePatExpr, tpenv = PropagateThenTcDelayed cenv (MustEqual activePatType) env tpenv m vexp vexpty ExprAtomicFlag.NonAtomic delayed + let activePatExpr, tpenv = PropagateThenTcDelayed cenv (MustEqual activePatType) env tpenv m vExpr vExprTy ExprAtomicFlag.NonAtomic delayed let patEnvR = TcPatLinearEnv(tpenv, names, takenNames) @@ -6264,13 +6264,13 @@ and TcExprILAssembly cenv overallTy env tpenv (ilInstrs, synTyArgs, synArgs, syn and RewriteRangeExpr synExpr = match synExpr with // a..b..c (parsed as (a..b)..c ) - | SynExpr.IndexRange(Some (SynExpr.IndexRange(Some synExpr1, _, Some synStepExpr, _, _, _)), _, Some synExpr2, _m1, _m2, wholem) -> - Some (mkSynTrifix wholem ".. .." synExpr1 synStepExpr synExpr2) + | SynExpr.IndexRange(Some (SynExpr.IndexRange(Some synExpr1, _, Some synStepExpr, _, _, _)), _, Some synExpr2, _m1, _m2, mWhole) -> + Some (mkSynTrifix mWhole ".. .." synExpr1 synStepExpr synExpr2) // a..b - | SynExpr.IndexRange (Some synExpr1, mOperator, Some synExpr2, _m1, _m2, wholem) -> + | SynExpr.IndexRange (Some synExpr1, mOperator, Some synExpr2, _m1, _m2, mWhole) -> let otherExpr = match mkSynInfix mOperator synExpr1 ".." synExpr2 with - | SynExpr.App (a, b, c, d, _) -> SynExpr.App (a, b, c, d, wholem) + | SynExpr.App (a, b, c, d, _) -> SynExpr.App (a, b, c, d, mWhole) | _ -> failwith "impossible" Some otherExpr | _ -> None @@ -7696,8 +7696,8 @@ and TcForEachExpr cenv overallTy env tpenv (seqExprOnly, isFromSource, synPat, s match stripDebugPoints enumExpr with // optimize 'for i in n .. m do' - | Expr.App (Expr.Val (vf, _, _), _, [tyarg], [startExpr;finishExpr], _) - when valRefEq g vf g.range_op_vref && typeEquiv g tyarg g.int_ty -> + | Expr.App (Expr.Val (vref, _, _), _, [tyarg], [startExpr;finishExpr], _) + when valRefEq g vref g.range_op_vref && typeEquiv g tyarg g.int_ty -> (g.int32_ty, (fun _ x -> x), id, Choice1Of3 (startExpr, finishExpr)) // optimize 'for i in arr do' @@ -7883,9 +7883,9 @@ and Propagate cenv (overallTy: OverallTy) (env: TcEnv) tpenv (expr: ApplicableEx // See RFC FS-1053.md let isAddrOf = match expr with - | ApplicableExpr(_, Expr.App (Expr.Val (vf, _, _), _, _, [], _), _) - when (valRefEq g vf g.addrof_vref || - valRefEq g vf g.nativeptr_tobyref_vref) -> true + | ApplicableExpr(_, Expr.App (Expr.Val (vref, _, _), _, _, [], _), _) + when (valRefEq g vref g.addrof_vref || + valRefEq g vref g.nativeptr_tobyref_vref) -> true | _ -> false propagate isAddrOf delayedList' mExprAndArg resultTy @@ -8195,12 +8195,12 @@ and TcApplicationThen cenv (overallTy: OverallTy) env tpenv mExprAndArg synLeftE // will have debug points on "f expr1" and "g expr2" let env = match leftExpr with - | ApplicableExpr(_, Expr.Val (vf, _, _), _) - | ApplicableExpr(_, Expr.App (Expr.Val (vf, _, _), _, _, [_], _), _) - when valRefEq g vf g.and_vref - || valRefEq g vf g.and2_vref - || valRefEq g vf g.or_vref - || valRefEq g vf g.or2_vref -> + | ApplicableExpr(_, Expr.Val (vref, _, _), _) + | ApplicableExpr(_, Expr.App (Expr.Val (vref, _, _), _, _, [_], _), _) + when valRefEq g vref g.and_vref + || valRefEq g vref g.and2_vref + || valRefEq g vref g.or_vref + || valRefEq g vref g.or2_vref -> { env with eIsControlFlow = true } | _ -> env @@ -8757,7 +8757,7 @@ and TcValueItemThen cenv overallTy env vref tpenv mItem afterResolution delayed vTy // Always allow subsumption on assignment to fields let expr2R, tpenv = TcExprFlex cenv true false vty2 env tpenv expr2 - let vexp = + let vExpr = if isInByrefTy g vTy then errorR(Error(FSComp.SR.writeToReadOnlyByref(), mStmt)) mkAddrSet mStmt vref expr2R @@ -8766,7 +8766,7 @@ and TcValueItemThen cenv overallTy env vref tpenv mItem afterResolution delayed else mkValSet mStmt vref expr2R - PropagateThenTcDelayed cenv overallTy env tpenv mStmt (MakeApplicableExprNoFlex cenv vexp) (tyOfExpr g vexp) ExprAtomicFlag.NonAtomic otherDelayed + PropagateThenTcDelayed cenv overallTy env tpenv mStmt (MakeApplicableExprNoFlex cenv vExpr) (tyOfExpr g vExpr) ExprAtomicFlag.NonAtomic otherDelayed // Value instantiation: v ... | DelayedTypeApp(tys, _mTypeArgs, mExprAndTypeArgs) :: otherDelayed -> @@ -8780,24 +8780,24 @@ and TcValueItemThen cenv overallTy env vref tpenv mItem afterResolution delayed match tys with | [SynType.Var(SynTypar(id, _, false) as tp, _m)] -> let _tpR, tpenv = TcTypeOrMeasureParameter None cenv env ImplicitlyBoundTyparsAllowed.NoNewTypars tpenv tp - let vexp = TcNameOfExprResult cenv id mExprAndTypeArgs - let vexpFlex = MakeApplicableExprNoFlex cenv vexp + let vExpr = TcNameOfExprResult cenv id mExprAndTypeArgs + let vexpFlex = MakeApplicableExprNoFlex cenv vExpr PropagateThenTcDelayed cenv overallTy env tpenv mExprAndTypeArgs vexpFlex g.string_ty ExprAtomicFlag.Atomic otherDelayed | _ -> error (Error(FSComp.SR.expressionHasNoName(), mExprAndTypeArgs)) | _ -> let checkTys tpenv kinds = TcTypesOrMeasures (Some kinds) cenv NewTyparsOK CheckCxs ItemOccurence.UseInType env tpenv tys mItem - let _, vexp, isSpecial, _, _, tpenv = TcVal true cenv env tpenv vref (Some (NormalValUse, checkTys)) (Some afterResolution) mItem + let _, vExpr, isSpecial, _, _, tpenv = TcVal true cenv env tpenv vref (Some (NormalValUse, checkTys)) (Some afterResolution) mItem - let vexpFlex = (if isSpecial then MakeApplicableExprNoFlex cenv vexp else MakeApplicableExprWithFlex cenv env vexp) + let vexpFlex = (if isSpecial then MakeApplicableExprNoFlex cenv vExpr else MakeApplicableExprWithFlex cenv env vExpr) // We need to eventually record the type resolution for an expression, but this is done // inside PropagateThenTcDelayed, so we don't have to explicitly call 'CallExprHasTypeSink' here PropagateThenTcDelayed cenv overallTy env tpenv mExprAndTypeArgs vexpFlex vexpFlex.Type ExprAtomicFlag.Atomic otherDelayed // Value get | _ -> - let _, vexp, isSpecial, _, _, tpenv = TcVal true cenv env tpenv vref None (Some afterResolution) mItem - let vexpFlex = (if isSpecial then MakeApplicableExprNoFlex cenv vexp else MakeApplicableExprWithFlex cenv env vexp) + let _, vExpr, isSpecial, _, _, tpenv = TcVal true cenv env tpenv vref None (Some afterResolution) mItem + let vexpFlex = (if isSpecial then MakeApplicableExprNoFlex cenv vExpr else MakeApplicableExprWithFlex cenv env vExpr) PropagateThenTcDelayed cenv overallTy env tpenv mItem vexpFlex vexpFlex.Type ExprAtomicFlag.Atomic delayed and TcPropertyItemThen cenv overallTy env nm pinfos tpenv mItem afterResolution delayed = @@ -9054,8 +9054,8 @@ and TcLookupThen cenv overallTy env tpenv mObjExpr objExpr objExprTy longId dela PropagateThenTcDelayed cenv overallTy env tpenv mExprAndItem (MakeApplicableExprWithFlex cenv env objExpr') fieldTy ExprAtomicFlag.Atomic delayed | Item.AnonRecdField (anonInfo, tinst, n, _) -> - let tgty = TType_anon (anonInfo, tinst) - AddCxTypeMustSubsumeType ContextInfo.NoContext env.DisplayEnv cenv.css mItem NoTrace tgty objExprTy + let tgtTy = TType_anon (anonInfo, tinst) + AddCxTypeMustSubsumeType ContextInfo.NoContext env.DisplayEnv cenv.css mItem NoTrace tgtTy objExprTy let fieldTy = List.item n tinst match delayed with | DelayedSet _ :: _otherDelayed -> @@ -9107,7 +9107,7 @@ and TcEventItemThen cenv overallTy env tpenv mItem mExprAndItem objDetails (einf MethInfoChecks g cenv.amap true None objArgs env.eAccessRights mItem delInvokeMeth // This checks for and drops the 'object' sender - let argsTy = ArgsTypOfEventInfo cenv.infoReader mItem ad einfo + let argsTy = ArgsTypeOfEventInfo cenv.infoReader mItem ad einfo if not (slotSigHasVoidReturnTy (delInvokeMeth.GetSlotSig(cenv.amap, mItem))) then errorR (nonStandardEventError einfo.EventName mItem) let delEventTy = mkIEventType g delTy argsTy @@ -11264,14 +11264,13 @@ and AnalyzeRecursiveDecl let rec analyzeRecursiveDeclPat tpenv pat = match pat with - | SynPat.FromParseError(pat', _) -> analyzeRecursiveDeclPat tpenv pat' - | SynPat.Typed(pat', cty, _) -> - let ctyR, tpenv = TcTypeAndRecover cenv NewTyparsOK CheckCxs ItemOccurence.UseInType envinner tpenv cty + | SynPat.FromParseError(innerPat, _) -> analyzeRecursiveDeclPat tpenv innerPat + | SynPat.Typed(innerPat, tgtTy, _) -> + let ctyR, tpenv = TcTypeAndRecover cenv NewTyparsOK CheckCxs ItemOccurence.UseInType envinner tpenv tgtTy UnifyTypes cenv envinner mBinding ty ctyR - analyzeRecursiveDeclPat tpenv pat' - | SynPat.Attrib(_pat', _attribs, m) -> + analyzeRecursiveDeclPat tpenv innerPat + | SynPat.Attrib(_innerPat, _attribs, m) -> error(Error(FSComp.SR.tcAttributesInvalidInPatterns(), m)) - //analyzeRecursiveDeclPat pat' // This is for the construct 'let rec x = ... and do ... and y = ...' (DEPRECATED IN pars.mly ) // diff --git a/src/Compiler/Checking/CheckExpressions.fsi b/src/Compiler/Checking/CheckExpressions.fsi index 8b5f1878532..2a83a61d50f 100644 --- a/src/Compiler/Checking/CheckExpressions.fsi +++ b/src/Compiler/Checking/CheckExpressions.fsi @@ -1180,7 +1180,7 @@ val TcPatLongIdentActivePatternCase: vFlags: TcPatValFlags -> patEnv: TcPatLinearEnv -> ty: TType -> - lidRange: range * item: Item * apref: ActivePatternElemRef * args: SynPat list * m: range -> + mLongId: range * item: Item * apref: ActivePatternElemRef * args: SynPat list * m: range -> (TcPatPhase2Input -> Pattern) * TcPatLinearEnv /// The pattern syntax can also represent active pattern arguments. This routine diff --git a/src/Compiler/Checking/CheckFormatStrings.fs b/src/Compiler/Checking/CheckFormatStrings.fs index fb4b4cec03a..1334b1bf54c 100644 --- a/src/Compiler/Checking/CheckFormatStrings.fs +++ b/src/Compiler/Checking/CheckFormatStrings.fs @@ -22,9 +22,9 @@ let copyAndFixupFormatTypar m tp = let lowestDefaultPriority = 0 (* See comment on TyparConstraint.DefaultsTo *) -let mkFlexibleFormatTypar m tys dflt = +let mkFlexibleFormatTypar m tys dfltTy = let tp = Construct.NewTypar (TyparKind.Type, TyparRigidity.Rigid, SynTypar(mkSynId m "fmt",TyparStaticReq.HeadType,true),false,TyparDynamicReq.Yes,[],false,false) - tp.SetConstraints [ TyparConstraint.SimpleChoice (tys,m); TyparConstraint.DefaultsTo (lowestDefaultPriority,dflt,m)] + tp.SetConstraints [ TyparConstraint.SimpleChoice (tys,m); TyparConstraint.DefaultsTo (lowestDefaultPriority,dfltTy,m)] copyAndFixupFormatTypar m tp let mkFlexibleIntFormatTypar (g: TcGlobals) m = @@ -449,19 +449,19 @@ let parseFormatStringInternal | Some '+' -> collectSpecifierLocation fragLine fragCol 1 let i = skipPossibleInterpolationHole (i+1) - let xty = NewInferenceType g - percentATys.Add(xty) - parseLoop ((posi, xty) :: acc) (i, fragLine, fragCol+1) fragments + let aTy = NewInferenceType g + percentATys.Add(aTy) + parseLoop ((posi, aTy) :: acc) (i, fragLine, fragCol+1) fragments | Some n -> failwith (FSComp.SR.forDoesNotSupportPrefixFlag(ch.ToString(), n.ToString())) | 'a' -> checkOtherFlags ch - let xty = NewInferenceType g - let fty = mkFunTy g printerArgTy (mkFunTy g xty printerResidueTy) + let aTy = NewInferenceType g + let fTy = mkFunTy g printerArgTy (mkFunTy g aTy printerResidueTy) collectSpecifierLocation fragLine fragCol 2 let i = skipPossibleInterpolationHole (i+1) - parseLoop ((Option.map ((+)1) posi, xty) :: (posi, fty) :: acc) (i, fragLine, fragCol+1) fragments + parseLoop ((Option.map ((+)1) posi, aTy) :: (posi, fTy) :: acc) (i, fragLine, fragCol+1) fragments | 't' -> checkOtherFlags ch diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index b39d6481517..7ced746b6a1 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -503,7 +503,7 @@ and TcPatLongIdent warnOnUpper cenv env ad valReprInfo vFlags (patEnv: TcPatLine | SynArgPats.Pats [] -> warnOnUpper | _ -> AllIdsOK - let lidRange = rangeOfLid longId + let mLongId = rangeOfLid longId match ResolvePatternLongIdent cenv.tcSink cenv.nameResolver warnOnUpperForId false m ad env.NameEnv TypeNameResolutionInfo.Default longId with | Item.NewDef id -> @@ -519,19 +519,19 @@ and TcPatLongIdent warnOnUpper cenv env ad valReprInfo vFlags (patEnv: TcPatLine let args = GetSynArgPatterns args - TcPatLongIdentActivePatternCase warnOnUpper cenv env vFlags patEnv ty (lidRange, item, apref, args, m) + TcPatLongIdentActivePatternCase warnOnUpper cenv env vFlags patEnv ty (mLongId, item, apref, args, m) | Item.UnionCase _ | Item.ExnCase _ as item -> - TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (lidRange, item, args, m) + TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (mLongId, item, args, m) | Item.ILField finfo -> - TcPatLongIdentILField warnOnUpper cenv env vFlags patEnv ty (lidRange, finfo, args, m) + TcPatLongIdentILField warnOnUpper cenv env vFlags patEnv ty (mLongId, finfo, args, m) | Item.RecdField rfinfo -> - TcPatLongIdentRecdField warnOnUpper cenv env vFlags patEnv ty (lidRange, rfinfo, args, m) + TcPatLongIdentRecdField warnOnUpper cenv env vFlags patEnv ty (mLongId, rfinfo, args, m) | Item.Value vref -> - TcPatLongIdentLiteral warnOnUpper cenv env vFlags patEnv ty (lidRange, vref, args, m) + TcPatLongIdentLiteral warnOnUpper cenv env vFlags patEnv ty (mLongId, vref, args, m) | _ -> error (Error(FSComp.SR.tcRequireVarConstRecogOrLiteral(), m)) @@ -577,9 +577,9 @@ and ApplyUnionCaseOrExn m (cenv: cenv) env overallTy item = let ucref = ucinfo.UnionCaseRef CheckUnionCaseAttributes g ucref m |> CommitOperationResult CheckUnionCaseAccessible cenv.amap m ad ucref |> ignore - let gtyp2 = actualResultTyOfUnionCase ucinfo.TypeInst ucref + let resTy = actualResultTyOfUnionCase ucinfo.TypeInst ucref let inst = mkTyparInst ucref.TyconRef.TyparsNoRange ucinfo.TypeInst - UnifyTypes cenv env m overallTy gtyp2 + UnifyTypes cenv env m overallTy resTy let mkf mArgs args = TPat_unioncase(ucref, ucinfo.TypeInst, args, unionRanges m mArgs) mkf, actualTysOfUnionCaseFields inst ucref, [ for f in ucref.AllFieldsAsList -> f.Id ] @@ -587,11 +587,11 @@ and ApplyUnionCaseOrExn m (cenv: cenv) env overallTy item = invalidArg "item" "not a union case or exception reference" /// Check a long identifier 'Case' or 'Case argsR that has been resolved to a union case or F# exception constructor -and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (lidRange, item, args, m) = +and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (mLongId, item, args, m) = let g = cenv.g // Report information about the case occurrence to IDE - CallNameResolutionSink cenv.tcSink (lidRange, env.NameEnv, item, emptyTyparInst, ItemOccurence.Pattern, env.eAccessRights) + CallNameResolutionSink cenv.tcSink (mLongId, env.NameEnv, item, emptyTyparInst, ItemOccurence.Pattern, env.eAccessRights) let mkf, argTys, argNames = ApplyUnionCaseOrExn m cenv env ty item let numArgTys = argTys.Length @@ -693,38 +693,38 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (l (fun values -> mkf m (List.map (fun f -> f values) argsR)), acc /// Check a long identifier that has been resolved to an IL field - valid if a literal -and TcPatLongIdentILField warnOnUpper (cenv: cenv) env vFlags patEnv ty (lidRange, finfo, args, m) = +and TcPatLongIdentILField warnOnUpper (cenv: cenv) env vFlags patEnv ty (mLongId, finfo, args, m) = let g = cenv.g - CheckILFieldInfoAccessible g cenv.amap lidRange env.AccessRights finfo + CheckILFieldInfoAccessible g cenv.amap mLongId env.AccessRights finfo if not finfo.IsStatic then - errorR (Error (FSComp.SR.tcFieldIsNotStatic finfo.FieldName, lidRange)) + errorR (Error (FSComp.SR.tcFieldIsNotStatic finfo.FieldName, mLongId)) CheckILFieldAttributes g finfo m match finfo.LiteralValue with | None -> - error (Error (FSComp.SR.tcFieldNotLiteralCannotBeUsedInPattern (), lidRange)) + error (Error (FSComp.SR.tcFieldNotLiteralCannotBeUsedInPattern (), mLongId)) | Some lit -> CheckNoArgsForLiteral args m let _, acc = TcArgPats warnOnUpper cenv env vFlags patEnv args UnifyTypes cenv env m ty (finfo.FieldType (cenv.amap, m)) - let c' = TcFieldInit lidRange lit + let c' = TcFieldInit mLongId lit let item = Item.ILField finfo - CallNameResolutionSink cenv.tcSink (lidRange, env.NameEnv, item, emptyTyparInst, ItemOccurence.Pattern, env.AccessRights) + CallNameResolutionSink cenv.tcSink (mLongId, env.NameEnv, item, emptyTyparInst, ItemOccurence.Pattern, env.AccessRights) (fun _ -> TPat_const (c', m)), acc /// Check a long identifier that has been resolved to a record field -and TcPatLongIdentRecdField warnOnUpper cenv env vFlags patEnv ty (lidRange, rfinfo, args, m) = +and TcPatLongIdentRecdField warnOnUpper cenv env vFlags patEnv ty (mLongId, rfinfo, args, m) = let g = cenv.g - CheckRecdFieldInfoAccessible cenv.amap lidRange env.AccessRights rfinfo - if not rfinfo.IsStatic then errorR (Error (FSComp.SR.tcFieldIsNotStatic(rfinfo.DisplayName), lidRange)) - CheckRecdFieldInfoAttributes g rfinfo lidRange |> CommitOperationResult + CheckRecdFieldInfoAccessible cenv.amap mLongId env.AccessRights rfinfo + if not rfinfo.IsStatic then errorR (Error (FSComp.SR.tcFieldIsNotStatic(rfinfo.DisplayName), mLongId)) + CheckRecdFieldInfoAttributes g rfinfo mLongId |> CommitOperationResult match rfinfo.LiteralValue with - | None -> error (Error(FSComp.SR.tcFieldNotLiteralCannotBeUsedInPattern(), lidRange)) + | None -> error (Error(FSComp.SR.tcFieldNotLiteralCannotBeUsedInPattern(), mLongId)) | Some lit -> CheckNoArgsForLiteral args m let _, acc = TcArgPats warnOnUpper cenv env vFlags patEnv args @@ -733,26 +733,26 @@ and TcPatLongIdentRecdField warnOnUpper cenv env vFlags patEnv ty (lidRange, rfi let item = Item.RecdField rfinfo // FUTURE: can we do better than emptyTyparInst here, in order to display instantiations // of type variables in the quick info provided in the IDE. - CallNameResolutionSink cenv.tcSink (lidRange, env.NameEnv, item, emptyTyparInst, ItemOccurence.Pattern, env.AccessRights) + CallNameResolutionSink cenv.tcSink (mLongId, env.NameEnv, item, emptyTyparInst, ItemOccurence.Pattern, env.AccessRights) (fun _ -> TPat_const (lit, m)), acc /// Check a long identifier that has been resolved to an F# value that is a literal -and TcPatLongIdentLiteral warnOnUpper (cenv: cenv) env vFlags patEnv ty (lidRange, vref, args, m) = +and TcPatLongIdentLiteral warnOnUpper (cenv: cenv) env vFlags patEnv ty (mLongId, vref, args, m) = let g = cenv.g let (TcPatLinearEnv(tpenv, _, _)) = patEnv match vref.LiteralValue with | None -> error (Error(FSComp.SR.tcNonLiteralCannotBeUsedInPattern(), m)) | Some lit -> - let _, _, _, vexpty, _, _ = TcVal true cenv env tpenv vref None None lidRange - CheckValAccessible lidRange env.AccessRights vref - CheckFSharpAttributes g vref.Attribs lidRange |> CommitOperationResult + let _, _, _, vexpty, _, _ = TcVal true cenv env tpenv vref None None mLongId + CheckValAccessible mLongId env.AccessRights vref + CheckFSharpAttributes g vref.Attribs mLongId |> CommitOperationResult CheckNoArgsForLiteral args m let _, acc = TcArgPats warnOnUpper cenv env vFlags patEnv args UnifyTypes cenv env m ty vexpty let item = Item.Value vref - CallNameResolutionSink cenv.tcSink (lidRange, env.NameEnv, item, emptyTyparInst, ItemOccurence.Pattern, env.AccessRights) + CallNameResolutionSink cenv.tcSink (mLongId, env.NameEnv, item, emptyTyparInst, ItemOccurence.Pattern, env.AccessRights) (fun _ -> TPat_const (lit, m)), acc and TcPatterns warnOnUpper cenv env vFlags s argTys args = diff --git a/src/Compiler/Checking/ConstraintSolver.fs b/src/Compiler/Checking/ConstraintSolver.fs index 7d7097dc25a..0119827bdf5 100644 --- a/src/Compiler/Checking/ConstraintSolver.fs +++ b/src/Compiler/Checking/ConstraintSolver.fs @@ -136,12 +136,12 @@ let FreshenTypars m tpsorig = match tpsorig with | [] -> [] | _ -> - let _, _, tptys = FreshenTypeInst m tpsorig - tptys + let _, _, tpTys = FreshenTypeInst m tpsorig + tpTys let FreshenMethInfo m (minfo: MethInfo) = - let _, _, tptys = FreshMethInst m (minfo.GetFormalTyparsOfDeclaringType m) minfo.DeclaringTypeInst minfo.FormalMethodTypars - tptys + let _, _, tpTys = FreshMethInst m (minfo.GetFormalTyparsOfDeclaringType m) minfo.DeclaringTypeInst minfo.FormalMethodTypars + tpTys //------------------------------------------------------------------------- // Unification of types: solve/record equality constraints @@ -362,7 +362,7 @@ let rec occursCheck g un ty = | TType_app (_, l, _) | TType_anon(_, l) | TType_tuple (_, l) -> List.exists (occursCheck g un) l - | TType_fun (d, r, _) -> occursCheck g un d || occursCheck g un r + | TType_fun (domainTy, rangeTy, _) -> occursCheck g un domainTy || occursCheck g un rangeTy | TType_var (r, _) -> typarEq un r | TType_forall (_, tau) -> occursCheck g un tau | _ -> false @@ -787,7 +787,7 @@ let UnifyMeasureWithOne (csenv: ConstraintSolverEnv) trace ms = match FindPreferredTypar nonRigidVars with | (v, e) :: vs -> let unexpandedCons = ListMeasureConOccsWithNonZeroExponents csenv.g false ms - let newms = ProdMeasures (List.map (fun (c, e') -> Measure.RationalPower (Measure.Con c, NegRational (DivRational e' e))) unexpandedCons + let newms = ProdMeasures (List.map (fun (c, e') -> Measure.RationalPower (Measure.Const c, NegRational (DivRational e' e))) unexpandedCons @ List.map (fun (v, e') -> Measure.RationalPower (Measure.Var v, NegRational (DivRational e' e))) (vs @ rigidVars)) SubstMeasureWarnIfRigid csenv trace v newms @@ -818,7 +818,7 @@ let SimplifyMeasure g vars ms = let newms = ProdMeasures [ for (c, e') in nonZeroCon do - Measure.RationalPower (Measure.Con c, NegRational (DivRational e' e)) + Measure.RationalPower (Measure.Const c, NegRational (DivRational e' e)) for (v', e') in nonZeroVar do if typarEq v v' then newvarExpr @@ -841,11 +841,11 @@ let rec SimplifyMeasuresInType g resultFirst (generalizable, generalized as para | TType_anon (_,l) | TType_tuple (_, l) -> SimplifyMeasuresInTypes g param l - | TType_fun (d, r, _) -> + | TType_fun (domainTy, rangeTy, _) -> if resultFirst then - SimplifyMeasuresInTypes g param [r;d] + SimplifyMeasuresInTypes g param [rangeTy;domainTy] else - SimplifyMeasuresInTypes g param [d;r] + SimplifyMeasuresInTypes g param [domainTy;rangeTy] | TType_var _ -> param @@ -886,7 +886,7 @@ let rec GetMeasureVarGcdInType v ty = | TType_anon (_,l) | TType_tuple (_, l) -> GetMeasureVarGcdInTypes v l - | TType_fun (d, r, _) -> GcdRational (GetMeasureVarGcdInType v d) (GetMeasureVarGcdInType v r) + | TType_fun (domainTy, rangeTy, _) -> GcdRational (GetMeasureVarGcdInType v domainTy) (GetMeasureVarGcdInType v rangeTy) | TType_var _ -> ZeroRational | TType_forall (_, tau) -> GetMeasureVarGcdInType v tau | TType_measure unt -> MeasureVarExponent v unt @@ -1027,7 +1027,7 @@ and solveTypMeetsTyparConstraints (csenv: ConstraintSolverEnv) ndeep m2 trace ty AddConstraint csenv ndeep m2 trace destTypar (TyparConstraint.DefaultsTo(priority, dty, m)) | TyparConstraint.SupportsNull m2 -> SolveTypeUseSupportsNull csenv ndeep m2 trace ty - | TyparConstraint.IsEnum(underlying, m2) -> SolveTypeIsEnum csenv ndeep m2 trace ty underlying + | TyparConstraint.IsEnum(underlyingTy, m2) -> SolveTypeIsEnum csenv ndeep m2 trace ty underlyingTy | TyparConstraint.SupportsComparison(m2) -> SolveTypeSupportsComparison csenv ndeep m2 trace ty | TyparConstraint.SupportsEquality(m2) -> SolveTypeSupportsEquality csenv ndeep m2 trace ty | TyparConstraint.IsDelegate(aty, bty, m2) -> SolveTypeIsDelegate csenv ndeep m2 trace ty aty bty @@ -1054,17 +1054,17 @@ and SolveTyparEqualsType (csenv: ConstraintSolverEnv) ndeep m2 (trace: OptionalT } // Like SolveTyparEqualsType but asserts all typar equalities simultaneously instead of one by one -and SolveTyparsEqualTypes (csenv: ConstraintSolverEnv) ndeep m2 (trace: OptionalTrace) tptys tys = trackErrors { - do! (tptys, tys) ||> Iterate2D (fun tpty ty -> - match tpty with +and SolveTyparsEqualTypes (csenv: ConstraintSolverEnv) ndeep m2 (trace: OptionalTrace) tpTys tys = trackErrors { + do! (tpTys, tys) ||> Iterate2D (fun tpTy ty -> + match tpTy with | TType_var (r, _) | TType_measure (Measure.Var r) -> - SolveTyparEqualsTypePart1 csenv m2 trace tpty r ty + SolveTyparEqualsTypePart1 csenv m2 trace tpTy r ty | _ -> failwith "SolveTyparsEqualTypes") - do! (tptys, tys) ||> Iterate2D (fun tpty ty -> - match tpty with + do! (tpTys, tys) ||> Iterate2D (fun tpTy ty -> + match tpTy with | TType_var (r, _) | TType_measure (Measure.Var r) -> SolveTyparEqualsTypePart2 csenv ndeep m2 trace r ty @@ -1135,7 +1135,7 @@ and SolveTypeEqualsType (csenv: ConstraintSolverEnv) ndeep m2 (trace: OptionalTr match sty1, sty2 with // type vars inside forall-types may be alpha-equivalent - | TType_var (tp1, _), TType_var (tp2, _) when typarEq tp1 tp2 || (match aenv.EquivTypars.TryFind tp1 with | Some v when typeEquiv g v ty2 -> true | _ -> false) -> + | TType_var (tp1, _), TType_var (tp2, _) when typarEq tp1 tp2 || (match aenv.EquivTypars.TryFind tp1 with | Some tpTy1 when typeEquiv g tpTy1 ty2 -> true | _ -> false) -> CompleteD // 'v1 = 'v2 @@ -1173,18 +1173,18 @@ and SolveTypeEqualsType (csenv: ConstraintSolverEnv) ndeep m2 (trace: OptionalTr SolveAnonInfoEqualsAnonInfo csenv m2 anonInfo1 anonInfo2 ++ (fun () -> SolveTypeEqualsTypeEqns csenv ndeep m2 trace None l1 l2) - | TType_fun (d1, r1, _), TType_fun (d2, r2, _) -> - SolveFunTypeEqn csenv ndeep m2 trace None d1 d2 r1 r2 + | TType_fun (domainTy1, rangeTy1, _), TType_fun (domainTy2, rangeTy2, _) -> + SolveFunTypeEqn csenv ndeep m2 trace None domainTy1 domainTy2 rangeTy1 rangeTy2 | TType_measure ms1, TType_measure ms2 -> UnifyMeasures csenv trace ms1 ms2 - | TType_forall(tps1, rty1), TType_forall(tps2, rty2) -> + | TType_forall(tps1, bodyTy1), TType_forall(tps2, bodyTy2) -> if tps1.Length <> tps2.Length then localAbortD else let aenv = aenv.BindEquivTypars tps1 tps2 let csenv = {csenv with EquivEnv = aenv } if not (typarsAEquiv g aenv tps1 tps2) then localAbortD else - SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace rty1 rty2 + SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace bodyTy1 bodyTy2 | TType_ucase (uc1, l1), TType_ucase (uc2, l2) when g.unionCaseRefEq uc1 uc2 -> SolveTypeEqualsTypeEqns csenv ndeep m2 trace None l1 l2 | _ -> localAbortD @@ -1214,9 +1214,9 @@ and SolveTypeEqualsTypeEqns csenv ndeep m2 trace cxsln origl1 origl2 = ErrorD(ConstraintSolverTupleDiffLengths(csenv.DisplayEnv, origl1, origl2, csenv.m, m2)) loop origl1 origl2 -and SolveFunTypeEqn csenv ndeep m2 trace cxsln d1 d2 r1 r2 = trackErrors { - do! SolveTypeEqualsTypeKeepAbbrevsWithCxsln csenv ndeep m2 trace cxsln d1 d2 - return! SolveTypeEqualsTypeKeepAbbrevsWithCxsln csenv ndeep m2 trace cxsln r1 r2 +and SolveFunTypeEqn csenv ndeep m2 trace cxsln domainTy1 domainTy2 rangeTy1 rangeTy2 = trackErrors { + do! SolveTypeEqualsTypeKeepAbbrevsWithCxsln csenv ndeep m2 trace cxsln domainTy1 domainTy2 + return! SolveTypeEqualsTypeKeepAbbrevsWithCxsln csenv ndeep m2 trace cxsln rangeTy1 rangeTy2 } // ty1: expected @@ -1240,7 +1240,7 @@ and SolveTypeSubsumesType (csenv: ConstraintSolverEnv) ndeep m2 (trace: Optional match sty1, sty2 with | TType_var (tp1, _), _ -> match aenv.EquivTypars.TryFind tp1 with - | Some v -> SolveTypeSubsumesType csenv ndeep m2 trace cxsln v ty2 + | Some tpTy1 -> SolveTypeSubsumesType csenv ndeep m2 trace cxsln tpTy1 ty2 | _ -> match sty2 with | TType_var (r2, _) when typarEq tp1 r2 -> CompleteD @@ -1258,8 +1258,8 @@ and SolveTypeSubsumesType (csenv: ConstraintSolverEnv) ndeep m2 (trace: Optional SolveAnonInfoEqualsAnonInfo csenv m2 anonInfo1 anonInfo2 ++ (fun () -> SolveTypeEqualsTypeEqns csenv ndeep m2 trace cxsln l1 l2) (* nb. can unify since no variance *) - | TType_fun (d1, r1, _), TType_fun (d2, r2, _) -> - SolveFunTypeEqn csenv ndeep m2 trace cxsln d1 d2 r1 r2 (* nb. can unify since no variance *) + | TType_fun (domainTy1, rangeTy1, _), TType_fun (domainTy2, rangeTy2, _) -> + SolveFunTypeEqn csenv ndeep m2 trace cxsln domainTy1 domainTy2 rangeTy1 rangeTy2 (* nb. can unify since no variance *) | TType_measure ms1, TType_measure ms2 -> UnifyMeasures csenv trace ms1 ms2 @@ -1306,17 +1306,17 @@ and SolveTypeSubsumesType (csenv: ConstraintSolverEnv) ndeep m2 (trace: Optional // Note we don't support co-variance on array types nor // the special .NET conversions for these types match ty1 with - | AppTy g (tcr1, tinst) when + | AppTy g (tcref1, tinst1) when isArray1DTy g ty2 && - (tyconRefEq g tcr1 g.tcref_System_Collections_Generic_IList || - tyconRefEq g tcr1 g.tcref_System_Collections_Generic_ICollection || - tyconRefEq g tcr1 g.tcref_System_Collections_Generic_IReadOnlyList || - tyconRefEq g tcr1 g.tcref_System_Collections_Generic_IReadOnlyCollection || - tyconRefEq g tcr1 g.tcref_System_Collections_Generic_IEnumerable) -> - match tinst with - | [ty1arg] -> - let ty2arg = destArrayTy g ty2 - SolveTypeEqualsTypeKeepAbbrevsWithCxsln csenv ndeep m2 trace cxsln ty1arg ty2arg + (tyconRefEq g tcref1 g.tcref_System_Collections_Generic_IList || + tyconRefEq g tcref1 g.tcref_System_Collections_Generic_ICollection || + tyconRefEq g tcref1 g.tcref_System_Collections_Generic_IReadOnlyList || + tyconRefEq g tcref1 g.tcref_System_Collections_Generic_IReadOnlyCollection || + tyconRefEq g tcref1 g.tcref_System_Collections_Generic_IEnumerable) -> + match tinst1 with + | [elemTy1] -> + let elemTy2 = destArrayTy g ty2 + SolveTypeEqualsTypeKeepAbbrevsWithCxsln csenv ndeep m2 trace cxsln elemTy1 elemTy2 | _ -> error(InternalError("destArrayTy", m)) | _ -> @@ -1525,13 +1525,13 @@ and SolveMemberConstraint (csenv: ConstraintSolverEnv) ignoreUnresolvedOverload if rankOfArrayTy g ty <> argTys.Length - 1 then do! ErrorD(ConstraintSolverError(FSComp.SR.csIndexArgumentMismatch((rankOfArrayTy g ty), (argTys.Length - 1)), m, m2)) - let argTys, ety = List.frontAndBack argTys + let argTys, lastTy = List.frontAndBack argTys for argTy in argTys do do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace argTy g.int_ty - let etys = destArrayTy g ty - do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace ety etys + let elemTy = destArrayTy g ty + do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace lastTy elemTy return TTraitBuiltIn | [], _, false, ("op_BitwiseAnd" | "op_BitwiseOr" | "op_ExclusiveOr"), [argTy1;argTy2] @@ -1845,10 +1845,10 @@ and MemberConstraintSolutionOfMethInfo css m minfo minst = match callMethInfoOpt, callExpr with | Some methInfo, Expr.Op (TOp.ILCall (_, _, _, _, NormalValUse, _, _, ilMethRef, _, methInst, _), [], args, m) when (args, (objArgVars@allArgVars)) ||> List.lengthsEqAndForall2 (fun a b -> match a with Expr.Val (v, _, _) -> valEq v.Deref b | _ -> false) -> - let declaringType = ImportProvidedType amap m (methInfo.PApply((fun x -> x.DeclaringType), m)) - if isILAppTy g declaringType then + let declaringTy = ImportProvidedType amap m (methInfo.PApply((fun x -> x.DeclaringType), m)) + if isILAppTy g declaringTy then let extOpt = None // EXTENSION METHODS FROM TYPE PROVIDERS: for extension methods coming from the type providers we would have something here. - ILMethSln(declaringType, extOpt, ilMethRef, methInst) + ILMethSln(declaringTy, extOpt, ilMethRef, methInst) else closedExprSln | _ -> @@ -2090,8 +2090,8 @@ and AddConstraint (csenv: ConstraintSolverEnv) ndeep m2 trace tp newConstraint | TyparConstraint.IsReferenceType _, TyparConstraint.IsReferenceType _ | TyparConstraint.RequiresDefaultConstructor _, TyparConstraint.RequiresDefaultConstructor _ -> true | TyparConstraint.SimpleChoice (tys1, _), TyparConstraint.SimpleChoice (tys2, _) -> ListSet.isSubsetOf (typeEquiv g) tys1 tys2 - | TyparConstraint.DefaultsTo (priority1, dty1, _), TyparConstraint.DefaultsTo (priority2, dty2, _) -> - (priority1 = priority2) && typeEquiv g dty1 dty2 + | TyparConstraint.DefaultsTo (priority1, defaultTy1, _), TyparConstraint.DefaultsTo (priority2, defaultTy2, _) -> + (priority1 = priority2) && typeEquiv g defaultTy1 defaultTy2 | _ -> false @@ -2565,14 +2565,12 @@ and SolveTypeSubsumesTypeWithWrappedContextualReport (csenv: ConstraintSolverEnv and SolveTypeSubsumesTypeWithReport (csenv: ConstraintSolverEnv) ndeep m trace cxsln ty1 ty2 = SolveTypeSubsumesTypeWithWrappedContextualReport csenv ndeep m trace cxsln ty1 ty2 id -// ty1: actual -// ty2: expected -and private SolveTypeEqualsTypeWithReport (csenv: ConstraintSolverEnv) ndeep m trace cxsln actual expected = +and SolveTypeEqualsTypeWithReport (csenv: ConstraintSolverEnv) ndeep m trace cxsln actualTy expectedTy = TryD - (fun () -> SolveTypeEqualsTypeKeepAbbrevsWithCxsln csenv ndeep m trace cxsln actual expected) + (fun () -> SolveTypeEqualsTypeKeepAbbrevsWithCxsln csenv ndeep m trace cxsln actualTy expectedTy) (function | AbortForFailedMemberConstraintResolution as err -> ErrorD err - | res -> ErrorD (ErrorFromAddingTypeEquation(csenv.g, csenv.DisplayEnv, actual, expected, res, m))) + | res -> ErrorD (ErrorFromAddingTypeEquation(csenv.g, csenv.DisplayEnv, actualTy, expectedTy, res, m))) and ArgsMustSubsumeOrConvert (csenv: ConstraintSolverEnv) diff --git a/src/Compiler/Checking/FindUnsolved.fs b/src/Compiler/Checking/FindUnsolved.fs index a914e61d256..93f452abd7d 100644 --- a/src/Compiler/Checking/FindUnsolved.fs +++ b/src/Compiler/Checking/FindUnsolved.fs @@ -201,7 +201,7 @@ and accDiscrim cenv env d = | DecisionTreeTest.ArrayLength(_, ty) -> accTy cenv env ty | DecisionTreeTest.Const _ | DecisionTreeTest.IsNull -> () - | DecisionTreeTest.IsInst (srcty, tgty) -> accTy cenv env srcty; accTy cenv env tgty + | DecisionTreeTest.IsInst (srcTy, tgtTy) -> accTy cenv env srcTy; accTy cenv env tgtTy | DecisionTreeTest.ActivePatternCase (exp, tys, _, _, _, _) -> accExpr cenv env exp accTypeInst cenv env tys diff --git a/src/Compiler/Checking/InfoReader.fs b/src/Compiler/Checking/InfoReader.fs index 75a4e9aa897..581cb7d0353 100644 --- a/src/Compiler/Checking/InfoReader.fs +++ b/src/Compiler/Checking/InfoReader.fs @@ -628,10 +628,10 @@ type InfoReader(g: TcGlobals, amap: Import.ImportMap) as this = keyComparer= { new System.Collections.Generic.IEqualityComparer<_> with - member _.Equals((flags1, _, typ1), (flags2, _, typ2)) = + member _.Equals((flags1, _, ty1), (flags2, _, ty2)) = // Ignoring the ranges - that's OK. flagsEq.Equals(flags1, flags2) && - match stripTyEqns g typ1, stripTyEqns g typ2 with + match stripTyEqns g ty1, stripTyEqns g ty2 with | TType_app(tcref1, [], _), TType_app(tcref2, [], _) -> tyconRefEq g tcref1 tcref2 | _ -> false member _.GetHashCode((flags, _, ty)) = @@ -910,11 +910,11 @@ type SigOfFunctionForDelegate = /// Given a delegate type work out the minfo, argument types, return type /// and F# function type by looking at the Invoke signature of the delegate. -let GetSigOfFunctionForDelegate (infoReader: InfoReader) delty m ad = +let GetSigOfFunctionForDelegate (infoReader: InfoReader) delTy m ad = let g = infoReader.g let amap = infoReader.amap let delInvokeMeth = - match GetIntrinsicMethInfosOfType infoReader (Some "Invoke") ad AllowMultiIntfInstantiations.Yes IgnoreOverrides m delty with + match GetIntrinsicMethInfosOfType infoReader (Some "Invoke") ad AllowMultiIntfInstantiations.Yes IgnoreOverrides m delTy with | [h] -> h | [] -> error(Error(FSComp.SR.noInvokeMethodsFound (), m)) | h :: _ -> warning(InternalError(FSComp.SR.moreThanOneInvokeMethodFound (), m)); h @@ -964,26 +964,26 @@ let TryDestStandardDelegateType (infoReader: InfoReader) m ad delTy = // already defined an appropriate delegate type: EventHandler. // (from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcwlkEventsTutorial.asp) let IsStandardEventInfo (infoReader: InfoReader) m ad (einfo: EventInfo) = - let dty = einfo.GetDelegateType(infoReader.amap, m) - match TryDestStandardDelegateType infoReader m ad dty with + let delTy = einfo.GetDelegateType(infoReader.amap, m) + match TryDestStandardDelegateType infoReader m ad delTy with | Some _ -> true | None -> false /// Get the (perhaps tupled) argument type accepted by an event -let ArgsTypOfEventInfo (infoReader: InfoReader) m ad (einfo: EventInfo) = +let ArgsTypeOfEventInfo (infoReader: InfoReader) m ad (einfo: EventInfo) = let amap = infoReader.amap - let dty = einfo.GetDelegateType(amap, m) - match TryDestStandardDelegateType infoReader m ad dty with + let delTy = einfo.GetDelegateType(amap, m) + match TryDestStandardDelegateType infoReader m ad delTy with | Some(argTys, _) -> argTys | None -> error(nonStandardEventError einfo.EventName m) /// Get the type of the event when looked at as if it is a property /// Used when displaying the property in Intellisense -let PropTypOfEventInfo (infoReader: InfoReader) m ad (einfo: EventInfo) = +let PropTypeOfEventInfo (infoReader: InfoReader) m ad (einfo: EventInfo) = let g = infoReader.g let amap = infoReader.amap let delTy = einfo.GetDelegateType(amap, m) - let argsTy = ArgsTypOfEventInfo infoReader m ad einfo + let argsTy = ArgsTypeOfEventInfo infoReader m ad einfo mkIEventType g delTy argsTy /// Try to find the name of the metadata file for this external definition diff --git a/src/Compiler/Checking/InfoReader.fsi b/src/Compiler/Checking/InfoReader.fsi index 5941702256a..c8cec7f82da 100644 --- a/src/Compiler/Checking/InfoReader.fsi +++ b/src/Compiler/Checking/InfoReader.fsi @@ -280,7 +280,7 @@ type SigOfFunctionForDelegate = /// Given a delegate type work out the minfo, argument types, return type /// and F# function type by looking at the Invoke signature of the delegate. val GetSigOfFunctionForDelegate: - infoReader: InfoReader -> delty: TType -> m: range -> ad: AccessorDomain -> SigOfFunctionForDelegate + infoReader: InfoReader -> delTy: TType -> m: range -> ad: AccessorDomain -> SigOfFunctionForDelegate /// Try and interpret a delegate type as a "standard" .NET delegate type associated with an event, with a "sender" parameter. val TryDestStandardDelegateType: @@ -290,9 +290,9 @@ val TryDestStandardDelegateType: /// with a sender parameter. val IsStandardEventInfo: infoReader: InfoReader -> m: range -> ad: AccessorDomain -> einfo: EventInfo -> bool -val ArgsTypOfEventInfo: infoReader: InfoReader -> m: range -> ad: AccessorDomain -> einfo: EventInfo -> TType +val ArgsTypeOfEventInfo: infoReader: InfoReader -> m: range -> ad: AccessorDomain -> einfo: EventInfo -> TType -val PropTypOfEventInfo: infoReader: InfoReader -> m: range -> ad: AccessorDomain -> einfo: EventInfo -> TType +val PropTypeOfEventInfo: infoReader: InfoReader -> m: range -> ad: AccessorDomain -> einfo: EventInfo -> TType /// Try to find the name of the metadata file for this external definition val TryFindMetadataInfoOfExternalEntityRef: diff --git a/src/Compiler/Checking/MethodCalls.fs b/src/Compiler/Checking/MethodCalls.fs index 6331c9a992d..7c8c07cb883 100644 --- a/src/Compiler/Checking/MethodCalls.fs +++ b/src/Compiler/Checking/MethodCalls.fs @@ -181,7 +181,7 @@ let TryFindRelevantImplicitConversion (infoReader: InfoReader) ad reqdTy actualT let reqdTy2 = if isTyparTy g reqdTy then let tp = destTyparTy g reqdTy - match tp.Constraints |> List.choose (function TyparConstraint.CoercesTo (c, _) -> Some c | _ -> None) with + match tp.Constraints |> List.choose (function TyparConstraint.CoercesTo (tgtTy, _) -> Some tgtTy | _ -> None) with | [reqdTy2] when tp.Rigidity = TyparRigidity.Flexible -> reqdTy2 | _ -> reqdTy else reqdTy @@ -363,8 +363,8 @@ let AdjustCalledArgTypeForOptionals (infoReader: InfoReader) ad enforceNullableO calledArgTy, TypeDirectedConversionUsed.No, None | _ -> let compgenId = mkSynId range0 unassignedTyparName - let tp = mkTyparTy (Construct.NewTypar (TyparKind.Type, TyparRigidity.Flexible, SynTypar(compgenId, TyparStaticReq.None, true), false, TyparDynamicReq.No, [], false, false)) - tp, TypeDirectedConversionUsed.No, None + let tpTy = mkTyparTy (Construct.NewTypar (TyparKind.Type, TyparRigidity.Flexible, SynTypar(compgenId, TyparStaticReq.None, true), false, TyparDynamicReq.No, [], false, false)) + tpTy, TypeDirectedConversionUsed.No, None else AdjustCalledArgTypeForTypeDirectedConversionsAndAutoQuote infoReader ad callerArgTy calledArgTy calledArg m @@ -456,7 +456,7 @@ type CalledMethArgSet<'T> = let MakeCalledArgs amap m (minfo: MethInfo) minst = // Mark up the arguments with their position, so we can sort them back into order later let paramDatas = minfo.GetParamDatas(amap, m, minst) - paramDatas |> List.mapiSquared (fun i j (ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfoFlags, nmOpt, reflArgInfo, typeOfCalledArg)) -> + paramDatas |> List.mapiSquared (fun i j (ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfoFlags, nmOpt, reflArgInfo, calledArgTy)) -> { Position=(i,j) IsParamArray=isParamArrayArg OptArgInfo=optArgInfo @@ -465,7 +465,7 @@ let MakeCalledArgs amap m (minfo: MethInfo) minst = IsOutArg=isOutArg ReflArgInfo=reflArgInfo NameOpt=nmOpt - CalledArgumentType=typeOfCalledArg }) + CalledArgumentType=calledArgTy }) /// /// Represents the syntactic matching between a caller of a method and the called method. @@ -969,7 +969,7 @@ let BuildILMethInfoCall g amap m isProp (minfo: ILMethInfo) valUseFlags minst di /// /// QUERY: this looks overly complex considering that we are doing a fundamentally simple /// thing here. -let BuildFSharpMethodApp g m (vref: ValRef) vexp vexprty (args: Exprs) = +let BuildFSharpMethodApp g m (vref: ValRef) vExpr vexprty (args: Exprs) = let arities = (arityOfVal vref.Deref).AritiesOfArgs let args3, (leftover, retTy) = @@ -990,17 +990,17 @@ let BuildFSharpMethodApp g m (vref: ValRef) vexp vexprty (args: Exprs) = (mkRefTupled g m tupargs tuptys), (argst, rangeOfFunTy g fty) ) if not leftover.IsEmpty then error(InternalError("Unexpected "+string(leftover.Length)+" remaining arguments in method application", m)) - mkApps g ((vexp, vexprty), [], args3, m), + mkApps g ((vExpr, vexprty), [], args3, m), retTy /// Build a call to an F# method. let BuildFSharpMethodCall g m (ty, vref: ValRef) valUseFlags minst args = - let vexp = Expr.Val (vref, valUseFlags, m) - let vexpty = vref.Type + let vExpr = Expr.Val (vref, valUseFlags, m) + let vExprTy = vref.Type let tpsorig, tau = vref.GeneralizedType let vtinst = argsOfAppTy g ty @ minst if tpsorig.Length <> vtinst.Length then error(InternalError("BuildFSharpMethodCall: unexpected List.length mismatch", m)) - let expr = mkTyAppExpr m (vexp, vexpty) vtinst + let expr = mkTyAppExpr m (vExpr, vExprTy) vtinst let exprTy = instType (mkTyparInst tpsorig vtinst) tau BuildFSharpMethodApp g m vref expr exprTy args @@ -1113,8 +1113,8 @@ let BuildMethodCall tcVal g amap isMutable m isProp minfo valUseFlags minst objA if valRefEq amap.g fsValRef amap.g.reraise_vref then mkReraise m exprTy, exprTy else - let vexp, vexpty = tcVal fsValRef valUseFlags (minfo.DeclaringTypeInst @ minst) m - BuildFSharpMethodApp g m fsValRef vexp vexpty allArgs + let vExpr, vExprTy = tcVal fsValRef valUseFlags (minfo.DeclaringTypeInst @ minst) m + BuildFSharpMethodApp g m fsValRef vExpr vExprTy allArgs | None -> let ilMethRef = Import.ImportProvidedMethodBaseAsILMethodRef amap m providedMeth let isNewObj = isCtor && (match valUseFlags with NormalValUse -> true | _ -> false) @@ -1139,8 +1139,8 @@ let BuildMethodCall tcVal g amap isMutable m isProp minfo valUseFlags minst objA // Go see if this is a use of a recursive definition... Note we know the value instantiation // we want to use so we pass that in order not to create a new one. - let vexp, vexpty = tcVal vref valUseFlags (minfo.DeclaringTypeInst @ minst) m - BuildFSharpMethodApp g m vref vexp vexpty allArgs + let vExpr, vExprTy = tcVal vref valUseFlags (minfo.DeclaringTypeInst @ minst) m + BuildFSharpMethodApp g m vref vExpr vExprTy allArgs // Build a 'call' to a struct default constructor | DefaultStructCtor (g, ty) -> @@ -1793,6 +1793,7 @@ module ProvidedMethodCalls = for v, e in Seq.zip (paramVars |> Seq.map (fun x -> x.PUntaint(id, m))) (Option.toList thisArg @ allArgs) do dict.Add(v, (None, e)) dict + let rec exprToExprAndWitness top (ea: Tainted) = let fail() = error(Error(FSComp.SR.etUnsupportedProvidedExpression(ea.PUntaint((fun etree -> etree.UnderlyingExpressionString), m)), m)) match ea with @@ -1806,139 +1807,139 @@ module ProvidedMethodCalls = let srcExpr = exprToExpr expr let targetTy = Import.ImportProvidedType amap m (targetTy.PApply(id, m)) let sourceTy = Import.ImportProvidedType amap m (expr.PApply ((fun e -> e.Type), m)) - let te = mkCoerceIfNeeded g targetTy sourceTy srcExpr - None, (te, tyOfExpr g te) + let exprR = mkCoerceIfNeeded g targetTy sourceTy srcExpr + None, (exprR, tyOfExpr g exprR) | ProvidedTypeTestExpr (expr, targetTy) -> let expr, targetTy = exprType.PApply2((fun _ -> (expr, targetTy)), m) let srcExpr = exprToExpr expr let targetTy = Import.ImportProvidedType amap m (targetTy.PApply(id, m)) - let te = mkCallTypeTest g m targetTy srcExpr - None, (te, tyOfExpr g te) + let exprR = mkCallTypeTest g m targetTy srcExpr + None, (exprR, tyOfExpr g exprR) | ProvidedIfThenElseExpr (test, thenBranch, elseBranch) -> let test, thenBranch, elseBranch = exprType.PApply3((fun _ -> (test, thenBranch, elseBranch)), m) let testExpr = exprToExpr test let ifTrueExpr = exprToExpr thenBranch let ifFalseExpr = exprToExpr elseBranch - let te = mkCond DebugPointAtBinding.NoneAtSticky m (tyOfExpr g ifTrueExpr) testExpr ifTrueExpr ifFalseExpr - None, (te, tyOfExpr g te) + let exprR = mkCond DebugPointAtBinding.NoneAtSticky m (tyOfExpr g ifTrueExpr) testExpr ifTrueExpr ifFalseExpr + None, (exprR, tyOfExpr g exprR) | ProvidedVarExpr providedVar -> let _, vTe = varToExpr (exprType.PApply((fun _ -> providedVar), m)) None, (vTe, tyOfExpr g vTe) | ProvidedConstantExpr (obj, prType) -> - let ce = convertConstExpr g amap m (exprType.PApply((fun _ -> (obj, prType)), m)) - None, (ce, tyOfExpr g ce) + let exprR = convertConstExpr g amap m (exprType.PApply((fun _ -> (obj, prType)), m)) + None, (exprR, tyOfExpr g exprR) | ProvidedNewTupleExpr info -> let elems = exprType.PApplyArray((fun _ -> info), "GetInvokerExpression", m) - let elemsT = elems |> Array.map exprToExpr |> Array.toList - let exprT = mkRefTupledNoTypes g m elemsT - None, (exprT, tyOfExpr g exprT) + let elemsR = elems |> Array.map exprToExpr |> Array.toList + let exprR = mkRefTupledNoTypes g m elemsR + None, (exprR, tyOfExpr g exprR) | ProvidedNewArrayExpr (ty, elems) -> let ty, elems = exprType.PApply2((fun _ -> (ty, elems)), m) - let tyT = Import.ImportProvidedType amap m ty + let tyR = Import.ImportProvidedType amap m ty let elems = elems.PApplyArray(id, "GetInvokerExpression", m) - let elemsT = elems |> Array.map exprToExpr |> Array.toList - let exprT = Expr.Op (TOp.Array, [tyT], elemsT, m) - None, (exprT, tyOfExpr g exprT) + let elemsR = elems |> Array.map exprToExpr |> Array.toList + let exprR = Expr.Op (TOp.Array, [tyR], elemsR, m) + None, (exprR, tyOfExpr g exprR) | ProvidedTupleGetExpr (inp, n) -> let inp, n = exprType.PApply2((fun _ -> (inp, n)), m) - let inpT = inp |> exprToExpr + let inpR = inp |> exprToExpr // if type of expression is erased type then we need convert it to the underlying base type - let typeOfExpr = - let t = tyOfExpr g inpT + let exprTy = + let t = tyOfExpr g inpR stripTyEqnsWrtErasure EraseMeasures g t - let tupInfo, tysT = tryDestAnyTupleTy g typeOfExpr - let exprT = mkTupleFieldGet g (tupInfo, inpT, tysT, n.PUntaint(id, m), m) - None, (exprT, tyOfExpr g exprT) + let tupInfo, tysT = tryDestAnyTupleTy g exprTy + let exprR = mkTupleFieldGet g (tupInfo, inpR, tysT, n.PUntaint(id, m), m) + None, (exprR, tyOfExpr g exprR) | ProvidedLambdaExpr (v, b) -> let v, b = exprType.PApply2((fun _ -> (v, b)), m) - let vT = addVar v - let bT = exprToExpr b + let vR = addVar v + let bR = exprToExpr b removeVar v - let exprT = mkLambda m vT (bT, tyOfExpr g bT) - None, (exprT, tyOfExpr g exprT) + let exprR = mkLambda m vR (bR, tyOfExpr g bR) + None, (exprR, tyOfExpr g exprR) | ProvidedLetExpr (v, e, b) -> let v, e, b = exprType.PApply3((fun _ -> (v, e, b)), m) - let eT = exprToExpr e - let vT = addVar v - let bT = exprToExpr b + let eR = exprToExpr e + let vR = addVar v + let bR = exprToExpr b removeVar v - let exprT = mkCompGenLet m vT eT bT - None, (exprT, tyOfExpr g exprT) + let exprR = mkCompGenLet m vR eR bR + None, (exprR, tyOfExpr g exprR) | ProvidedVarSetExpr (v, e) -> let v, e = exprType.PApply2((fun _ -> (v, e)), m) - let eT = exprToExpr e - let vTopt, _ = varToExpr v - match vTopt with + let eR = exprToExpr e + let vOptR, _ = varToExpr v + match vOptR with | None -> fail() - | Some vT -> - let exprT = mkValSet m (mkLocalValRef vT) eT - None, (exprT, tyOfExpr g exprT) + | Some vR -> + let exprR = mkValSet m (mkLocalValRef vR) eR + None, (exprR, tyOfExpr g exprR) | ProvidedWhileLoopExpr (guardExpr, bodyExpr) -> let guardExpr, bodyExpr = (exprType.PApply2((fun _ -> (guardExpr, bodyExpr)), m)) - let guardExprT = exprToExpr guardExpr - let bodyExprT = exprToExpr bodyExpr - let exprT = mkWhile g (DebugPointAtWhile.No, SpecialWhileLoopMarker.NoSpecialWhileLoopMarker, guardExprT, bodyExprT, m) - None, (exprT, tyOfExpr g exprT) + let guardExprR = exprToExpr guardExpr + let bodyExprR = exprToExpr bodyExpr + let exprR = mkWhile g (DebugPointAtWhile.No, SpecialWhileLoopMarker.NoSpecialWhileLoopMarker, guardExprR, bodyExprR, m) + None, (exprR, tyOfExpr g exprR) | ProvidedForIntegerRangeLoopExpr (v, e1, e2, e3) -> let v, e1, e2, e3 = exprType.PApply4((fun _ -> (v, e1, e2, e3)), m) - let e1T = exprToExpr e1 - let e2T = exprToExpr e2 - let vT = addVar v - let e3T = exprToExpr e3 + let e1R = exprToExpr e1 + let e2R = exprToExpr e2 + let vR = addVar v + let e3R = exprToExpr e3 removeVar v - let exprT = mkFastForLoop g (DebugPointAtFor.No, DebugPointAtInOrTo.No, m, vT, e1T, true, e2T, e3T) - None, (exprT, tyOfExpr g exprT) + let exprR = mkFastForLoop g (DebugPointAtFor.No, DebugPointAtInOrTo.No, m, vR, e1R, true, e2R, e3R) + None, (exprR, tyOfExpr g exprR) | ProvidedNewDelegateExpr (delegateTy, boundVars, delegateBodyExpr) -> let delegateTy, boundVars, delegateBodyExpr = exprType.PApply3((fun _ -> (delegateTy, boundVars, delegateBodyExpr)), m) - let delegateTyT = Import.ImportProvidedType amap m delegateTy + let delegateTyR = Import.ImportProvidedType amap m delegateTy let vs = boundVars.PApplyArray(id, "GetInvokerExpression", m) |> Array.toList let vsT = List.map addVar vs - let delegateBodyExprT = exprToExpr delegateBodyExpr + let delegateBodyExprR = exprToExpr delegateBodyExpr List.iter removeVar vs - let lambdaExpr = mkLambdas g m [] vsT (delegateBodyExprT, tyOfExpr g delegateBodyExprT) + let lambdaExpr = mkLambdas g m [] vsT (delegateBodyExprR, tyOfExpr g delegateBodyExprR) let lambdaExprTy = tyOfExpr g lambdaExpr let infoReader = InfoReader(g, amap) - let exprT = CoerceFromFSharpFuncToDelegate g amap infoReader AccessorDomain.AccessibleFromSomewhere lambdaExprTy m lambdaExpr delegateTyT - None, (exprT, tyOfExpr g exprT) + let exprR = CoerceFromFSharpFuncToDelegate g amap infoReader AccessorDomain.AccessibleFromSomewhere lambdaExprTy m lambdaExpr delegateTyR + None, (exprR, tyOfExpr g exprR) #if PROVIDED_ADDRESS_OF | ProvidedAddressOfExpr e -> - let eT = exprToExpr (exprType.PApply((fun _ -> e), m)) - let wrap,ce, _readonly, _writeonly = mkExprAddrOfExpr g true false DefinitelyMutates eT None m - let ce = wrap ce - None, (ce, tyOfExpr g ce) + let eR = exprToExpr (exprType.PApply((fun _ -> e), m)) + let wrap,exprR, _readonly, _writeonly = mkExprAddrOfExpr g true false DefinitelyMutates eR None m + let exprR = wrap exprR + None, (exprR, tyOfExpr g exprR) #endif | ProvidedDefaultExpr pty -> let ty = Import.ImportProvidedType amap m (exprType.PApply((fun _ -> pty), m)) - let ce = mkDefault (m, ty) - None, (ce, tyOfExpr g ce) + let exprR = mkDefault (m, ty) + None, (exprR, tyOfExpr g exprR) | ProvidedCallExpr (e1, e2, e3) -> methodCallToExpr top ea (exprType.PApply((fun _ -> (e1, e2, e3)), m)) | ProvidedSequentialExpr (e1, e2) -> let e1, e2 = exprType.PApply2((fun _ -> (e1, e2)), m) - let e1T = exprToExpr e1 - let e2T = exprToExpr e2 - let ce = mkCompGenSequential m e1T e2T - None, (ce, tyOfExpr g ce) + let e1R = exprToExpr e1 + let e2R = exprToExpr e2 + let exprR = mkCompGenSequential m e1R e2R + None, (exprR, tyOfExpr g exprR) | ProvidedTryFinallyExpr (e1, e2) -> let e1, e2 = exprType.PApply2((fun _ -> (e1, e2)), m) - let e1T = exprToExpr e1 - let e2T = exprToExpr e2 - let ce = mkTryFinally g (e1T, e2T, m, tyOfExpr g e1T, DebugPointAtTry.No, DebugPointAtFinally.No) - None, (ce, tyOfExpr g ce) + let e1R = exprToExpr e1 + let e2R = exprToExpr e2 + let exprR = mkTryFinally g (e1R, e2R, m, tyOfExpr g e1R, DebugPointAtTry.No, DebugPointAtFinally.No) + None, (exprR, tyOfExpr g exprR) | ProvidedTryWithExpr (e1, e2, e3, e4, e5) -> let info = exprType.PApply((fun _ -> (e1, e2, e3, e4, e5)), m) - let bT = exprToExpr (info.PApply((fun (x, _, _, _, _) -> x), m)) + let bR = exprToExpr (info.PApply((fun (x, _, _, _, _) -> x), m)) let v1 = info.PApply((fun (_, x, _, _, _) -> x), m) - let v1T = addVar v1 - let e1T = exprToExpr (info.PApply((fun (_, _, x, _, _) -> x), m)) + let v1R = addVar v1 + let e1R = exprToExpr (info.PApply((fun (_, _, x, _, _) -> x), m)) removeVar v1 let v2 = info.PApply((fun (_, _, _, x, _) -> x), m) - let v2T = addVar v2 - let e2T = exprToExpr (info.PApply((fun (_, _, _, _, x) -> x), m)) + let v2R = addVar v2 + let e2R = exprToExpr (info.PApply((fun (_, _, _, _, x) -> x), m)) removeVar v2 - let ce = mkTryWith g (bT, v1T, e1T, v2T, e2T, m, tyOfExpr g bT, DebugPointAtTry.No, DebugPointAtWith.No) - None, (ce, tyOfExpr g ce) + let exprR = mkTryWith g (bR, v1R, e1R, v2R, e2R, m, tyOfExpr g bR, DebugPointAtTry.No, DebugPointAtWith.No) + None, (exprR, tyOfExpr g exprR) | ProvidedNewObjectExpr (e1, e2) -> None, ctorCallToExpr (exprType.PApply((fun _ -> (e1, e2)), m)) @@ -1955,10 +1956,10 @@ module ProvidedMethodCalls = let nm = v.PUntaint ((fun v -> v.Name), m) let mut = v.PUntaint ((fun v -> v.IsMutable), m) let vRaw = v.PUntaint (id, m) - let tyT = Import.ImportProvidedType amap m (v.PApply ((fun v -> v.Type), m)) - let vT, vTe = if mut then mkMutableCompGenLocal m nm tyT else mkCompGenLocal m nm tyT - varConv[vRaw] <- (Some vT, vTe) - vT + let tyR = Import.ImportProvidedType amap m (v.PApply ((fun v -> v.Type), m)) + let vR, vTe = if mut then mkMutableCompGenLocal m nm tyR else mkCompGenLocal m nm tyR + varConv[vRaw] <- (Some vR, vTe) + vR and removeVar (v: Tainted) = let vRaw = v.PUntaint (id, m) diff --git a/src/Compiler/Checking/MethodOverrides.fs b/src/Compiler/Checking/MethodOverrides.fs index 9d3e6c50153..7c5e9934a77 100644 --- a/src/Compiler/Checking/MethodOverrides.fs +++ b/src/Compiler/Checking/MethodOverrides.fs @@ -160,7 +160,7 @@ module DispatchSlotChecking = let belongsToReqdTy = match overrideBy.MemberInfo.Value.ImplementedSlotSigs with | [] -> false - | ss :: _ -> isInterfaceTy g ss.ImplementedType && typeEquiv g reqdTy ss.ImplementedType + | ss :: _ -> isInterfaceTy g ss.DeclaringType && typeEquiv g reqdTy ss.DeclaringType if belongsToReqdTy then CanImplementAnyInterfaceSlot else @@ -178,7 +178,7 @@ module DispatchSlotChecking = Override(implKind, overrideBy.MemberApparentEntity, mkSynId overrideBy.Range nm, memberMethodTypars, memberToParentInst, argTys, retTy, isFakeEventProperty, overrideBy.IsCompilerGenerated) /// Get the override information for an object expression method being used to implement dispatch slots - let GetObjectExprOverrideInfo g amap (implty, id: Ident, memberFlags, ty, arityInfo, bindingAttribs, rhsExpr) = + let GetObjectExprOverrideInfo g amap (implTy, id: Ident, memberFlags, ty, arityInfo, bindingAttribs, rhsExpr) = // Dissect the type. The '0' indicates there are no enclosing generic class type parameters relevant here. let tps, _, argInfos, retTy, _ = GetMemberTypeInMemberForm g memberFlags arityInfo 0 ty id.idRange let argTys = argInfos |> List.mapSquared fst @@ -192,13 +192,13 @@ module DispatchSlotChecking = // Check for empty variable list from a () arg let vs = if List.isSingleton vs && argInfos.IsEmpty then [] else vs let implKind = - if isInterfaceTy g implty then + if isInterfaceTy g implTy then CanImplementAnyInterfaceSlot else CanImplementAnyClassHierarchySlot //CanImplementAnySlot <<----- Change to this to enable implicit interface implementation let isFakeEventProperty = CompileAsEvent g bindingAttribs - let overrideByInfo = Override(implKind, tcrefOfAppTy g implty, id, tps, [], argTys, retTy, isFakeEventProperty, false) + let overrideByInfo = Override(implKind, tcrefOfAppTy g implTy, id, tps, [], argTys, retTy, isFakeEventProperty, false) overrideByInfo, (baseValOpt, thisv, vs, bindingAttribs, rhsExpr) | _ -> error(InternalError("Unexpected shape for object expression override", id.idRange)) @@ -749,7 +749,7 @@ module DispatchSlotChecking = let amap = infoReader.amap let tcaug = tycon.TypeContents - let interfaces = tycon.ImmediateInterfacesOfFSharpTycon |> List.map (fun (ity, _compgen, m) -> (ity, m)) + let interfaces = tycon.ImmediateInterfacesOfFSharpTycon |> List.map (fun (intfTy, _compgen, m) -> (intfTy, m)) let overallTy = generalizedTyconRef g (mkLocalTyconRef tycon) @@ -780,9 +780,9 @@ module DispatchSlotChecking = | [] -> // Are we looking at the implementation of the class hierarchy? If so include all the override members not (isInterfaceTy g reqdTy) - | ss -> - ss |> List.forall (fun ss -> - let ty = ss.ImplementedType + | slotSigs -> + slotSigs |> List.forall (fun slotSig -> + let ty = slotSig.DeclaringType if isInterfaceTy g ty then // Is this a method impl listed under the reqdTy? typeEquiv g ty reqdTy diff --git a/src/Compiler/Checking/MethodOverrides.fsi b/src/Compiler/Checking/MethodOverrides.fsi index e6091626469..b93b290f5d3 100644 --- a/src/Compiler/Checking/MethodOverrides.fsi +++ b/src/Compiler/Checking/MethodOverrides.fsi @@ -89,7 +89,7 @@ module DispatchSlotChecking = val GetObjectExprOverrideInfo: g: TcGlobals -> amap: ImportMap -> - implty: TType * + implTy: TType * id: Ident * memberFlags: SynMemberFlags * ty: TType * diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index d04f9d0929d..0f3daba1d0f 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -1420,10 +1420,10 @@ and AddModuleOrNamespaceContentsToNameEnv (g: TcGlobals) amap (ad: AccessorDomai and AddModuleOrNamespaceRefsContentsToNameEnv g amap ad m root nenv modrefs = (modrefs, nenv) ||> List.foldBack (fun modref acc -> AddModuleOrNamespaceRefContentsToNameEnv g amap ad m root acc modref) -and AddTypeContentsToNameEnv g amap ad m nenv (typ: TType) = - assert (isAppTy g typ) - assert not (tcrefOfAppTy g typ).IsModuleOrNamespace - AddStaticContentOfTypeToNameEnv g amap ad m nenv typ +and AddTypeContentsToNameEnv g amap ad m nenv (ty: TType) = + assert (isAppTy g ty) + assert not (tcrefOfAppTy g ty).IsModuleOrNamespace + AddStaticContentOfTypeToNameEnv g amap ad m nenv ty and AddModuleOrNamespaceRefContentsToNameEnv g amap ad m root nenv (modref: EntityRef) = assert modref.IsModuleOrNamespace @@ -2426,8 +2426,8 @@ let TryFindUnionCaseOfType g ty nm = ValueNone /// Try to find a union case of a type, with the given name -let TryFindAnonRecdFieldOfType g typ nm = - match tryDestAnonRecdTy g typ with +let TryFindAnonRecdFieldOfType g ty nm = + match tryDestAnonRecdTy g ty with | ValueSome (anonInfo, tys) -> match anonInfo.SortedIds |> Array.tryFindIndex (fun x -> x.idText = nm) with | Some i -> Some (Item.AnonRecdField(anonInfo, tys, i, anonInfo.SortedIds[i].idRange)) @@ -4113,7 +4113,7 @@ let rec ResolvePartialLongIdentInType (ncenv: NameResolver) nenv isApplicableMet // e.g. .. for einfo in ncenv.InfoReader.GetEventInfosOfType(Some id, ad, m, ty) do - let einfoTy = PropTypOfEventInfo ncenv.InfoReader m ad einfo + let einfoTy = PropTypeOfEventInfo ncenv.InfoReader m ad einfo yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest einfoTy // nested types @@ -4811,7 +4811,7 @@ let rec ResolvePartialLongIdentInTypeForItem (ncenv: NameResolver) nenv m ad sta // e.g. .. for einfo in ncenv.InfoReader.GetEventInfosOfType(Some id, ad, m, ty) do - let tyinfo = PropTypOfEventInfo ncenv.InfoReader m ad einfo + let tyinfo = PropTypeOfEventInfo ncenv.InfoReader m ad einfo yield! ResolvePartialLongIdentInTypeForItem ncenv nenv m ad false rest item tyinfo // nested types! diff --git a/src/Compiler/Checking/NicePrint.fs b/src/Compiler/Checking/NicePrint.fs index 6d8b38c7956..a07f000c7a7 100644 --- a/src/Compiler/Checking/NicePrint.fs +++ b/src/Compiler/Checking/NicePrint.fs @@ -497,7 +497,7 @@ module PrintTypes = | _ -> itemL /// Layout a reference to a type - let layoutTyconRef denv tycon = layoutTyconRefImpl false denv tycon + let layoutTyconRef denv tcref = layoutTyconRefImpl false denv tcref /// Layout the flags of a member let layoutMemberFlags (memFlags: SynMemberFlags) = @@ -546,8 +546,8 @@ module PrintTypes = | TypeDefOfExpr denv.g ty -> LeftL.keywordTypedefof ^^ wordL (tagPunctuation "<") ^^ layoutType denv ty ^^ rightL (tagPunctuation ">") - | Expr.Op (TOp.Coerce, [tgTy;_], [arg2], _) -> - leftL (tagPunctuation "(") ^^ layoutAttribArg denv arg2 ^^ wordL (tagPunctuation ":>") ^^ layoutType denv tgTy ^^ rightL (tagPunctuation ")") + | Expr.Op (TOp.Coerce, [tgtTy;_], [arg2], _) -> + leftL (tagPunctuation "(") ^^ layoutAttribArg denv arg2 ^^ wordL (tagPunctuation ":>") ^^ layoutType denv tgtTy ^^ rightL (tagPunctuation ")") | AttribBitwiseOrExpr denv.g (arg1, arg2) -> layoutAttribArg denv arg1 ^^ wordL (tagPunctuation "|||") ^^ layoutAttribArg denv arg2 @@ -726,8 +726,8 @@ module PrintTypes = and layoutConstraintWithInfo denv env (tp, tpc) = let longConstraintPrefix l = (layoutTyparRefWithInfo denv env tp |> addColonL) ^^ l match tpc with - | TyparConstraint.CoercesTo(tpct, _) -> - [layoutTyparRefWithInfo denv env tp ^^ wordL (tagOperator ":>") --- layoutTypeWithInfo denv env tpct] + | TyparConstraint.CoercesTo(tgtTy, _) -> + [layoutTyparRefWithInfo denv env tp ^^ wordL (tagOperator ":>") --- layoutTypeWithInfo denv env tgtTy] | TyparConstraint.MayResolveMember(traitInfo, _) -> [layoutTraitWithInfo denv env traitInfo] @@ -815,8 +815,8 @@ module PrintTypes = /// Layout a unit of measure expression and layoutMeasure denv unt = - let sortVars vs = vs |> List.sortBy (fun (v: Typar, _) -> v.DisplayName) - let sortCons cs = cs |> List.sortBy (fun (c: TyconRef, _) -> c.DisplayName) + let sortVars vs = vs |> List.sortBy (fun (tp: Typar, _) -> tp.DisplayName) + let sortCons cs = cs |> List.sortBy (fun (tcref: TyconRef, _) -> tcref.DisplayName) let negvs, posvs = ListMeasureVarOccsWithNonZeroExponents unt |> sortVars |> List.partition (fun (_, e) -> SignRational e < 0) let negcs, poscs = ListMeasureConOccsWithNonZeroExponents denv.g false unt |> sortCons |> List.partition (fun (_, e) -> SignRational e < 0) let unparL uv = layoutTyparRef denv uv @@ -832,14 +832,14 @@ module PrintTypes = | _ -> prefix ^^ sepL (tagPunctuation "/") ^^ (if List.length negvs + List.length negcs > 1 then sepL (tagPunctuation "(") ^^ postfix ^^ sepL (tagPunctuation ")") else postfix) /// Layout type arguments, either NAME or (ty, ..., ty) NAME *) - and layoutTypeAppWithInfoAndPrec denv env tcL prec prefix args = + and layoutTypeAppWithInfoAndPrec denv env tcL prec prefix argTys = if prefix then - match args with + match argTys with | [] -> tcL - | [arg] -> tcL ^^ sepL (tagPunctuation "<") ^^ (layoutTypeWithInfoAndPrec denv env 4 arg) ^^ rightL (tagPunctuation">") - | args -> bracketIfL (prec <= 1) (tcL ^^ angleL (layoutTypesWithInfoAndPrec denv env 2 (sepL (tagPunctuation ",")) args)) + | [argTy] -> tcL ^^ sepL (tagPunctuation "<") ^^ (layoutTypeWithInfoAndPrec denv env 4 argTy) ^^ rightL (tagPunctuation">") + | _ -> bracketIfL (prec <= 1) (tcL ^^ angleL (layoutTypesWithInfoAndPrec denv env 2 (sepL (tagPunctuation ",")) argTys)) else - match args with + match argTys with | [] -> tcL | [arg] -> layoutTypeWithInfoAndPrec denv env 2 arg ^^ tcL | args -> bracketIfL (prec <= 1) (bracketL (layoutTypesWithInfoAndPrec denv env 2 (sepL (tagPunctuation ",")) args) --- tcL) @@ -1050,8 +1050,8 @@ module PrintTypes = prettyTyparInst, niceMethodTypars, layout - let prettyLayoutOfMemberType denv v typarInst argInfos retTy = - match PartitionValRefTypars denv.g v with + let prettyLayoutOfMemberType denv vref typarInst argInfos retTy = + match PartitionValRefTypars denv.g vref with | Some(_, _, memberMethodTypars, memberToParentInst, _) -> prettyLayoutOfMemberSigCore denv memberToParentInst (typarInst, memberMethodTypars, argInfos, retTy) | None -> @@ -1123,14 +1123,14 @@ module PrintTypes = let ty, _cxs = PrettyTypes.PrettifyType denv.g ty layoutTypeWithInfoAndPrec denv SimplifyTypes.typeSimplificationInfo0 5 ty - let layoutOfValReturnType denv (v: ValRef) = - match v.ValReprInfo with + let layoutOfValReturnType denv (vref: ValRef) = + match vref.ValReprInfo with | None -> - let tau = v.TauType + let tau = vref.TauType let _argTysl, retTy = stripFunTy denv.g tau layoutReturnType denv SimplifyTypes.typeSimplificationInfo0 retTy | Some (ValReprInfo(_typars, argInfos, _retInfo)) -> - let tau = v.TauType + let tau = vref.TauType let _c, retTy = GetTopTauTypeInFSharpForm denv.g argInfos tau Range.range0 layoutReturnType denv SimplifyTypes.typeSimplificationInfo0 retTy @@ -1147,22 +1147,22 @@ module PrintTastMemberOrVals = else nameL - let layoutMemberName (denv: DisplayEnv) (v: ValRef) niceMethodTypars tagFunction name = - let nameL = ConvertValNameToDisplayLayout v.IsBaseVal (tagFunction >> mkNav v.DefinitionRange >> wordL) name + let layoutMemberName (denv: DisplayEnv) (vref: ValRef) niceMethodTypars tagFunction name = + let nameL = ConvertValNameToDisplayLayout vref.IsBaseVal (tagFunction >> mkNav vref.DefinitionRange >> wordL) name let nameL = if denv.showMemberContainers then - layoutTyconRef denv v.MemberApparentEntity ^^ SepL.dot ^^ nameL + layoutTyconRef denv vref.MemberApparentEntity ^^ SepL.dot ^^ nameL else nameL let nameL = if denv.showTyparBinding then layoutTyparDecls denv nameL true niceMethodTypars else nameL - let nameL = layoutAccessibility denv v.Accessibility nameL + let nameL = layoutAccessibility denv vref.Accessibility nameL nameL let prettyLayoutOfMemberShortOption denv typarInst (v: Val) short = - let v = mkLocalValRef v - let membInfo = Option.get v.MemberInfo + let vref = mkLocalValRef v + let membInfo = Option.get vref.MemberInfo let stat = layoutMemberFlags membInfo.MemberFlags - let _tps, argInfos, retTy, _ = GetTypeOfMemberInFSharpForm denv.g v + let _tps, argInfos, retTy, _ = GetTypeOfMemberInFSharpForm denv.g vref if short then for argInfo in argInfos do @@ -1173,22 +1173,22 @@ module PrintTastMemberOrVals = let prettyTyparInst, memberL = match membInfo.MemberFlags.MemberKind with | SynMemberKind.Member -> - let prettyTyparInst, niceMethodTypars,tauL = prettyLayoutOfMemberType denv v typarInst argInfos retTy + let prettyTyparInst, niceMethodTypars,tauL = prettyLayoutOfMemberType denv vref typarInst argInfos retTy let resL = if short then tauL else - let nameL = layoutMemberName denv v niceMethodTypars tagMember v.DisplayNameCoreMangled - let nameL = if short then nameL else mkInlineL denv v.Deref nameL + let nameL = layoutMemberName denv vref niceMethodTypars tagMember vref.DisplayNameCoreMangled + let nameL = if short then nameL else mkInlineL denv vref.Deref nameL stat --- ((nameL |> addColonL) ^^ tauL) prettyTyparInst, resL | SynMemberKind.ClassConstructor | SynMemberKind.Constructor -> - let prettyTyparInst, _, tauL = prettyLayoutOfMemberType denv v typarInst argInfos retTy + let prettyTyparInst, _, tauL = prettyLayoutOfMemberType denv vref typarInst argInfos retTy let resL = if short then tauL else - let newL = layoutAccessibility denv v.Accessibility WordL.keywordNew + let newL = layoutAccessibility denv vref.Accessibility WordL.keywordNew stat ++ (newL |> addColonL) ^^ tauL prettyTyparInst, resL @@ -1198,8 +1198,8 @@ module PrintTastMemberOrVals = | SynMemberKind.PropertyGet -> if isNil argInfos then // use error recovery because intellisense on an incomplete file will show this - errorR(Error(FSComp.SR.tastInvalidFormForPropertyGetter(), v.Id.idRange)) - let nameL = layoutMemberName denv v [] tagProperty v.DisplayNameCoreMangled + errorR(Error(FSComp.SR.tastInvalidFormForPropertyGetter(), vref.Id.idRange)) + let nameL = layoutMemberName denv vref [] tagProperty vref.DisplayNameCoreMangled let resL = if short then nameL --- (WordL.keywordWith ^^ WordL.keywordGet) else stat --- nameL --- (WordL.keywordWith ^^ WordL.keywordGet) @@ -1209,31 +1209,31 @@ module PrintTastMemberOrVals = match argInfos with | [[(ty, _)]] when isUnitTy denv.g ty -> [] | _ -> argInfos - let prettyTyparInst, niceMethodTypars,tauL = prettyLayoutOfMemberType denv v typarInst argInfos retTy + let prettyTyparInst, niceMethodTypars,tauL = prettyLayoutOfMemberType denv vref typarInst argInfos retTy let resL = if short then if isNil argInfos then tauL else tauL --- (WordL.keywordWith ^^ WordL.keywordGet) else - let nameL = layoutMemberName denv v niceMethodTypars tagProperty v.DisplayNameCoreMangled + let nameL = layoutMemberName denv vref niceMethodTypars tagProperty vref.DisplayNameCoreMangled stat --- ((nameL |> addColonL) ^^ (if isNil argInfos then tauL else tauL --- (WordL.keywordWith ^^ WordL.keywordGet))) prettyTyparInst, resL | SynMemberKind.PropertySet -> if argInfos.Length <> 1 || isNil argInfos.Head then // use error recovery because intellisense on an incomplete file will show this - errorR(Error(FSComp.SR.tastInvalidFormForPropertySetter(), v.Id.idRange)) - let nameL = layoutMemberName denv v [] tagProperty v.DisplayNameCoreMangled + errorR(Error(FSComp.SR.tastInvalidFormForPropertySetter(), vref.Id.idRange)) + let nameL = layoutMemberName denv vref [] tagProperty vref.DisplayNameCoreMangled let resL = stat --- nameL --- (WordL.keywordWith ^^ WordL.keywordSet) emptyTyparInst, resL else let argInfos, valueInfo = List.frontAndBack argInfos.Head - let prettyTyparInst, niceMethodTypars, tauL = prettyLayoutOfMemberType denv v typarInst (if isNil argInfos then [] else [argInfos]) (fst valueInfo) + let prettyTyparInst, niceMethodTypars, tauL = prettyLayoutOfMemberType denv vref typarInst (if isNil argInfos then [] else [argInfos]) (fst valueInfo) let resL = if short then (tauL --- (WordL.keywordWith ^^ WordL.keywordSet)) else - let nameL = layoutMemberName denv v niceMethodTypars tagProperty v.DisplayNameCoreMangled + let nameL = layoutMemberName denv vref niceMethodTypars tagProperty vref.DisplayNameCoreMangled stat --- ((nameL |> addColonL) ^^ (tauL --- (WordL.keywordWith ^^ WordL.keywordSet))) prettyTyparInst, resL @@ -1730,23 +1730,23 @@ module TastDefinitionPrinting = typewordL ^^ tpsL - let sortKey (v: MethInfo) = - (not v.IsConstructor, - not v.IsInstance, // instance first - v.DisplayNameCore, // sort by name - List.sum v.NumArgs, // sort by #curried - v.NumArgs.Length) // sort by arity + let sortKey (minfo: MethInfo) = + (not minfo.IsConstructor, + not minfo.IsInstance, // instance first + minfo.DisplayNameCore, // sort by name + List.sum minfo.NumArgs, // sort by #curried + minfo.NumArgs.Length) // sort by arity - let shouldShow (valRef: ValRef option) = - match valRef with + let shouldShow (vrefOpt: ValRef option) = + match vrefOpt with | None -> true - | Some(vr) -> - (denv.showObsoleteMembers || not (CheckFSharpAttributesForObsolete denv.g vr.Attribs)) && - (denv.showHiddenMembers || not (CheckFSharpAttributesForHidden denv.g vr.Attribs)) + | Some vref -> + (denv.showObsoleteMembers || not (CheckFSharpAttributesForObsolete denv.g vref.Attribs)) && + (denv.showHiddenMembers || not (CheckFSharpAttributesForHidden denv.g vref.Attribs)) let ctors = GetIntrinsicConstructorInfosOfType infoReader m ty - |> List.filter (fun v -> IsMethInfoAccessible amap m ad v && not v.IsClassConstructor && shouldShow v.ArbitraryValRef) + |> List.filter (fun minfo -> IsMethInfoAccessible amap m ad minfo && not minfo.IsClassConstructor && shouldShow minfo.ArbitraryValRef) let iimpls = if suppressInheritanceAndInterfacesForTyInSimplifiedDisplays g amap m ty then @@ -1760,15 +1760,15 @@ module TastDefinitionPrinting = let iimplsLs = iimpls - |> List.map (fun ity -> wordL (tagKeyword (if isInterfaceTy g ty then "inherit" else "interface")) -* layoutType denv ity) + |> List.map (fun intfTy -> wordL (tagKeyword (if isInterfaceTy g ty then "inherit" else "interface")) -* layoutType denv intfTy) let props = GetImmediateIntrinsicPropInfosOfType (None, ad) g amap m ty - |> List.filter (fun v -> shouldShow v.ArbitraryValRef) + |> List.filter (fun pinfo -> shouldShow pinfo.ArbitraryValRef) let events = infoReader.GetEventInfosOfType(None, ad, m, ty) - |> List.filter (fun v -> shouldShow v.ArbitraryValRef && typeEquiv g ty v.ApparentEnclosingType) + |> List.filter (fun einfo -> shouldShow einfo.ArbitraryValRef && typeEquiv g ty einfo.ApparentEnclosingType) let impliedNames = try @@ -1883,8 +1883,8 @@ module TastDefinitionPrinting = let inherits = [ if not (suppressInheritanceAndInterfacesForTyInSimplifiedDisplays g amap m ty) then match GetSuperTypeOfType g amap m ty with - | Some super when not (isObjTy g super) && not (isValueTypeTy g super) -> - super + | Some superTy when not (isObjTy g superTy) && not (isValueTypeTy g superTy) -> + superTy | _ -> () ] @@ -2052,8 +2052,8 @@ module TastDefinitionPrinting = |> addLhs | TNoRepr when tycon.TypeAbbrev.IsSome -> - let abbreviatedType = tycon.TypeAbbrev.Value - (lhsL ^^ WordL.equals) -* (layoutType { denv with shortTypeNames = false } abbreviatedType) + let abbreviatedTy = tycon.TypeAbbrev.Value + (lhsL ^^ WordL.equals) -* (layoutType { denv with shortTypeNames = false } abbreviatedTy) | _ when isNil allDecls -> lhsL @@ -2386,8 +2386,8 @@ module PrintData = else layoutConst denv.g ty c - | Expr.Val (v, _, _) -> - wordL (tagLocal v.DisplayName) + | Expr.Val (vref, _, _) -> + wordL (tagLocal vref.DisplayName) | Expr.Link rX -> dataExprWrapL denv isAtomic rX.Value @@ -2435,21 +2435,28 @@ let outputValOrMember denv infoReader os x = x |> PrintTastMemberOrVals.prettyLa let stringValOrMember denv infoReader x = x |> PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv infoReader |> showL /// Print members with a qualification showing the type they are contained in -let layoutQualifiedValOrMember denv infoReader typarInst v = PrintTastMemberOrVals.prettyLayoutOfValOrMember { denv with showMemberContainers=true; } infoReader typarInst v +let layoutQualifiedValOrMember denv infoReader typarInst vref = + PrintTastMemberOrVals.prettyLayoutOfValOrMember { denv with showMemberContainers=true; } infoReader typarInst vref -let outputQualifiedValOrMember denv infoReader os v = outputValOrMember { denv with showMemberContainers=true; } infoReader os v +let outputQualifiedValOrMember denv infoReader os vref = + outputValOrMember { denv with showMemberContainers=true; } infoReader os vref -let outputQualifiedValSpec denv infoReader os v = outputQualifiedValOrMember denv infoReader os v +let outputQualifiedValSpec denv infoReader os vref = + outputQualifiedValOrMember denv infoReader os vref -let stringOfQualifiedValOrMember denv infoReader v = PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst { denv with showMemberContainers=true; } infoReader v |> showL +let stringOfQualifiedValOrMember denv infoReader vref = + PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst { denv with showMemberContainers=true; } infoReader vref |> showL /// Convert a MethInfo to a string -let formatMethInfoToBufferFreeStyle infoReader m denv buf d = InfoMemberPrinting.formatMethInfoToBufferFreeStyle infoReader m denv buf d +let formatMethInfoToBufferFreeStyle infoReader m denv buf d = + InfoMemberPrinting.formatMethInfoToBufferFreeStyle infoReader m denv buf d -let prettyLayoutOfMethInfoFreeStyle infoReader m denv typarInst minfo = InfoMemberPrinting.prettyLayoutOfMethInfoFreeStyle infoReader m denv typarInst minfo +let prettyLayoutOfMethInfoFreeStyle infoReader m denv typarInst minfo = + InfoMemberPrinting.prettyLayoutOfMethInfoFreeStyle infoReader m denv typarInst minfo /// Convert a PropInfo to a string -let prettyLayoutOfPropInfoFreeStyle g amap m denv d = InfoMemberPrinting.prettyLayoutOfPropInfoFreeStyle g amap m denv d +let prettyLayoutOfPropInfoFreeStyle g amap m denv d = + InfoMemberPrinting.prettyLayoutOfPropInfoFreeStyle g amap m denv d /// Convert a MethInfo to a string let stringOfMethInfo infoReader m denv minfo = @@ -2509,13 +2516,15 @@ let stringOfILAttrib denv x = x |> PrintTypes.layoutILAttrib denv |> squareAngle let layoutImpliedSignatureOfModuleOrNamespace showHeader denv infoReader ad m contents = InferredSigPrinting.layoutImpliedSignatureOfModuleOrNamespace showHeader denv infoReader ad m contents -let prettyLayoutOfValOrMember denv infoReader typarInst v = PrintTastMemberOrVals.prettyLayoutOfValOrMember denv infoReader typarInst v +let prettyLayoutOfValOrMember denv infoReader typarInst vref = + PrintTastMemberOrVals.prettyLayoutOfValOrMember denv infoReader typarInst vref -let prettyLayoutOfValOrMemberNoInst denv infoReader v = PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv infoReader v +let prettyLayoutOfValOrMemberNoInst denv infoReader vref = + PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv infoReader vref let prettyLayoutOfMemberNoInstShort denv v = PrintTastMemberOrVals.prettyLayoutOfMemberNoInstShort denv v -let layoutOfValReturnType denv v = v |> PrintTypes.layoutOfValReturnType denv +let layoutOfValReturnType denv vref = vref |> PrintTypes.layoutOfValReturnType denv let prettyLayoutOfInstAndSig denv x = PrintTypes.prettyLayoutOfInstAndSig denv x @@ -2523,14 +2532,14 @@ let prettyLayoutOfInstAndSig denv x = PrintTypes.prettyLayoutOfInstAndSig denv x /// /// If the output text is different without showing constraints and/or imperative type variable /// annotations and/or fully qualifying paths then don't show them! -let minimalStringsOfTwoTypes denv t1 t2= - let (t1, t2), tpcs = PrettyTypes.PrettifyTypePair denv.g (t1, t2) +let minimalStringsOfTwoTypes denv ty1 ty2 = + let (ty1, ty2), tpcs = PrettyTypes.PrettifyTypePair denv.g (ty1, ty2) // try denv + no type annotations let attempt1 = let denv = { denv with showInferenceTyparAnnotations=false; showStaticallyResolvedTyparAnnotations=false } - let min1 = stringOfTy denv t1 - let min2 = stringOfTy denv t2 + let min1 = stringOfTy denv ty1 + let min2 = stringOfTy denv ty2 if min1 <> min2 then Some (min1, min2, "") else None match attempt1 with @@ -2540,8 +2549,8 @@ let minimalStringsOfTwoTypes denv t1 t2= // try denv + no type annotations + show full paths let attempt2 = let denv = { denv with showInferenceTyparAnnotations=false; showStaticallyResolvedTyparAnnotations=false }.SetOpenPaths [] - let min1 = stringOfTy denv t1 - let min2 = stringOfTy denv t2 + let min1 = stringOfTy denv ty1 + let min2 = stringOfTy denv ty2 if min1 <> min2 then Some (min1, min2, "") else None match attempt2 with @@ -2549,8 +2558,8 @@ let minimalStringsOfTwoTypes denv t1 t2= | None -> let attempt3 = - let min1 = stringOfTy denv t1 - let min2 = stringOfTy denv t2 + let min1 = stringOfTy denv ty1 + let min2 = stringOfTy denv ty2 if min1 <> min2 then Some (min1, min2, stringOfTyparConstraints denv tpcs) else None match attempt3 with @@ -2561,8 +2570,8 @@ let minimalStringsOfTwoTypes denv t1 t2= // try denv + show full paths + static parameters let denv = denv.SetOpenPaths [] let denv = { denv with includeStaticParametersInTypeNames=true } - let min1 = stringOfTy denv t1 - let min2 = stringOfTy denv t2 + let min1 = stringOfTy denv ty1 + let min2 = stringOfTy denv ty2 if min1 <> min2 then Some (min1, min2, stringOfTyparConstraints denv tpcs) else None match attempt4 with @@ -2576,19 +2585,19 @@ let minimalStringsOfTwoTypes denv t1 t2= let assemblyName = PrintTypes.layoutAssemblyName denv t |> function | null | "" -> "" | name -> sprintf " (%s)" name sprintf "%s%s" (stringOfTy denv t) assemblyName - (makeName t1, makeName t2, stringOfTyparConstraints denv tpcs) + (makeName ty1, makeName ty2, stringOfTyparConstraints denv tpcs) // Note: Always show imperative annotations when comparing value signatures -let minimalStringsOfTwoValues denv infoReader v1 v2= +let minimalStringsOfTwoValues denv infoReader vref1 vref2 = let denvMin = { denv with showInferenceTyparAnnotations=true; showStaticallyResolvedTyparAnnotations=false } - let min1 = buildString (fun buf -> outputQualifiedValOrMember denvMin infoReader buf v1) - let min2 = buildString (fun buf -> outputQualifiedValOrMember denvMin infoReader buf v2) + let min1 = buildString (fun buf -> outputQualifiedValOrMember denvMin infoReader buf vref1) + let min2 = buildString (fun buf -> outputQualifiedValOrMember denvMin infoReader buf vref2) if min1 <> min2 then (min1, min2) else let denvMax = { denv with showInferenceTyparAnnotations=true; showStaticallyResolvedTyparAnnotations=true } - let max1 = buildString (fun buf -> outputQualifiedValOrMember denvMax infoReader buf v1) - let max2 = buildString (fun buf -> outputQualifiedValOrMember denvMax infoReader buf v2) + let max1 = buildString (fun buf -> outputQualifiedValOrMember denvMax infoReader buf vref1) + let max2 = buildString (fun buf -> outputQualifiedValOrMember denvMax infoReader buf vref2) max1, max2 let minimalStringOfType denv ty = diff --git a/src/Compiler/Checking/NicePrint.fsi b/src/Compiler/Checking/NicePrint.fsi index c9df76a87a7..523202af9b9 100644 --- a/src/Compiler/Checking/NicePrint.fsi +++ b/src/Compiler/Checking/NicePrint.fsi @@ -54,14 +54,14 @@ val layoutQualifiedValOrMember: denv: DisplayEnv -> infoReader: InfoReader -> typarInst: TyparInstantiation -> - v: ValRef -> + vref: ValRef -> TyparInstantiation * Layout -val outputQualifiedValOrMember: denv: DisplayEnv -> infoReader: InfoReader -> os: StringBuilder -> v: ValRef -> unit +val outputQualifiedValOrMember: denv: DisplayEnv -> infoReader: InfoReader -> os: StringBuilder -> vref: ValRef -> unit -val outputQualifiedValSpec: denv: DisplayEnv -> infoReader: InfoReader -> os: StringBuilder -> v: ValRef -> unit +val outputQualifiedValSpec: denv: DisplayEnv -> infoReader: InfoReader -> os: StringBuilder -> vref: ValRef -> unit -val stringOfQualifiedValOrMember: denv: DisplayEnv -> infoReader: InfoReader -> v: ValRef -> string +val stringOfQualifiedValOrMember: denv: DisplayEnv -> infoReader: InfoReader -> vref: ValRef -> string val formatMethInfoToBufferFreeStyle: infoReader: InfoReader -> m: range -> denv: DisplayEnv -> buf: StringBuilder -> d: MethInfo -> unit @@ -139,22 +139,23 @@ val prettyLayoutOfValOrMember: denv: DisplayEnv -> infoReader: InfoReader -> typarInst: TyparInstantiation -> - v: ValRef -> + vref: ValRef -> TyparInstantiation * Layout -val prettyLayoutOfValOrMemberNoInst: denv: DisplayEnv -> infoReader: InfoReader -> v: ValRef -> Layout +val prettyLayoutOfValOrMemberNoInst: denv: DisplayEnv -> infoReader: InfoReader -> vref: ValRef -> Layout val prettyLayoutOfMemberNoInstShort: denv: DisplayEnv -> v: Val -> Layout -val layoutOfValReturnType: denv: DisplayEnv -> v: ValRef -> Layout +val layoutOfValReturnType: denv: DisplayEnv -> vref: ValRef -> Layout val prettyLayoutOfInstAndSig: denv: DisplayEnv -> TyparInstantiation * TTypes * TType -> TyparInstantiation * (TTypes * TType) * (Layout list * Layout) * Layout -val minimalStringsOfTwoTypes: denv: DisplayEnv -> t1: TType -> t2: TType -> string * string * string +val minimalStringsOfTwoTypes: denv: DisplayEnv -> ty1: TType -> ty2: TType -> string * string * string -val minimalStringsOfTwoValues: denv: DisplayEnv -> infoReader: InfoReader -> v1: ValRef -> v2: ValRef -> string * string +val minimalStringsOfTwoValues: + denv: DisplayEnv -> infoReader: InfoReader -> vref1: ValRef -> vref2: ValRef -> string * string val minimalStringOfType: denv: DisplayEnv -> ty: TType -> string diff --git a/src/Compiler/Checking/PatternMatchCompilation.fs b/src/Compiler/Checking/PatternMatchCompilation.fs index c38f65e307e..ec5c5488f81 100644 --- a/src/Compiler/Checking/PatternMatchCompilation.fs +++ b/src/Compiler/Checking/PatternMatchCompilation.fs @@ -312,8 +312,8 @@ let RefuteDiscrimSet g m path discrims = raise CannotRefute go path tm -let rec CombineRefutations g r1 r2 = - match r1, r2 with +let rec CombineRefutations g refutation1 refutation2 = + match refutation1, refutation2 with | Expr.Val (vref, _, _), other | other, Expr.Val (vref, _, _) when vref.LogicalName = "_" -> other | Expr.Val (vref, _, _), other | other, Expr.Val (vref, _, _) when vref.LogicalName = notNullText -> other | Expr.Val (vref, _, _), other | other, Expr.Val (vref, _, _) when vref.LogicalName = otherSubtypeText -> other @@ -326,9 +326,9 @@ let rec CombineRefutations g r1 r2 = Expr.Op (op1, tinst1, List.map2 (CombineRefutations g) flds1 flds2, m1) (* Choose the greater of the two ucrefs based on name ordering *) elif ucref1.CaseName < ucref2.CaseName then - r2 + refutation2 else - r1 + refutation1 | Expr.Op (op1, tinst1, flds1, m1), Expr.Op (_, _, flds2, _) -> Expr.Op (op1, tinst1, List.map2 (CombineRefutations g) flds1 flds2, m1) @@ -352,7 +352,7 @@ let rec CombineRefutations g r1 r2 = Expr.Const (c12, m1, ty1) - | _ -> r1 + | _ -> refutation1 let ShowCounterExample g denv m refuted = try @@ -592,8 +592,8 @@ let getDiscrimOfPattern (g: TcGlobals) tpinst t = match t with | TPat_null _m -> Some(DecisionTreeTest.IsNull) - | TPat_isinst (srcty, tgty, _, _m) -> - Some(DecisionTreeTest.IsInst (instType tpinst srcty, instType tpinst tgty)) + | TPat_isinst (srcTy, tgtTy, _, _m) -> + Some(DecisionTreeTest.IsInst (instType tpinst srcTy, instType tpinst tgtTy)) | TPat_exnconstr(tcref, _, _m) -> Some(DecisionTreeTest.IsInst (g.exn_ty, mkAppTy tcref [])) | TPat_const (c, _m) -> @@ -624,7 +624,7 @@ let discrimsEq (g: TcGlobals) d1 d2 = | DecisionTreeTest.ArrayLength (n1, _), DecisionTreeTest.ArrayLength(n2, _) -> (n1=n2) | DecisionTreeTest.Const c1, DecisionTreeTest.Const c2 -> (c1=c2) | DecisionTreeTest.IsNull, DecisionTreeTest.IsNull -> true - | DecisionTreeTest.IsInst (srcty1, tgty1), DecisionTreeTest.IsInst (srcty2, tgty2) -> typeEquiv g srcty1 srcty2 && typeEquiv g tgty1 tgty2 + | DecisionTreeTest.IsInst (srcTy1, tgtTy1), DecisionTreeTest.IsInst (srcTy2, tgtTy2) -> typeEquiv g srcTy1 srcTy2 && typeEquiv g tgtTy1 tgtTy2 | DecisionTreeTest.ActivePatternCase (_, _, _, vrefOpt1, n1, _), DecisionTreeTest.ActivePatternCase (_, _, _, vrefOpt2, n2, _) -> match vrefOpt1, vrefOpt2 with | Some (vref1, tinst1), Some (vref2, tinst2) -> valRefEq g vref1 vref2 && n1 = n2 && not (doesActivePatternHaveFreeTypars g vref1) && List.lengthsEqAndForall2 (typeEquiv g) tinst1 tinst2 @@ -1213,15 +1213,15 @@ let CompilePatternBasic // This is really an optimization that could be done more effectively in opt.fs // if we flowed a bit of information through - | [EdgeDiscrim(_i', DecisionTreeTest.IsInst (_srcty, tgty), m)] + | [EdgeDiscrim(_i', DecisionTreeTest.IsInst (_srcTy, tgtTy), m)] // check we can use a simple 'isinst' instruction - when isRefTy g tgty && canUseTypeTestFast g tgty && isNil origInputValTypars -> + when isRefTy g tgtTy && canUseTypeTestFast g tgtTy && isNil origInputValTypars -> - let v, vExpr = mkCompGenLocal m "typeTestResult" tgty + let v, vExpr = mkCompGenLocal m "typeTestResult" tgtTy if origInputVal.IsMemberOrModuleBinding then AdjustValToTopVal v origInputVal.DeclaringEntity ValReprInfo.emptyValData let argExpr = GetSubExprOfInput subexpr - let appExpr = mkIsInst tgty argExpr mMatch + let appExpr = mkIsInst tgtTy argExpr mMatch Some vExpr, Some(mkInvisibleBind v appExpr) // Any match on a struct union must take the address of its input. diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index 1459fc99984..d8bca9c223c 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -416,8 +416,8 @@ and CheckTypeConstraintDeep cenv f g env x = | TyparConstraint.MayResolveMember(traitInfo, _) -> CheckTraitInfoDeep cenv f g env traitInfo | TyparConstraint.DefaultsTo(_, ty, _) -> CheckTypeDeep cenv f g env true ty | TyparConstraint.SimpleChoice(tys, _) -> CheckTypesDeep cenv f g env tys - | TyparConstraint.IsEnum(uty, _) -> CheckTypeDeep cenv f g env true uty - | TyparConstraint.IsDelegate(aty, bty, _) -> CheckTypeDeep cenv f g env true aty; CheckTypeDeep cenv f g env true bty + | TyparConstraint.IsEnum(underlyingTy, _) -> CheckTypeDeep cenv f g env true underlyingTy + | TyparConstraint.IsDelegate(argTys, retTy, _) -> CheckTypeDeep cenv f g env true argTys; CheckTypeDeep cenv f g env true retTy | TyparConstraint.SupportsComparison _ | TyparConstraint.SupportsEquality _ | TyparConstraint.SupportsNull _ @@ -717,39 +717,42 @@ type TTypeEquality = | FeasiblyEqual | NotEqual -let compareTypesWithRegardToTypeVariablesAndMeasures g amap m typ1 typ2 = +let compareTypesWithRegardToTypeVariablesAndMeasures g amap m ty1 ty2 = - if (typeEquiv g typ1 typ2) then + if (typeEquiv g ty1 ty2) then ExactlyEqual else - if (typeEquiv g typ1 typ2 || TypesFeasiblyEquivStripMeasures g amap m typ1 typ2) then + if (typeEquiv g ty1 ty2 || TypesFeasiblyEquivStripMeasures g amap m ty1 ty2) then FeasiblyEqual else NotEqual -let CheckMultipleInterfaceInstantiations cenv (typ:TType) (interfaces:TType list) isObjectExpression m = - let keyf ty = assert isAppTy cenv.g ty; (tcrefOfAppTy cenv.g ty).Stamp - let groups = interfaces |> List.groupBy keyf +let keyTyByStamp g ty = + assert isAppTy g ty + (tcrefOfAppTy g ty).Stamp + +let CheckMultipleInterfaceInstantiations cenv (ty:TType) (interfaces:TType list) isObjectExpression m = + let groups = interfaces |> List.groupBy (keyTyByStamp cenv.g) let errors = seq { for _, items in groups do for i1 in 0 .. items.Length - 1 do for i2 in i1 + 1 .. items.Length - 1 do - let typ1 = items[i1] - let typ2 = items[i2] - let tcRef1 = tcrefOfAppTy cenv.g typ1 - match compareTypesWithRegardToTypeVariablesAndMeasures cenv.g cenv.amap m typ1 typ2 with + let ty1 = items[i1] + let ty2 = items[i2] + let tcRef1 = tcrefOfAppTy cenv.g ty1 + match compareTypesWithRegardToTypeVariablesAndMeasures cenv.g cenv.amap m ty1 ty2 with | ExactlyEqual -> () | FeasiblyEqual -> match tryLanguageFeatureErrorOption cenv.g.langVersion LanguageFeature.InterfacesWithMultipleGenericInstantiation m with | None -> () | Some exn -> exn - let typ1Str = NicePrint.minimalStringOfType cenv.denv typ1 - let typ2Str = NicePrint.minimalStringOfType cenv.denv typ2 + let typ1Str = NicePrint.minimalStringOfType cenv.denv ty1 + let typ2Str = NicePrint.minimalStringOfType cenv.denv ty2 if isObjectExpression then Error(FSComp.SR.typrelInterfaceWithConcreteAndVariableObjectExpression(tcRef1.DisplayNameWithStaticParametersAndUnderscoreTypars, typ1Str, typ2Str),m) else - let typStr = NicePrint.minimalStringOfType cenv.denv typ + let typStr = NicePrint.minimalStringOfType cenv.denv ty Error(FSComp.SR.typrelInterfaceWithConcreteAndVariable(typStr, tcRef1.DisplayNameWithStaticParametersAndUnderscoreTypars, typ1Str, typ2Str),m) | NotEqual -> @@ -1575,8 +1578,8 @@ and CheckExprOp cenv env (op, tyargs, args, m) ctxt expr = errorR(Error(FSComp.SR.chkNoWriteToLimitedSpan(rf.FieldName), m)) NoLimit - | TOp.Coerce, [tgty;srcty], [x] -> - if TypeDefinitelySubsumesTypeNoCoercion 0 g cenv.amap m tgty srcty then + | TOp.Coerce, [tgtTy;srcTy], [x] -> + if TypeDefinitelySubsumesTypeNoCoercion 0 g cenv.amap m tgtTy srcTy then CheckExpr cenv env x ctxt else CheckTypeInstNoByrefs cenv env m tyargs @@ -2279,8 +2282,8 @@ let CheckEntityDefn cenv env (tycon: Entity) = let allVirtualMethsInParent = match GetSuperTypeOfType g cenv.amap m ty with - | Some super -> - GetIntrinsicMethInfosOfType cenv.infoReader None AccessibleFromSomewhere AllowMultiIntfInstantiations.Yes IgnoreOverrides m super + | Some superTy -> + GetIntrinsicMethInfosOfType cenv.infoReader None AccessibleFromSomewhere AllowMultiIntfInstantiations.Yes IgnoreOverrides m superTy |> List.filter (fun minfo -> minfo.IsVirtual) | None -> [] diff --git a/src/Compiler/Checking/QuotationTranslator.fs b/src/Compiler/Checking/QuotationTranslator.fs index 044ff283f0b..089de7b4a7f 100644 --- a/src/Compiler/Checking/QuotationTranslator.fs +++ b/src/Compiler/Checking/QuotationTranslator.fs @@ -172,7 +172,7 @@ let (|ModuleValueOrMemberUse|_|) g expr = match stripExpr expr with | Expr.App (InnerExprPat(Expr.Val (vref, vFlags, _) as f), fty, tyargs, actualArgs, _m) when vref.IsMemberOrModuleBinding -> Some(vref, vFlags, f, fty, tyargs, actualArgs @ args) - | Expr.App (f, _fty, [], actualArgs, _) -> + | Expr.App (f, _fTy, [], actualArgs, _) -> loop f (actualArgs @ args) | Expr.Val (vref, vFlags, _m) as f when (match vref.DeclaringEntity with ParentNone -> false | _ -> true) -> let fty = tyOfExpr g f @@ -292,8 +292,8 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. // Recognize applications of module functions. match expr with // Detect expression tree exprSplices - | Expr.App (InnerExprPat(Expr.Val (vf, _, _)), _, _, x0 :: rest, m) - when isSplice g vf -> + | Expr.App (InnerExprPat(Expr.Val (vref, _, _)), _, _, x0 :: rest, m) + when isSplice g vref -> let idx = cenv.exprSplices.Count let ty = tyOfExpr g expr @@ -305,7 +305,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. let hole = QP.mkHole(ConvType cenv env m ty, idx) (hole, rest) ||> List.fold (fun fR arg -> QP.mkApp (fR, ConvExpr cenv env arg)) - | ModuleValueOrMemberUse g (vref, vFlags, _f, _fty, tyargs, curriedArgs) + | ModuleValueOrMemberUse g (vref, vFlags, _f, _fTy, tyargs, curriedArgs) when not (isSplice g vref) -> let m = expr.Range @@ -419,16 +419,16 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. List.fold (fun fR arg -> QP.mkApp (fR, ConvExpr cenv env arg)) callR laterArgs // Blast type application nodes and expression application nodes apart so values are left with just their type arguments - | Expr.App (f, fty, (_ :: _ as tyargs), (_ :: _ as args), m) -> - let rfty = applyForallTy g fty tyargs - ConvExpr cenv env (primMkApp (primMkApp (f, fty) tyargs [] m, rfty) [] args m) + | Expr.App (f, fTy, (_ :: _ as tyargs), (_ :: _ as args), m) -> + let reducedTy = applyForallTy g fTy tyargs + ConvExpr cenv env (primMkApp (primMkApp (f, fTy) tyargs [] m, reducedTy) [] args m) // Uses of possibly-polymorphic values - | Expr.App (InnerExprPat(Expr.Val (vref, _vFlags, m)), _fty, tyargs, [], _) -> + | Expr.App (InnerExprPat(Expr.Val (vref, _vFlags, m)), _fTy, tyargs, [], _) -> ConvValRef true cenv env m vref tyargs // Simple applications - | Expr.App (f, _fty, tyargs, args, m) -> + | Expr.App (f, _fTy, tyargs, args, m) -> if not (List.isEmpty tyargs) then wfail(Error(FSComp.SR.crefQuotationsCantContainGenericExprs(), m)) List.fold (fun fR arg -> QP.mkApp (fR, ConvExpr cenv env arg)) (ConvExpr cenv env f) args @@ -828,12 +828,12 @@ and ConvLValueExprCore cenv env expr = | TOp.UnionCaseFieldGetAddr (ucref, n, _), [e], _ -> ConvUnionFieldGet cenv env m ucref n tyargs e | TOp.ILAsm ([ I_ldflda(fspec) ], _), _, _ -> ConvLdfld cenv env m fspec tyargs args | TOp.ILAsm ([ I_ldsflda(fspec) ], _), _, _ -> ConvLdfld cenv env m fspec tyargs args - | TOp.ILAsm ([ I_ldelema(_ro, _isNativePtr, shape, _tyarg) ], _), arr :: idxs, [elemty] -> + | TOp.ILAsm ([ I_ldelema(_ro, _isNativePtr, shape, _tyarg) ], _), arr :: idxs, [elemTy] -> match shape.Rank, idxs with - | 1, [idx1] -> ConvExpr cenv env (mkCallArrayGet cenv.g m elemty arr idx1) - | 2, [idx1; idx2] -> ConvExpr cenv env (mkCallArray2DGet cenv.g m elemty arr idx1 idx2) - | 3, [idx1; idx2; idx3] -> ConvExpr cenv env (mkCallArray3DGet cenv.g m elemty arr idx1 idx2 idx3) - | 4, [idx1; idx2; idx3; idx4] -> ConvExpr cenv env (mkCallArray4DGet cenv.g m elemty arr idx1 idx2 idx3 idx4) + | 1, [idx1] -> ConvExpr cenv env (mkCallArrayGet cenv.g m elemTy arr idx1) + | 2, [idx1; idx2] -> ConvExpr cenv env (mkCallArray2DGet cenv.g m elemTy arr idx1 idx2) + | 3, [idx1; idx2; idx3] -> ConvExpr cenv env (mkCallArray3DGet cenv.g m elemTy arr idx1 idx2 idx3) + | 4, [idx1; idx2; idx3; idx4] -> ConvExpr cenv env (mkCallArray4DGet cenv.g m elemTy arr idx1 idx2 idx3 idx4) | _ -> ConvExpr cenv env expr | _ -> ConvExpr cenv env expr | _ -> ConvExpr cenv env expr @@ -937,15 +937,15 @@ and private ConvValRefCore holeOk cenv env m (vref: ValRef) tyargs = elif v.IsCtorThisVal && cenv.isReflectedDefinition = IsReflectedDefinition.Yes then QP.mkThisVar(ConvType cenv env m v.Type) else - let vty = v.Type + let vTy = v.Type match v.DeclaringEntity with | ParentNone -> // References to local values are embedded by value if not holeOk then wfail(Error(FSComp.SR.crefNoSetOfHole(), m)) let idx = cenv.exprSplices.Count - let liftExpr = mkCallLiftValueWithName cenv.g m vty v.LogicalName (exprForValRef m vref) + let liftExpr = mkCallLiftValueWithName cenv.g m vTy v.LogicalName (exprForValRef m vref) cenv.exprSplices.Add((liftExpr, m)) - QP.mkHole(ConvType cenv env m vty, idx) + QP.mkHole(ConvType cenv env m vTy, idx) | Parent _ -> // First-class use or use of type function @@ -1106,9 +1106,9 @@ and ConvDecisionTree cenv env tgs typR x = let eqR = ConvExpr cenv env eq QP.mkCond (eqR, ConvDecisionTree cenv env tgs typR dtree, acc) - | DecisionTreeTest.IsInst (_srcty, tgty) -> + | DecisionTreeTest.IsInst (_srcTy, tgtTy) -> let e1R = ConvExpr cenv env e1 - QP.mkCond (QP.mkTypeTest (ConvType cenv env m tgty, e1R), ConvDecisionTree cenv env tgs typR dtree, acc) + QP.mkCond (QP.mkTypeTest (ConvType cenv env m tgtTy, e1R), ConvDecisionTree cenv env tgs typR dtree, acc) | DecisionTreeTest.ActivePatternCase _ -> wfail(InternalError( "DecisionTreeTest.ActivePatternCase test in quoted expression", m)) diff --git a/src/Compiler/Checking/SignatureConformance.fs b/src/Compiler/Checking/SignatureConformance.fs index f9d9b41b871..4a689f48a0c 100644 --- a/src/Compiler/Checking/SignatureConformance.fs +++ b/src/Compiler/Checking/SignatureConformance.fs @@ -187,26 +187,26 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) = else let aenv = aenv.BindEquivTypars implTypars sigTypars - let aintfs = implTycon.ImmediateInterfaceTypesOfFSharpTycon - let fintfs = sigTycon.ImmediateInterfaceTypesOfFSharpTycon - let aintfsUser = implTycon.TypeContents.tcaug_interfaces |> List.filter (fun (_, compgen, _) -> not compgen) |> List.map p13 + let implIntfTys = implTycon.ImmediateInterfaceTypesOfFSharpTycon + let sigIntfTys = sigTycon.ImmediateInterfaceTypesOfFSharpTycon + let implUserIntfTys = implTycon.TypeContents.tcaug_interfaces |> List.filter (fun (_, compgen, _) -> not compgen) |> List.map p13 let flatten tys = tys |> List.collect (AllSuperTypesOfType g amap m AllowMultiIntfInstantiations.Yes) |> ListSet.setify (typeEquiv g) |> List.filter (isInterfaceTy g) - let aintfs = flatten aintfs - let fintfs = flatten fintfs + let implIntfTys = flatten implIntfTys + let sigIntfTys = flatten sigIntfTys - let unimpl = ListSet.subtract (fun fity aity -> typeAEquiv g aenv aity fity) fintfs aintfs - (unimpl + let unimplIntfTys = ListSet.subtract (fun sigIntfTy implIntfTy -> typeAEquiv g aenv implIntfTy sigIntfTy) sigIntfTys implIntfTys + (unimplIntfTys |> List.forall (fun ity -> let errorMessage = FSComp.SR.DefinitionsInSigAndImplNotCompatibleMissingInterface(implTycon.TypeOrMeasureKind.ToString(), implTycon.DisplayName, NicePrint.minimalStringOfType denv ity) errorR (Error(errorMessage, m)); false)) && - let aintfsUser = flatten aintfsUser + let implUserIntfTys = flatten implUserIntfTys - let hidden = ListSet.subtract (typeAEquiv g aenv) aintfsUser fintfs + let hidden = ListSet.subtract (typeAEquiv g aenv) implUserIntfTys sigIntfTys let continueChecks, warningOrError = if implTycon.IsFSharpInterfaceTycon then false, errorR else true, warning (hidden |> List.forall (fun ity -> warningOrError (InterfaceNotRevealed(denv, ity, implTycon.Range)); continueChecks)) && @@ -328,12 +328,12 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) = elif implVal.LiteralValue <> sigVal.LiteralValue then (err denv FSComp.SR.ValueNotContainedMutabilityLiteralConstantValuesDiffer) elif implVal.IsTypeFunction <> sigVal.IsTypeFunction then (err denv FSComp.SR.ValueNotContainedMutabilityOneIsTypeFunction) else - let implTypars, atau = implVal.GeneralizedType - let sigTypars, ftau = sigVal.GeneralizedType + let implTypars, implValTy = implVal.GeneralizedType + let sigTypars, sigValTy = sigVal.GeneralizedType if implTypars.Length <> sigTypars.Length then (err {denv with showTyparBinding=true} FSComp.SR.ValueNotContainedMutabilityParameterCountsDiffer) else let aenv = aenv.BindEquivTypars implTypars sigTypars checkTypars m aenv implTypars sigTypars && - if not (typeAEquiv g aenv atau ftau) then err denv FSComp.SR.ValueNotContainedMutabilityTypesDiffer + if not (typeAEquiv g aenv implValTy sigValTy) then err denv FSComp.SR.ValueNotContainedMutabilityTypesDiffer elif not (checkValInfo aenv (err denv) implVal sigVal) then false elif not (implVal.IsExtensionMember = sigVal.IsExtensionMember) then err denv FSComp.SR.ValueNotContainedMutabilityExtensionsDiffer elif not (checkMemberDatasConform (err denv) (implVal.Attribs, implVal, implVal.MemberInfo) (sigVal.Attribs, sigVal, sigVal.MemberInfo)) then false diff --git a/src/Compiler/Checking/TypeHierarchy.fs b/src/Compiler/Checking/TypeHierarchy.fs index 12572e87d10..fe44b9cf874 100644 --- a/src/Compiler/Checking/TypeHierarchy.fs +++ b/src/Compiler/Checking/TypeHierarchy.fs @@ -92,8 +92,8 @@ let GetImmediateInterfacesOfMetadataType g amap m skipUnref ty (tcref: TyconRef) match metadataOfTy g ty with #if !NO_TYPEPROVIDERS | ProvidedTypeMetadata info -> - for ity in info.ProvidedType.PApplyArray((fun st -> st.GetInterfaces()), "GetInterfaces", m) do - ImportProvidedType amap m ity + for intfTy in info.ProvidedType.PApplyArray((fun st -> st.GetInterfaces()), "GetInterfaces", m) do + ImportProvidedType amap m intfTy #endif | ILTypeMetadata (TILObjectReprData(scoref, _, tdef)) -> // ImportILType may fail for an interface if the assembly load set is incomplete and the interface @@ -103,12 +103,12 @@ let GetImmediateInterfacesOfMetadataType g amap m skipUnref ty (tcref: TyconRef) // succeeded with more reported. There are pathological corner cases where this // doesn't apply: e.g. for mscorlib interfaces like IComparable, but we can always // assume those are present. - for ity in tdef.Implements do - if skipUnref = SkipUnrefInterfaces.No || CanRescopeAndImportILType scoref amap m ity then - RescopeAndImportILType scoref amap m tinst ity + for intfTy in tdef.Implements do + if skipUnref = SkipUnrefInterfaces.No || CanRescopeAndImportILType scoref amap m intfTy then + RescopeAndImportILType scoref amap m tinst intfTy | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> - for ity in tcref.ImmediateInterfaceTypesOfFSharpTycon do - instType (mkInstForAppTy g ty) ity ] + for intfTy in tcref.ImmediateInterfaceTypesOfFSharpTycon do + instType (mkInstForAppTy g ty) intfTy ] /// Collect the set of immediate declared interface types for an F# type, but do not /// traverse the type hierarchy to collect further interfaces. @@ -163,10 +163,10 @@ let rec GetImmediateInterfacesOfType skipUnref g amap m ty = and GetImmediateInterfacesOfMeasureAnnotatedType skipUnref g amap m ty reprTy = [ // Report any interfaces that don't derive from IComparable<_> or IEquatable<_> - for ity in GetImmediateInterfacesOfType skipUnref g amap m reprTy do - if not (ExistsHeadTypeInInterfaceHierarchy g.system_GenericIComparable_tcref skipUnref g amap m ity) && - not (ExistsHeadTypeInInterfaceHierarchy g.system_GenericIEquatable_tcref skipUnref g amap m ity) then - ity + for intfTy in GetImmediateInterfacesOfType skipUnref g amap m reprTy do + if not (ExistsHeadTypeInInterfaceHierarchy g.system_GenericIComparable_tcref skipUnref g amap m intfTy) && + not (ExistsHeadTypeInInterfaceHierarchy g.system_GenericIEquatable_tcref skipUnref g amap m intfTy) then + intfTy // NOTE: we should really only report the IComparable> interface for measure-annotated types // if the original type supports IComparable somewhere in the hierarchy, likeiwse IEquatable>. @@ -181,15 +181,15 @@ and GetImmediateInterfacesOfMeasureAnnotatedType skipUnref g amap m ty reprTy = ] // Check for IComparable, IEquatable and interfaces that derive from these -and ExistsHeadTypeInInterfaceHierarchy target skipUnref g amap m ity = - ExistsInInterfaceHierarchy (function AppTy g (tcref,_) -> tyconRefEq g tcref target | _ -> false) skipUnref g amap m ity +and ExistsHeadTypeInInterfaceHierarchy target skipUnref g amap m intfTy = + ExistsInInterfaceHierarchy (function AppTy g (tcref,_) -> tyconRefEq g tcref target | _ -> false) skipUnref g amap m intfTy // Check for IComparable, IEquatable and interfaces that derive from these -and ExistsInInterfaceHierarchy p skipUnref g amap m ity = - match ity with +and ExistsInInterfaceHierarchy p skipUnref g amap m intfTy = + match intfTy with | AppTy g (tcref, tinst) -> - p ity || - (GetImmediateInterfacesOfMetadataType g amap m skipUnref ity tcref tinst + p intfTy || + (GetImmediateInterfacesOfMetadataType g amap m skipUnref intfTy tcref tinst |> List.exists (ExistsInInterfaceHierarchy p skipUnref g amap m)) | _ -> false @@ -369,14 +369,14 @@ let CopyTyparConstraints m tprefInst (tporig: Typar) = TyparConstraint.DefaultsTo (priority, instType tprefInst ty, m) | TyparConstraint.SupportsNull _ -> TyparConstraint.SupportsNull m - | TyparConstraint.IsEnum (uty, _) -> - TyparConstraint.IsEnum (instType tprefInst uty, m) + | TyparConstraint.IsEnum (underlyingTy, _) -> + TyparConstraint.IsEnum (instType tprefInst underlyingTy, m) | TyparConstraint.SupportsComparison _ -> TyparConstraint.SupportsComparison m | TyparConstraint.SupportsEquality _ -> TyparConstraint.SupportsEquality m - | TyparConstraint.IsDelegate(aty, bty, _) -> - TyparConstraint.IsDelegate (instType tprefInst aty, instType tprefInst bty, m) + | TyparConstraint.IsDelegate(argTys, retTy, _) -> + TyparConstraint.IsDelegate (instType tprefInst argTys, instType tprefInst retTy, m) | TyparConstraint.IsNonNullableStruct _ -> TyparConstraint.IsNonNullableStruct m | TyparConstraint.IsUnmanaged _ -> diff --git a/src/Compiler/Checking/TypeRelations.fs b/src/Compiler/Checking/TypeRelations.fs index b0951fd9a79..d714e1b1a60 100644 --- a/src/Compiler/Checking/TypeRelations.fs +++ b/src/Compiler/Checking/TypeRelations.fs @@ -46,24 +46,25 @@ let rec TypeDefinitelySubsumesTypeNoCoercion ndeep g amap m ty1 ty2 = type CanCoerce = CanCoerce | NoCoerce +let stripAll stripMeasures g ty = + if stripMeasures then + ty |> stripTyEqnsWrtErasure EraseAll g |> stripMeasuresFromTy g + else + ty |> stripTyEqns g + /// The feasible equivalence relation. Part of the language spec. let rec TypesFeasiblyEquivalent stripMeasures ndeep g amap m ty1 ty2 = if ndeep > 100 then error(InternalError("recursive class hierarchy (detected in TypeFeasiblySubsumesType), ty1 = " + (DebugPrint.showType ty1), m)); - let stripAll ty = - if stripMeasures then - ty |> stripTyEqnsWrtErasure EraseAll g |> stripMeasuresFromTType g - else - ty |> stripTyEqns g - let ty1str = stripAll ty1 - let ty2str = stripAll ty2 + let ty1 = stripAll stripMeasures g ty1 + let ty2 = stripAll stripMeasures g ty2 - match ty1str, ty2str with + match ty1, ty2 with | TType_var _, _ | _, TType_var _ -> true - | TType_app (tc1, l1, _), TType_app (tc2, l2, _) when tyconRefEq g tc1 tc2 -> + | TType_app (tcref1, l1, _), TType_app (tcref2, l2, _) when tyconRefEq g tcref1 tcref2 -> List.lengthsEqAndForall2 (TypesFeasiblyEquivalent stripMeasures ndeep g amap m) l1 l2 | TType_anon (anonInfo1, l1),TType_anon (anonInfo2, l2) -> @@ -76,9 +77,9 @@ let rec TypesFeasiblyEquivalent stripMeasures ndeep g amap m ty1 ty2 = evalTupInfoIsStruct tupInfo1 = evalTupInfoIsStruct tupInfo2 && List.lengthsEqAndForall2 (TypesFeasiblyEquivalent stripMeasures ndeep g amap m) l1 l2 - | TType_fun (d1, r1, _), TType_fun (d2, r2, _) -> - TypesFeasiblyEquivalent stripMeasures ndeep g amap m d1 d2 && - TypesFeasiblyEquivalent stripMeasures ndeep g amap m r1 r2 + | TType_fun (domainTy1, rangeTy1, _), TType_fun (domainTy2, rangeTy2, _) -> + TypesFeasiblyEquivalent stripMeasures ndeep g amap m domainTy1 domainTy2 && + TypesFeasiblyEquivalent stripMeasures ndeep g amap m rangeTy1 rangeTy2 | TType_measure _, TType_measure _ -> true @@ -133,51 +134,51 @@ let rec TypeFeasiblySubsumesType ndeep g amap m ty1 canCoerce ty2 = /// Here x gets a generalized type "list<'T>". let ChooseTyparSolutionAndRange (g: TcGlobals) amap (tp:Typar) = let m = tp.Range - let max, m = - let initial = + let maxTy, m = + let initialTy = match tp.Kind with | TyparKind.Type -> g.obj_ty | TyparKind.Measure -> TType_measure Measure.One // Loop through the constraints computing the lub - ((initial, m), tp.Constraints) ||> List.fold (fun (maxSoFar, _) tpc -> + ((initialTy, m), tp.Constraints) ||> List.fold (fun (maxTy, _) tpc -> let join m x = - if TypeFeasiblySubsumesType 0 g amap m x CanCoerce maxSoFar then maxSoFar - elif TypeFeasiblySubsumesType 0 g amap m maxSoFar CanCoerce x then x - else errorR(Error(FSComp.SR.typrelCannotResolveImplicitGenericInstantiation((DebugPrint.showType x), (DebugPrint.showType maxSoFar)), m)); maxSoFar + if TypeFeasiblySubsumesType 0 g amap m x CanCoerce maxTy then maxTy + elif TypeFeasiblySubsumesType 0 g amap m maxTy CanCoerce x then x + else errorR(Error(FSComp.SR.typrelCannotResolveImplicitGenericInstantiation((DebugPrint.showType x), (DebugPrint.showType maxTy)), m)); maxTy // Don't continue if an error occurred and we set the value eagerly - if tp.IsSolved then maxSoFar, m else + if tp.IsSolved then maxTy, m else match tpc with | TyparConstraint.CoercesTo(x, m) -> join m x, m | TyparConstraint.MayResolveMember(_traitInfo, m) -> - maxSoFar, m + maxTy, m | TyparConstraint.SimpleChoice(_, m) -> errorR(Error(FSComp.SR.typrelCannotResolveAmbiguityInPrintf(), m)) - maxSoFar, m + maxTy, m | TyparConstraint.SupportsNull m -> - maxSoFar, m + maxTy, m | TyparConstraint.SupportsComparison m -> join m g.mk_IComparable_ty, m | TyparConstraint.SupportsEquality m -> - maxSoFar, m + maxTy, m | TyparConstraint.IsEnum(_, m) -> errorR(Error(FSComp.SR.typrelCannotResolveAmbiguityInEnum(), m)) - maxSoFar, m + maxTy, m | TyparConstraint.IsDelegate(_, _, m) -> errorR(Error(FSComp.SR.typrelCannotResolveAmbiguityInDelegate(), m)) - maxSoFar, m + maxTy, m | TyparConstraint.IsNonNullableStruct m -> join m g.int_ty, m | TyparConstraint.IsUnmanaged m -> errorR(Error(FSComp.SR.typrelCannotResolveAmbiguityInUnmanaged(), m)) - maxSoFar, m + maxTy, m | TyparConstraint.RequiresDefaultConstructor m -> - maxSoFar, m + maxTy, m | TyparConstraint.IsReferenceType m -> - maxSoFar, m + maxTy, m | TyparConstraint.DefaultsTo(_priority, _ty, m) -> - maxSoFar, m) - max, m + maxTy, m) + maxTy, m let ChooseTyparSolution g amap tp = let ty, _m = ChooseTyparSolutionAndRange g amap tp @@ -249,11 +250,11 @@ let tryDestTopLambda g amap (ValReprInfo (tpNames, _, _) as tvd) (e, ty) = (None, None, [], e, ty) let n = tvd.NumCurriedArgs - let tps, taue, tauty = + let tps, bodyExpr, bodyTy = match stripDebugPoints e with | Expr.TyLambda (_, tps, b, _, retTy) when not (isNil tpNames) -> tps, b, retTy | _ -> [], e, ty - let ctorThisValOpt, baseValOpt, vsl, body, retTy = startStripLambdaUpto n (taue, tauty) + let ctorThisValOpt, baseValOpt, vsl, body, retTy = startStripLambdaUpto n (bodyExpr, bodyTy) if vsl.Length <> n then None else diff --git a/src/Compiler/Checking/import.fs b/src/Compiler/Checking/import.fs index ea3dc9dbb9a..cca134f4d38 100644 --- a/src/Compiler/Checking/import.fs +++ b/src/Compiler/Checking/import.fs @@ -174,8 +174,8 @@ let rec ImportILType (env: ImportMap) m tinst ty = | ILType.Array(bounds, ty) -> let n = bounds.Rank - let elementType = ImportILType env m tinst ty - mkArrayTy env.g n elementType m + let elemTy = ImportILType env m tinst ty + mkArrayTy env.g n elemTy m | ILType.Boxed tspec | ILType.Value tspec -> let tcref = ImportILTypeRef env m tspec.TypeRef @@ -335,10 +335,10 @@ let rec ImportProvidedType (env: ImportMap) (m: range) (* (tinst: TypeInst) *) ( if tp.Kind = TyparKind.Measure then let rec conv ty = match ty with - | TType_app (tcref, [t1;t2], _) when tyconRefEq g tcref g.measureproduct_tcr -> Measure.Prod (conv t1, conv t2) - | TType_app (tcref, [t1], _) when tyconRefEq g tcref g.measureinverse_tcr -> Measure.Inv (conv t1) + | TType_app (tcref, [ty1;ty2], _) when tyconRefEq g tcref g.measureproduct_tcr -> Measure.Prod (conv ty1, conv ty2) + | TType_app (tcref, [ty1], _) when tyconRefEq g tcref g.measureinverse_tcr -> Measure.Inv (conv ty1) | TType_app (tcref, [], _) when tyconRefEq g tcref g.measureone_tcr -> Measure.One - | TType_app (tcref, [], _) when tcref.TypeOrMeasureKind = TyparKind.Measure -> Measure.Con tcref + | TType_app (tcref, [], _) when tcref.TypeOrMeasureKind = TyparKind.Measure -> Measure.Const tcref | TType_app (tcref, _, _) -> errorR(Error(FSComp.SR.impInvalidMeasureArgument1(tcref.CompiledName, tp.Name), m)) Measure.One diff --git a/src/Compiler/Checking/infos.fs b/src/Compiler/Checking/infos.fs index 28c4382f918..c5d45e95e3f 100644 --- a/src/Compiler/Checking/infos.fs +++ b/src/Compiler/Checking/infos.fs @@ -55,7 +55,7 @@ type ValRef with | Some membInfo -> not membInfo.MemberFlags.IsDispatchSlot && (match membInfo.ImplementedSlotSigs with - | TSlotSig(_, oty, _, _, _, _) :: _ -> isInterfaceTy g oty + | slotSig :: _ -> isInterfaceTy g slotSig.DeclaringType | [] -> false) member vref.ImplementedSlotSignatures = @@ -312,8 +312,8 @@ let OptionalArgInfoOfProvidedParameter (amap: ImportMap) m (provParam : Tainted< elif isObjTy g ty then MissingValue else DefaultValue - let pty = ImportProvidedType amap m (provParam.PApply((fun p -> p.ParameterType), m)) - CallerSide (analyze pty) + let paramTy = ImportProvidedType amap m (provParam.PApply((fun p -> p.ParameterType), m)) + CallerSide (analyze paramTy) | _ -> let v = provParam.PUntaint((fun p -> p.RawDefaultValue), m) CallerSide (Constant (ILFieldInit.FromProvidedObj m v)) @@ -1217,8 +1217,8 @@ type MethInfo = let formalRetTy = ImportReturnTypeFromMetadata amap m ilminfo.RawMetadata.Return.Type (fun _ -> ilminfo.RawMetadata.Return.CustomAttrs) ftinfo.ILScopeRef ftinfo.TypeInstOfRawMetadata formalMethTyparTys let formalParams = [ [ for p in ilminfo.RawMetadata.Parameters do - let paramType = ImportILTypeFromMetadataWithAttributes amap m ftinfo.ILScopeRef ftinfo.TypeInstOfRawMetadata formalMethTyparTys p.Type (fun _ -> p.CustomAttrs) - yield TSlotParam(p.Name, paramType, p.IsIn, p.IsOut, p.IsOptional, []) ] ] + let paramTy = ImportILTypeFromMetadataWithAttributes amap m ftinfo.ILScopeRef ftinfo.TypeInstOfRawMetadata formalMethTyparTys p.Type (fun _ -> p.CustomAttrs) + yield TSlotParam(p.Name, paramTy, p.IsIn, p.IsOut, p.IsOptional, []) ] ] formalRetTy, formalParams #if !NO_TYPEPROVIDERS | ProvidedMeth (_, mi, _, _) -> @@ -1230,9 +1230,9 @@ type MethInfo = let formalParams = [ [ for p in mi.PApplyArray((fun mi -> mi.GetParameters()), "GetParameters", m) do let paramName = p.PUntaint((fun p -> match p.Name with null -> None | s -> Some s), m) - let paramType = ImportProvidedType amap m (p.PApply((fun p -> p.ParameterType), m)) + let paramTy = ImportProvidedType amap m (p.PApply((fun p -> p.ParameterType), m)) let isIn, isOut, isOptional = p.PUntaint((fun p -> p.IsIn, p.IsOut, p.IsOptional), m) - yield TSlotParam(paramName, paramType, isIn, isOut, isOptional, []) ] ] + yield TSlotParam(paramName, paramTy, isIn, isOut, isOptional, []) ] ] formalRetTy, formalParams #endif | _ -> failwith "unreachable" @@ -1256,15 +1256,15 @@ type MethInfo = | ProvidedMeth(amap, mi, _, _) -> // A single set of tupled parameters [ [for p in mi.PApplyArray((fun mi -> mi.GetParameters()), "GetParameters", m) do - let pname = + let paramName = match p.PUntaint((fun p -> p.Name), m) with | null -> None | name -> Some (mkSynId m name) - let pty = + let paramTy = match p.PApply((fun p -> p.ParameterType), m) with | Tainted.Null -> amap.g.unit_ty | parameterType -> ImportProvidedType amap m parameterType - yield ParamNameAndType(pname, pty) ] ] + yield ParamNameAndType(paramName, paramTy) ] ] #endif @@ -1866,14 +1866,14 @@ type PropInfo = | ProvidedProp (_, pi, m) -> [ for p in pi.PApplyArray((fun pi -> pi.GetIndexParameters()), "GetIndexParameters", m) do let paramName = p.PUntaint((fun p -> match p.Name with null -> None | s -> Some (mkSynId m s)), m) - let paramType = ImportProvidedType amap m (p.PApply((fun p -> p.ParameterType), m)) - yield ParamNameAndType(paramName, paramType) ] + let paramTy = ImportProvidedType amap m (p.PApply((fun p -> p.ParameterType), m)) + yield ParamNameAndType(paramName, paramTy) ] #endif /// Get the details of the indexer parameters associated with the property member x.GetParamDatas(amap, m) = x.GetParamNamesAndTypes(amap, m) - |> List.map (fun (ParamNameAndType(nmOpt, pty)) -> ParamData(false, false, false, NotOptional, NoCallerInfo, nmOpt, ReflectedArgInfo.None, pty)) + |> List.map (fun (ParamNameAndType(nmOpt, paramTy)) -> ParamData(false, false, false, NotOptional, NoCallerInfo, nmOpt, ReflectedArgInfo.None, paramTy)) /// Get the types of the indexer parameters associated with the property member x.GetParamTypes(amap, m) = @@ -1908,14 +1908,16 @@ type PropInfo = /// Uses the same techniques as 'MethInfosUseIdenticalDefinitions'. /// Must be compatible with ItemsAreEffectivelyEqual relation. static member PropInfosUseIdenticalDefinitions x1 x2 = + let optVrefEq g = function - | Some v1, Some v2 -> valRefEq g v1 v2 + | Some vref1, Some vref2 -> valRefEq g vref1 vref2 | None, None -> true | _ -> false + match x1, x2 with | ILProp ilpinfo1, ILProp ilpinfo2 -> (ilpinfo1.RawMetadata === ilpinfo2.RawMetadata) | FSProp(g, _, vrefa1, vrefb1), FSProp(_, _, vrefa2, vrefb2) -> - (optVrefEq g (vrefa1, vrefa2)) && (optVrefEq g (vrefb1, vrefb2)) + optVrefEq g (vrefa1, vrefa2) && optVrefEq g (vrefb1, vrefb2) #if !NO_TYPEPROVIDERS | ProvidedProp(_, pi1, _), ProvidedProp(_, pi2, _) -> ProvidedPropertyInfo.TaintedEquals (pi1, pi2) #endif @@ -1927,7 +1929,7 @@ type PropInfo = | ILProp ilpinfo -> hash ilpinfo.RawMetadata.Name | FSProp(_, _, vrefOpt1, vrefOpt2) -> // Hash on string option * string option - let vth = (vrefOpt1 |> Option.map (fun vr -> vr.LogicalName), (vrefOpt2 |> Option.map (fun vr -> vr.LogicalName))) + let vth = (vrefOpt1 |> Option.map (fun vr -> vr.LogicalName), (vrefOpt2 |> Option.map (fun vref -> vref.LogicalName))) hash vth #if !NO_TYPEPROVIDERS | ProvidedProp(_, pi, _) -> ProvidedPropertyInfo.TaintedGetHashCode pi diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index c39508fc595..361f9078495 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -164,7 +164,7 @@ type AttributeDecoder(namedArgs) = let findTyconRef x = match NameMap.tryFind x nameMap with - | Some (AttribExpr (_, Expr.App (_, _, [ TType_app (tr, _, _) ], _, _))) -> Some tr + | Some (AttribExpr (_, Expr.App (_, _, [ TType_app (tcref, _, _) ], _, _))) -> Some tcref | _ -> None member _.FindInt16 x dflt = @@ -575,7 +575,7 @@ type TypeReprEnv(reprs: Map, count: int, templateReplacement: (Ty member eenv.ForTycon(tycon: Tycon) = eenv.ForTypars tycon.TyparsNoRange /// Get the environment for generating a reference to items within a type definition - member eenv.ForTyconRef(tycon: TyconRef) = eenv.ForTycon tycon.Deref + member eenv.ForTyconRef(tcref: TyconRef) = eenv.ForTycon tcref.Deref //-------------------------------------------------------------------------- // Generate type references @@ -2171,16 +2171,16 @@ type AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbu ) let tcref = mkLocalTyconRef tycon - let typ = generalizedTyconRef g tcref + let ty = generalizedTyconRef g tcref let tcaug = tcref.TypeContents tcaug.tcaug_interfaces <- [ (g.mk_IStructuralComparable_ty, true, m) (g.mk_IComparable_ty, true, m) - (mkAppTy g.system_GenericIComparable_tcref [ typ ], true, m) + (mkAppTy g.system_GenericIComparable_tcref [ ty ], true, m) (g.mk_IStructuralEquatable_ty, true, m) - (mkAppTy g.system_GenericIEquatable_tcref [ typ ], true, m) + (mkAppTy g.system_GenericIEquatable_tcref [ ty ], true, m) ] let vspec1, vspec2 = AugmentWithHashCompare.MakeValsForEqualsAugmentation g tcref @@ -2209,7 +2209,7 @@ type AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbu let ilInterfaceTys = [ - for ity, _, _ in tcaug.tcaug_interfaces -> GenType cenv m (TypeReprEnv.Empty.ForTypars tps) ity + for intfTy, _, _ in tcaug.tcaug_interfaces -> GenType cenv m (TypeReprEnv.Empty.ForTypars tps) intfTy ] let ilTypeDef = @@ -2973,7 +2973,7 @@ and GenExprAux (cenv: cenv) (cgbuf: CodeGenBuffer) eenv expr (sequel: sequel) = match op, args, tyargs with | TOp.ExnConstr c, _, _ -> GenAllocExn cenv cgbuf eenv (c, args, m) sequel | TOp.UnionCase c, _, _ -> GenAllocUnionCase cenv cgbuf eenv (c, tyargs, args, m) sequel - | TOp.Recd (isCtor, tycon), _, _ -> GenAllocRecd cenv cgbuf eenv isCtor (tycon, tyargs, args, m) sequel + | TOp.Recd (isCtor, tcref), _, _ -> GenAllocRecd cenv cgbuf eenv isCtor (tcref, tyargs, args, m) sequel | TOp.AnonRecd anonInfo, _, _ -> GenAllocAnonRecd cenv cgbuf eenv (anonInfo, tyargs, args, m) sequel | TOp.AnonRecdGet (anonInfo, n), [ e ], _ -> GenGetAnonRecdField cenv cgbuf eenv (anonInfo, e, tyargs, n, m) sequel | TOp.TupleFieldGet (tupInfo, n), [ e ], _ -> GenGetTupleField cenv cgbuf eenv (tupInfo, e, tyargs, n, m) sequel @@ -3000,10 +3000,10 @@ and GenExprAux (cenv: cenv) (cgbuf: CodeGenBuffer) eenv expr (sequel: sequel) = [] -> GenIntegerForLoop cenv cgbuf eenv (spFor, spTo, v, e1, dir, e2, e3, m) sequel | TOp.TryFinally (spTry, spFinally), [ Expr.Lambda (_, _, _, [ _ ], e1, _, _); Expr.Lambda (_, _, _, [ _ ], e2, _, _) ], - [ resty ] -> GenTryFinally cenv cgbuf eenv (e1, e2, m, resty, spTry, spFinally) sequel + [ resTy ] -> GenTryFinally cenv cgbuf eenv (e1, e2, m, resTy, spTry, spFinally) sequel | TOp.TryWith (spTry, spWith), [ Expr.Lambda (_, _, _, [ _ ], e1, _, _); Expr.Lambda (_, _, _, [ vf ], ef, _, _); Expr.Lambda (_, _, _, [ vh ], eh, _, _) ], - [ resty ] -> GenTryWith cenv cgbuf eenv (e1, vf, ef, vh, eh, m, resty, spTry, spWith) sequel + [ resTy ] -> GenTryWith cenv cgbuf eenv (e1, vf, ef, vh, eh, m, resTy, spTry, spWith) sequel | TOp.ILCall (isVirtual, _, isStruct, isCtor, valUseFlag, _, noTailCall, ilMethRef, enclTypeInst, methInst, returnTypes), args, [] -> @@ -3014,8 +3014,8 @@ and GenExprAux (cenv: cenv) (cgbuf: CodeGenBuffer) eenv expr (sequel: sequel) = (isVirtual, isStruct, isCtor, valUseFlag, noTailCall, ilMethRef, enclTypeInst, methInst, args, returnTypes, m) sequel | TOp.RefAddrGet _readonly, [ e ], [ ty ] -> GenGetAddrOfRefCellField cenv cgbuf eenv (e, ty, m) sequel - | TOp.Coerce, [ e ], [ tgty; srcty ] -> GenCoerce cenv cgbuf eenv (e, tgty, m, srcty) sequel - | TOp.Reraise, [], [ rtnty ] -> GenReraise cenv cgbuf eenv (rtnty, m) sequel + | TOp.Coerce, [ e ], [ tgtTy; srcTy ] -> GenCoerce cenv cgbuf eenv (e, tgtTy, m, srcTy) sequel + | TOp.Reraise, [], [ retTy ] -> GenReraise cenv cgbuf eenv (retTy, m) sequel | TOp.TraitCall traitInfo, args, [] -> GenTraitCall cenv cgbuf eenv (traitInfo, args, m) expr sequel | TOp.LValueOp (LSet, v), [ e ], [] -> GenSetVal cenv cgbuf eenv (v, e, m) sequel | TOp.LValueOp (LByrefGet, v), [], [] -> GenGetByref cenv cgbuf eenv (v, m) sequel @@ -3285,17 +3285,17 @@ and GenGetTupleField cenv cgbuf eenv (tupInfo, e, tys, n, m) sequel = if ar <= 0 then failwith "getCompiledTupleItem" elif ar < maxTuple then - let tcr' = mkCompiledTupleTyconRef g tupInfo ar - let ty = GenNamedTyApp cenv m eenv.tyenv tcr' tys + let tcref = mkCompiledTupleTyconRef g tupInfo ar + let ty = GenNamedTyApp cenv m eenv.tyenv tcref tys mkGetTupleItemN g m n ty tupInfo e tys[n] else let tysA, tysB = List.splitAfter goodTupleFields tys let tyB = mkCompiledTupleTy g tupInfo tysB - let tys' = tysA @ [ tyB ] - let tcr' = mkCompiledTupleTyconRef g tupInfo (List.length tys') - let ty' = GenNamedTyApp cenv m eenv.tyenv tcr' tys' - let n' = (min n goodTupleFields) - let elast = mkGetTupleItemN g m n' ty' tupInfo e tys'[n'] + let tysC = tysA @ [ tyB ] + let tcref = mkCompiledTupleTyconRef g tupInfo (List.length tysC) + let tyR = GenNamedTyApp cenv m eenv.tyenv tcref tysC + let nR = min n goodTupleFields + let elast = mkGetTupleItemN g m nR tyR tupInfo e tysC[nR] if n < goodTupleFields then elast @@ -3682,18 +3682,18 @@ and GenNewArray cenv cgbuf eenv (elems: Expr list, elemTy, m) sequel = else GenNewArraySimple cenv cgbuf eenv (elems, elemTy, m) sequel -and GenCoerce cenv cgbuf eenv (e, tgty, m, srcty) sequel = +and GenCoerce cenv cgbuf eenv (e, tgtTy, m, srcTy) sequel = let g = cenv.g // Is this an upcast? if - TypeDefinitelySubsumesTypeNoCoercion 0 g cenv.amap m tgty srcty + TypeDefinitelySubsumesTypeNoCoercion 0 g cenv.amap m tgtTy srcTy && // Do an extra check - should not be needed - TypeFeasiblySubsumesType 0 g cenv.amap m tgty NoCoerce srcty + TypeFeasiblySubsumesType 0 g cenv.amap m tgtTy NoCoerce srcTy then - if isInterfaceTy g tgty then + if isInterfaceTy g tgtTy then GenExpr cenv cgbuf eenv e Continue - let ilToTy = GenType cenv m eenv.tyenv tgty + let ilToTy = GenType cenv m eenv.tyenv tgtTy // Section "III.1.8.1.3 Merging stack states" of ECMA-335 implies that no unboxing // is required, but we still push the coerced type on to the code gen buffer. CG.EmitInstrs cgbuf (pop 1) (Push [ ilToTy ]) [] @@ -3703,18 +3703,18 @@ and GenCoerce cenv cgbuf eenv (e, tgty, m, srcty) sequel = else GenExpr cenv cgbuf eenv e Continue - if not (isObjTy g srcty) then - let ilFromTy = GenType cenv m eenv.tyenv srcty + if not (isObjTy g srcTy) then + let ilFromTy = GenType cenv m eenv.tyenv srcTy CG.EmitInstr cgbuf (pop 1) (Push [ g.ilg.typ_Object ]) (I_box ilFromTy) - if not (isObjTy g tgty) then - let ilToTy = GenType cenv m eenv.tyenv tgty + if not (isObjTy g tgtTy) then + let ilToTy = GenType cenv m eenv.tyenv tgtTy CG.EmitInstr cgbuf (pop 1) (Push [ ilToTy ]) (I_unbox_any ilToTy) GenSequel cenv eenv.cloc cgbuf sequel -and GenReraise cenv cgbuf eenv (rtnty, m) sequel = - let ilReturnTy = GenType cenv m eenv.tyenv rtnty +and GenReraise cenv cgbuf eenv (retTy, m) sequel = + let ilReturnTy = GenType cenv m eenv.tyenv retTy CG.EmitInstr cgbuf (pop 0) Push0 I_rethrow // [See comment related to I_throw]. // Rethrow does not return. Required to push dummy value on the stack. @@ -4538,14 +4538,14 @@ and GenNamedLocalTyFuncCall cenv (cgbuf: CodeGenBuffer) eenv ty cloinfo tyargs m actualRetTy /// Generate an indirect call, converting to an ILX callfunc instruction -and GenCurriedArgsAndIndirectCall cenv cgbuf eenv (functy, tyargs, curriedArgs, m) sequel = +and GenCurriedArgsAndIndirectCall cenv cgbuf eenv (funcTy, tyargs, curriedArgs, m) sequel = // Generate the curried arguments to the indirect call GenExprs cenv cgbuf eenv curriedArgs - GenIndirectCall cenv cgbuf eenv (functy, tyargs, curriedArgs, m) sequel + GenIndirectCall cenv cgbuf eenv (funcTy, tyargs, curriedArgs, m) sequel /// Generate an indirect call, converting to an ILX callfunc instruction -and GenIndirectCall cenv cgbuf eenv (functy, tyargs, curriedArgs, m) sequel = +and GenIndirectCall cenv cgbuf eenv (funcTy, tyargs, curriedArgs, m) sequel = let g = cenv.g // Fold in the new types into the environment as we generate the formal types. @@ -4553,7 +4553,7 @@ and GenIndirectCall cenv cgbuf eenv (functy, tyargs, curriedArgs, m) sequel = // keep only non-erased type arguments when computing indirect call let tyargs = DropErasedTyargs tyargs - let typars, formalFuncTy = tryDestForallTy g functy + let typars, formalFuncTy = tryDestForallTy g funcTy let feenv = eenv.tyenv.Add typars @@ -4568,7 +4568,7 @@ and GenIndirectCall cenv cgbuf eenv (functy, tyargs, curriedArgs, m) sequel = List.foldBack (fun tyarg acc -> Apps_tyapp(GenType cenv m eenv.tyenv tyarg, acc)) tyargs (appBuilder ilxRetApps) - let actualRetTy = applyTys g functy (tyargs, curriedArgs) + let actualRetTy = applyTys g funcTy (tyargs, curriedArgs) let ilActualRetTy = GenType cenv m eenv.tyenv actualRetTy // Check if any byrefs are involved to make sure we don't tailcall @@ -4710,14 +4710,14 @@ and eligibleForFilter (cenv: cenv) expr = && not isTrivial && check expr -and GenTryWith cenv cgbuf eenv (e1, valForFilter: Val, filterExpr, valForHandler: Val, handlerExpr, m, resty, spTry, spWith) sequel = +and GenTryWith cenv cgbuf eenv (e1, valForFilter: Val, filterExpr, valForHandler: Val, handlerExpr, m, resTy, spTry, spWith) sequel = let g = cenv.g // Save the stack - gross because IL flushes the stack at the exn. handler // note: eenvinner notes spill vars are live LocalScope "trystack" cgbuf (fun scopeMarks -> let whereToSaveOpt, eenvinner, stack, tryMarks, afterHandler = - GenTry cenv cgbuf eenv scopeMarks (e1, m, resty, spTry) + GenTry cenv cgbuf eenv scopeMarks (e1, m, resTy, spTry) let seh = if cenv.options.generateFilterBlocks || eligibleForFilter cenv filterExpr then @@ -4824,13 +4824,13 @@ and GenTryWith cenv cgbuf eenv (e1, valForFilter: Val, filterExpr, valForHandler GenSequel cenv eenv.cloc cgbuf sequel | None -> GenUnitThenSequel cenv eenv m eenv.cloc cgbuf sequel) -and GenTryFinally cenv cgbuf eenv (bodyExpr, handlerExpr, m, resty, spTry, spFinally) sequel = +and GenTryFinally cenv cgbuf eenv (bodyExpr, handlerExpr, m, resTy, spTry, spFinally) sequel = // Save the stack - needed because IL flushes the stack at the exn. handler // note: eenvinner notes spill vars are live LocalScope "trystack" cgbuf (fun scopeMarks -> let whereToSaveOpt, eenvinner, stack, tryMarks, afterHandler = - GenTry cenv cgbuf eenv scopeMarks (bodyExpr, m, resty, spTry) + GenTry cenv cgbuf eenv scopeMarks (bodyExpr, m, resTy, spTry) // Now the catch/finally block let startOfHandler = CG.GenerateMark cgbuf "startOfHandler" @@ -7520,8 +7520,8 @@ and GenDecisionTreeSwitch CG.EmitInstr cgbuf (pop 1) (Push [ g.ilg.typ_Object ]) (I_box ilFromTy) BI_brfalse - | DecisionTreeTest.IsInst (_srcty, tgty) -> - let e = mkCallTypeTest g m tgty e + | DecisionTreeTest.IsInst (_srcTy, tgtTy) -> + let e = mkCallTypeTest g m tgtTy e GenExpr cenv cgbuf eenv e Continue BI_brtrue | _ -> failwith "internal error: GenDecisionTreeSwitch" @@ -9472,7 +9472,7 @@ and AllocLocal cenv cgbuf eenv compgen (v, ty, isFixed) (scopeMarks: Mark * Mark let j, realloc = if cenv.options.localOptimizationsEnabled then cgbuf.ReallocLocal( - (fun i (_, ty', isFixed') -> not isFixed' && not isFixed && not (IntMap.mem i eenv.liveLocals) && (ty = ty')), + (fun i (_, ty2, isFixed2) -> not isFixed2 && not isFixed && not (IntMap.mem i eenv.liveLocals) && (ty = ty2)), ranges, ty, isFixed @@ -10470,7 +10470,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = for slotsig in memberInfo.ImplementedSlotSigs do - if isInterfaceTy g slotsig.ImplementedType then + if isInterfaceTy g slotsig.DeclaringType then match vref.ValReprInfo with | Some _ -> diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index f3537b7bbc0..056f2f19a78 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -900,7 +900,8 @@ let OutputPhasedErrorR (os: StringBuilder) (diagnostic: PhasedDiagnostic) (canSu | ParameterlessStructCtor _ -> os.AppendString(ParameterlessStructCtorE().Format) - | InterfaceNotRevealed (denv, ity, _) -> os.AppendString(InterfaceNotRevealedE().Format(NicePrint.minimalStringOfType denv ity)) + | InterfaceNotRevealed (denv, intfTy, _) -> + os.AppendString(InterfaceNotRevealedE().Format(NicePrint.minimalStringOfType denv intfTy)) | NotAFunctionButIndexer (_, _, name, _, _, old) -> if old then @@ -1506,7 +1507,7 @@ let OutputPhasedErrorR (os: StringBuilder) (diagnostic: PhasedDiagnostic) (canSu |> List.exists (function | TType_app (maybeUnit, [], _) -> match maybeUnit.TypeAbbrev with - | Some ttype when isUnitTy g ttype -> true + | Some ty when isUnitTy g ty -> true | _ -> false | _ -> false) @@ -1694,7 +1695,7 @@ let OutputPhasedErrorR (os: StringBuilder) (diagnostic: PhasedDiagnostic) (canSu | PatternMatchCompilation.RuleNeverMatched _ -> os.AppendString(RuleNeverMatchedE().Format) - | ValNotMutable (_, valRef, _) -> os.AppendString(ValNotMutableE().Format(valRef.DisplayName)) + | ValNotMutable (_, vref, _) -> os.AppendString(ValNotMutableE().Format(vref.DisplayName)) | ValNotLocal _ -> os.AppendString(ValNotLocalE().Format) diff --git a/src/Compiler/Facilities/TextLayoutRender.fs b/src/Compiler/Facilities/TextLayoutRender.fs index 1b77bd9e6ae..e9b7cd8637a 100644 --- a/src/Compiler/Facilities/TextLayoutRender.fs +++ b/src/Compiler/Facilities/TextLayoutRender.fs @@ -204,5 +204,5 @@ module LayoutRender = let toArray layout = let output = ResizeArray() - renderL (taggedTextListR (fun tt -> output.Add(tt))) layout |> ignore + renderL (taggedTextListR output.Add) layout |> ignore output.ToArray() diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 936343a7036..5d8966fd9a1 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -1814,9 +1814,9 @@ type internal FsiDynamicCompiler( ilTy |> Morphs.morphILTypeRefsInILType emEnv.ReverseMapTypeRef | _ -> ilTy) - ((istate, []), ilTys) ||> List.fold (fun (state, addedTypes) ilTy -> - let nextState, addedType = addTypeToEnvironment state ilTy - nextState, addedTypes @ [addedType]) + ((istate, []), ilTys) ||> List.fold (fun (state, addedTys) ilTy -> + let nextState, addedTy = addTypeToEnvironment state ilTy + nextState, addedTys @ [addedTy]) member _.DynamicAssemblies = dynamicAssemblies.ToArray() diff --git a/src/Compiler/Optimize/Optimizer.fs b/src/Compiler/Optimize/Optimizer.fs index 90e79010ed6..f4462122337 100644 --- a/src/Compiler/Optimize/Optimizer.fs +++ b/src/Compiler/Optimize/Optimizer.fs @@ -606,9 +606,9 @@ let inline BindInternalValsToUnknown cenv vs env = ignore vs env -let BindTypeVar tyv typeinfo env = { env with typarInfos= (tyv, typeinfo) :: env.typarInfos } +let BindTypar tyv typeinfo env = { env with typarInfos= (tyv, typeinfo) :: env.typarInfos } -let BindTypeVarsToUnknown (tps: Typar list) env = +let BindTyparsToUnknown (tps: Typar list) env = if isNil tps then env else // The optimizer doesn't use the type values it could track. // However here we mutate to provide better names for generalized type parameters @@ -617,7 +617,7 @@ let BindTypeVarsToUnknown (tps: Typar list) env = (tps, nms) ||> List.iter2 (fun tp nm -> if PrettyTypes.NeedsPrettyTyparName tp then tp.typar_id <- ident (nm, tp.Range)) - List.fold (fun sofar arg -> BindTypeVar arg UnknownTypeValue sofar) env tps + List.fold (fun sofar arg -> BindTypar arg UnknownTypeValue sofar) env tps let BindCcu (ccu: CcuThunk) mval env (_g: TcGlobals) = { env with globalModuleInfos=env.globalModuleInfos.Add(ccu.AssemblyName, mval) } @@ -2245,8 +2245,8 @@ let TryDetectQueryQuoteAndRun cenv (expr: Expr) = match reqdResultInfo, exprIsEnumerableInfo with | Some _, Some _ | None, None -> resultExpr // the expression is a QuerySource, the result is a QuerySource, nothing to do | Some resultElemTy, None -> - let iety = TType_app(g.tcref_System_Collections_IEnumerable, [], g.knownWithoutNull) - mkCallGetQuerySourceAsEnumerable g expr.Range resultElemTy iety resultExpr + let enumerableTy = TType_app(g.tcref_System_Collections_IEnumerable, [], g.knownWithoutNull) + mkCallGetQuerySourceAsEnumerable g expr.Range resultElemTy enumerableTy resultExpr | None, Some (resultElemTy, qTy) -> mkCallNewQuerySource g expr.Range resultElemTy qTy resultExpr Some resultExprAfterConvertToResultTy @@ -2425,7 +2425,7 @@ and OptimizeMethods cenv env baseValOpt methods = and OptimizeMethod cenv env baseValOpt (TObjExprMethod(slotsig, attribs, tps, vs, e, m) as tmethod) = let env = {env with latestBoundId=Some tmethod.Id; functionVal = None} - let env = BindTypeVarsToUnknown tps env + let env = BindTyparsToUnknown tps env let env = BindInternalValsToUnknown cenv vs env let env = Option.foldBack (BindInternalValToUnknown cenv) baseValOpt env let eR, einfo = OptimizeExpr cenv env e @@ -2508,11 +2508,11 @@ and OptimizeExprOp cenv env (op, tyargs, args, m) = // Special cases match op, tyargs, args with - | TOp.Coerce, [toty;fromty], [arg] -> + | TOp.Coerce, [tgtTy; srcTy], [arg] -> let argR, einfo = OptimizeExpr cenv env arg - if typeEquiv g toty fromty then argR, einfo + if typeEquiv g tgtTy srcTy then argR, einfo else - mkCoerceExpr(argR, toty, m, fromty), + mkCoerceExpr(argR, tgtTy, m, srcTy), { TotalSize=einfo.TotalSize + 1 FunctionSize=einfo.FunctionSize + 1 HasEffect = true @@ -3742,7 +3742,7 @@ and OptimizeLambdas (vspec: Val option) cenv env valReprInfo expr exprTy = let env = { env with functionVal = (match vspec with None -> None | Some v -> Some (v, valReprInfo)) } let env = Option.foldBack (BindInternalValToUnknown cenv) ctorThisValOpt env let env = Option.foldBack (BindInternalValToUnknown cenv) baseValOpt env - let env = BindTypeVarsToUnknown tps env + let env = BindTyparsToUnknown tps env let env = List.foldBack (BindInternalValsToUnknown cenv) vsl env let bodyR, bodyinfo = OptimizeExpr cenv env body let exprR = mkMemberLambdas g m tps ctorThisValOpt baseValOpt vsl (bodyR, bodyTy) @@ -3977,7 +3977,7 @@ and TryOptimizeDecisionTreeTest cenv test vinfo = | DecisionTreeTest.ArrayLength _, _ -> None | DecisionTreeTest.Const c1, StripConstValue c2 -> if c1 = Const.Zero || c2 = Const.Zero then None else Some(c1=c2) | DecisionTreeTest.IsNull, StripConstValue c2 -> Some(c2=Const.Zero) - | DecisionTreeTest.IsInst (_srcty1, _tgty1), _ -> None + | DecisionTreeTest.IsInst (_srcTy1, _tgtTy1), _ -> None // These should not occur in optimization | DecisionTreeTest.ActivePatternCase _, _ -> None | _ -> None @@ -3989,8 +3989,8 @@ and OptimizeSwitch cenv env (e, cases, dflt, m) = // Replace IsInst tests by calls to the helper for type tests, which may then get optimized let e, cases = match cases with - | [ TCase(DecisionTreeTest.IsInst (_srcTy, tgTy), success)] -> - let testExpr = mkCallTypeTest g m tgTy e + | [ TCase(DecisionTreeTest.IsInst (_srcTy, tgtTy), success)] -> + let testExpr = mkCallTypeTest g m tgtTy e let testCases = [TCase(DecisionTreeTest.Const(Const.Bool true), success)] testExpr, testCases | _ -> e, cases diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index c7f4e0ce0f0..48649d1835a 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -351,13 +351,13 @@ type internal TypeCheckInfo // Find the most deeply nested enclosing scope that contains given position sResolutions.CapturedEnvs - |> ResizeArray.iter (fun (possm, env, ad) -> - if rangeContainsPos possm cursorPos then + |> ResizeArray.iter (fun (mPossible, env, ad) -> + if rangeContainsPos mPossible cursorPos then match bestSoFar with | Some (bestm, _, _) -> - if rangeContainsRange bestm possm then - bestSoFar <- Some(possm, env, ad) - | None -> bestSoFar <- Some(possm, env, ad)) + if rangeContainsRange bestm mPossible then + bestSoFar <- Some(mPossible, env, ad) + | None -> bestSoFar <- Some(mPossible, env, ad)) let mostDeeplyNestedEnclosingScope = bestSoFar @@ -370,23 +370,23 @@ type internal TypeCheckInfo let mutable bestAlmostIncludedSoFar = None sResolutions.CapturedEnvs - |> ResizeArray.iter (fun (possm, env, ad) -> + |> ResizeArray.iter (fun (mPossible, env, ad) -> // take only ranges that strictly do not include cursorPos (all ranges that touch cursorPos were processed during 'Strict Inclusion' part) - if rangeBeforePos possm cursorPos && not (posEq possm.End cursorPos) then + if rangeBeforePos mPossible cursorPos && not (posEq mPossible.End cursorPos) then let contained = match mostDeeplyNestedEnclosingScope with - | Some (bestm, _, _) -> rangeContainsRange bestm possm + | Some (bestm, _, _) -> rangeContainsRange bestm mPossible | None -> true if contained then match bestAlmostIncludedSoFar with - | Some (rightm: range, _, _) -> + | Some (mRight: range, _, _) -> if - posGt possm.End rightm.End - || (posEq possm.End rightm.End && posGt possm.Start rightm.Start) + posGt mPossible.End mRight.End + || (posEq mPossible.End mRight.End && posGt mPossible.Start mRight.Start) then - bestAlmostIncludedSoFar <- Some(possm, env, ad) - | _ -> bestAlmostIncludedSoFar <- Some(possm, env, ad)) + bestAlmostIncludedSoFar <- Some(mPossible, env, ad) + | _ -> bestAlmostIncludedSoFar <- Some(mPossible, env, ad)) let resEnv = match bestAlmostIncludedSoFar, mostDeeplyNestedEnclosingScope with diff --git a/src/Compiler/Service/ItemKey.fs b/src/Compiler/Service/ItemKey.fs index 261d6ec094f..d2621715b10 100644 --- a/src/Compiler/Service/ItemKey.fs +++ b/src/Compiler/Service/ItemKey.fs @@ -241,10 +241,10 @@ and [] ItemKeyStoreBuilder() = writeString anonInfo.ILTypeRef.BasicQualifiedName tinst |> List.iter (writeType false) - | TType_fun (d, r, _) -> + | TType_fun (domainTy, rangeTy, _) -> writeString ItemKeyTags.typeFunction - writeType false d - writeType false r + writeType false domainTy + writeType false rangeTy | TType_measure ms -> if isStandalone then @@ -265,7 +265,7 @@ and [] ItemKeyStoreBuilder() = | Measure.Var typar -> writeString ItemKeyTags.typeMeasureVar writeTypar isStandalone typar - | Measure.Con tcref -> + | Measure.Const tcref -> writeString ItemKeyTags.typeMeasureCon writeEntityRef tcref | _ -> () diff --git a/src/Compiler/Service/SemanticClassification.fs b/src/Compiler/Service/SemanticClassification.fs index bdbc73d783a..fc4f9d21b75 100644 --- a/src/Compiler/Service/SemanticClassification.fs +++ b/src/Compiler/Service/SemanticClassification.fs @@ -152,8 +152,8 @@ module TcResolutionsExtensions = protectAssemblyExplorationNoReraise false false (fun () -> ExistsHeadTypeInEntireHierarchy g amap range0 vref.Type g.tcref_System_IDisposable) - let isStructTyconRef (tyconRef: TyconRef) = - let ty = generalizedTyconRef g tyconRef + let isStructTyconRef (tcref: TyconRef) = + let ty = generalizedTyconRef g tcref let underlyingTy = stripTyEqnsAndMeasureEqns g ty isStructTy g underlyingTy diff --git a/src/Compiler/Service/ServiceDeclarationLists.fs b/src/Compiler/Service/ServiceDeclarationLists.fs index 82fc0afae36..30d024d646a 100644 --- a/src/Compiler/Service/ServiceDeclarationLists.fs +++ b/src/Compiler/Service/ServiceDeclarationLists.fs @@ -197,15 +197,15 @@ module DeclarationListHelpers = | Item.ActivePatternCase apref -> let v = apref.ActivePatternVal // Format the type parameters to get e.g. ('a -> 'a) rather than ('?1234 -> '?1234) - let tau = v.TauType + let vTauTy = v.TauType // REVIEW: use _cxs here - let (prettyTyparInst, ptau), _cxs = PrettyTypes.PrettifyInstAndType denv.g (item.TyparInstantiation, tau) + let (prettyTyparInst, prettyTy), _cxs = PrettyTypes.PrettifyInstAndType denv.g (item.TyparInstantiation, vTauTy) let remarks = OutputFullName displayFullName pubpathOfValRef fullDisplayTextOfValRefAsLayout v let layout = wordL (tagText (FSComp.SR.typeInfoActiveRecognizer())) ^^ wordL (tagActivePatternCase apref.Name |> mkNav v.DefinitionRange) ^^ RightL.colon ^^ - NicePrint.layoutType denv ptau + NicePrint.layoutType denv prettyTy let tpsL = FormatTyparMapping denv prettyTyparInst @@ -292,7 +292,7 @@ module DeclarationListHelpers = // .NET events | Item.Event einfo -> - let eventTy = PropTypOfEventInfo infoReader m AccessibleFromSomewhere einfo + let eventTy = PropTypeOfEventInfo infoReader m AccessibleFromSomewhere einfo let eventTy, _cxs = PrettyTypes.PrettifyType g eventTy let layout = wordL (tagText (FSComp.SR.typeInfoEvent())) ^^ @@ -353,11 +353,11 @@ module DeclarationListHelpers = ToolTipElement.Single(layout, xml) // The 'fake' representation of constructors of .NET delegate types - | Item.DelegateCtor delty -> - let delty, _cxs = PrettyTypes.PrettifyType g delty - let (SigOfFunctionForDelegate(_, _, _, delFuncTy)) = GetSigOfFunctionForDelegate infoReader delty m AccessibleFromSomewhere + | Item.DelegateCtor delTy -> + let delTy, _cxs = PrettyTypes.PrettifyType g delTy + let (SigOfFunctionForDelegate(_, _, _, delFuncTy)) = GetSigOfFunctionForDelegate infoReader delTy m AccessibleFromSomewhere let layout = - NicePrint.layoutTyconRef denv (tcrefOfAppTy g delty) ^^ + NicePrint.layoutTyconRef denv (tcrefOfAppTy g delTy) ^^ LeftL.leftParen ^^ NicePrint.layoutType denv delFuncTy ^^ RightL.rightParen @@ -484,16 +484,16 @@ type MethodGroupItemParameter(name: string, canonicalTypeTextForSorting: string, module internal DescriptionListsImpl = let isFunction g ty = - let _, tau = tryDestForallTy g ty - isFunTy g tau + let _, tauTy = tryDestForallTy g ty + isFunTy g tauTy - let printCanonicalizedTypeName g (denv:DisplayEnv) tau = + let printCanonicalizedTypeName g (denv:DisplayEnv) tauTy = // get rid of F# abbreviations and such - let strippedType = stripTyEqnsWrtErasure EraseAll g tau + let strippedTy = stripTyEqnsWrtErasure EraseAll g tauTy // pretend no namespaces are open let denv = denv.SetOpenPaths([]) // now printing will see a .NET-like canonical representation, that is good for sorting overloads into a reasonable order (see bug 94520) - NicePrint.stringOfTy denv strippedType + NicePrint.stringOfTy denv strippedTy let PrettyParamOfRecdField g denv (f: RecdField) = let display = NicePrint.prettyLayoutOfType denv f.FormalType @@ -566,12 +566,12 @@ module internal DescriptionListsImpl = // Remake the params using the prettified versions let prettyParams = - (paramInfo, prettyParamTys, prettyParamTysL) |||> List.map3 (fun (nm, isOptArg, paramPrefix) tau tyL -> + (paramInfo, prettyParamTys, prettyParamTysL) |||> List.map3 (fun (nm, isOptArg, paramPrefix) tauTy tyL -> let display = paramPrefix ^^ tyL let display = toArray display MethodGroupItemParameter( name = nm, - canonicalTypeTextForSorting = printCanonicalizedTypeName g denv tau, + canonicalTypeTextForSorting = printCanonicalizedTypeName g denv tauTy, display = display, isOptional=isOptArg )) @@ -587,11 +587,11 @@ module internal DescriptionListsImpl = // Remake the params using the prettified versions let parameters = (prettyParamTys, prettyParamTysL) - ||> List.map2 (fun tau tyL -> + ||> List.map2 (fun paramTy tyL -> let display = toArray tyL MethodGroupItemParameter( name = "", - canonicalTypeTextForSorting = printCanonicalizedTypeName g denv tau, + canonicalTypeTextForSorting = printCanonicalizedTypeName g denv paramTy, display = display, isOptional=false )) @@ -635,17 +635,18 @@ module internal DescriptionListsImpl = let denv = { SimplerDisplayEnv denv with useColonForReturnType=true} match item.Item with | Item.Value vref -> + let getPrettyParamsOfTypes() = - let tau = vref.TauType - match tryDestFunTy denv.g tau with - | ValueSome(arg, rtau) -> + let vTauTy = vref.TauType + match tryDestFunTy denv.g vTauTy with + | ValueSome(arg, retTy) -> let args = tryDestRefTupleTy denv.g arg - let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfTypes g denv item.TyparInstantiation args rtau + let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfTypes g denv item.TyparInstantiation args retTy // FUTURE: prettyTyparInst is the pretty version of the known instantiations of type parameters in the output. It could be returned // for display as part of the method group prettyParams, prettyRetTyL | _ -> - let _prettyTyparInst, prettyTyL = NicePrint.prettyLayoutOfUncurriedSig denv item.TyparInstantiation [] tau + let _prettyTyparInst, prettyTyL = NicePrint.prettyLayoutOfUncurriedSig denv item.TyparInstantiation [] vTauTy [], prettyTyL match vref.ValReprInfo with @@ -675,7 +676,7 @@ module internal DescriptionListsImpl = // Adjust the return type so it only strips the first argument let curriedRetTy = match tryDestFunTy denv.g vref.TauType with - | ValueSome(_, rtau) -> rtau + | ValueSome(_, retTy) -> retTy | _ -> lastRetTy let _prettyTyparInst, prettyFirstCurriedParams, prettyCurriedRetTyL, prettyConstraintsL = PrettyParamsOfParamDatas g denv item.TyparInstantiation firstCurriedParamDatas curriedRetTy @@ -695,8 +696,8 @@ module internal DescriptionListsImpl = | Item.ActivePatternCase(apref) -> let v = apref.ActivePatternVal - let tau = v.TauType - let args, resTy = stripFunTy denv.g tau + let vTauTy = v.TauType + let args, resTy = stripFunTy denv.g vTauTy let apinfo = Option.get (TryGetActivePatternInfo v) let aparity = apinfo.Names.Length @@ -726,7 +727,7 @@ module internal DescriptionListsImpl = [], prettyRetTyL | Item.Event einfo -> - let _prettyTyparInst, prettyRetTyL = NicePrint.prettyLayoutOfUncurriedSig denv item.TyparInstantiation [] (PropTypOfEventInfo infoReader m AccessibleFromSomewhere einfo) + let _prettyTyparInst, prettyRetTyL = NicePrint.prettyLayoutOfUncurriedSig denv item.TyparInstantiation [] (PropTypeOfEventInfo infoReader m AccessibleFromSomewhere einfo) [], prettyRetTyL | Item.Property(_, pinfo :: _) -> @@ -775,11 +776,11 @@ module internal DescriptionListsImpl = let _prettyTyparInst, prettyRetTyL = NicePrint.prettyLayoutOfUncurriedSig denv item.TyparInstantiation [] ty [], prettyRetTyL - | Item.DelegateCtor delty -> - let (SigOfFunctionForDelegate(_, _, _, delFuncTy)) = GetSigOfFunctionForDelegate infoReader delty m AccessibleFromSomewhere + | Item.DelegateCtor delTy -> + let (SigOfFunctionForDelegate(_, _, _, delFuncTy)) = GetSigOfFunctionForDelegate infoReader delTy m AccessibleFromSomewhere // No need to pass more generic type information in here since the instanitations have already been applied - let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfParamDatas g denv item.TyparInstantiation [ParamData(false, false, false, NotOptional, NoCallerInfo, None, ReflectedArgInfo.None, delFuncTy)] delty + let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfParamDatas g denv item.TyparInstantiation [ParamData(false, false, false, NotOptional, NoCallerInfo, None, ReflectedArgInfo.None, delFuncTy)] delTy // FUTURE: prettyTyparInst is the pretty version of the known instantiations of type parameters in the output. It could be returned // for display as part of the method group diff --git a/src/Compiler/Service/ServiceNavigation.fs b/src/Compiler/Service/ServiceNavigation.fs index 68b7eb268f9..0751225c890 100755 --- a/src/Compiler/Service/ServiceNavigation.fs +++ b/src/Compiler/Service/ServiceNavigation.fs @@ -121,8 +121,8 @@ module NavigationImpl = |> List.fold (fun st (SynField (_, _, _, _, _, _, _, m)) -> unionRangesChecked m st) range.Zero | SynUnionCaseKind.FullType (ty, _) -> ty.Range - let bodyRange mb decls = - unionRangesChecked (rangeOfDecls decls) mb + let bodyRange mBody decls = + unionRangesChecked (rangeOfDecls decls) mBody /// Get information for implementation file let getNavigationFromImplFile (modules: SynModuleOrNamespace list) = @@ -143,18 +143,18 @@ module NavigationImpl = sprintf "%s_%d_of_%d" name idx total // Create declaration (for the left dropdown) - let createDeclLid (baseName, lid, kind, baseGlyph, m, bodym, nested, enclosingEntityKind, access) = + let createDeclLid (baseName, lid, kind, baseGlyph, m, mBody, nested, enclosingEntityKind, access) = let name = (if baseName <> "" then baseName + "." else "") + textOfLid lid - let item = NavigationItem.Create(name, kind, baseGlyph, m, bodym, false, enclosingEntityKind, false, access) + let item = NavigationItem.Create(name, kind, baseGlyph, m, mBody, false, enclosingEntityKind, false, access) item, addItemName name, nested - let createDecl (baseName, id: Ident, kind, baseGlyph, m, bodym, nested, enclosingEntityKind, isAbstract, access) = + let createDecl (baseName, id: Ident, kind, baseGlyph, m, mBody, nested, enclosingEntityKind, isAbstract, access) = let name = (if baseName <> "" then baseName + "." else "") + id.idText - let item = NavigationItem.Create(name, kind, baseGlyph, m, bodym, false, enclosingEntityKind, isAbstract, access) + let item = NavigationItem.Create(name, kind, baseGlyph, m, mBody, false, enclosingEntityKind, isAbstract, access) item, addItemName name, nested - let createTypeDecl (baseName, lid, baseGlyph, m, bodym, nested, enclosingEntityKind, access) = - createDeclLid (baseName, lid, NavigationItemKind.Type, baseGlyph, m, bodym, nested, enclosingEntityKind, access) + let createTypeDecl (baseName, lid, baseGlyph, m, mBody, nested, enclosingEntityKind, access) = + createDeclLid (baseName, lid, NavigationItemKind.Type, baseGlyph, m, mBody, nested, enclosingEntityKind, access) // Create member-kind-of-thing for the right dropdown let createMemberLid (lid, kind, baseGlyph, m, enclosingEntityKind, isAbstract, access) = @@ -226,10 +226,10 @@ module NavigationImpl = let rec processExnDefnRepr baseName nested synExnRepr = let (SynExceptionDefnRepr (_, ucase, _, _, access, m)) = synExnRepr let (SynUnionCase (ident = SynIdent (id, _); caseType = fldspec)) = ucase - let bodym = fldspecRange fldspec + let mBody = fldspecRange fldspec [ - createDecl (baseName, id, NavigationItemKind.Exception, FSharpGlyph.Exception, m, bodym, nested, NavigationEntityKind.Exception, false, access) + createDecl (baseName, id, NavigationItemKind.Exception, FSharpGlyph.Exception, m, mBody, nested, NavigationEntityKind.Exception, false, access) ] // Process a class declaration or F# type declaration @@ -247,35 +247,35 @@ module NavigationImpl = match repr with | SynTypeDefnRepr.Exception repr -> processExnDefnRepr baseName [] repr - | SynTypeDefnRepr.ObjectModel (_, membDefns, mb) -> + | SynTypeDefnRepr.ObjectModel (_, membDefns, mBody) -> // F# class declaration let members = processMembers membDefns NavigationEntityKind.Class |> snd let nested = members @ topMembers - let bodym = bodyRange mb nested + let mBody = bodyRange mBody nested [ - createTypeDecl (baseName, lid, FSharpGlyph.Class, m, bodym, nested, NavigationEntityKind.Class, access) + createTypeDecl (baseName, lid, FSharpGlyph.Class, m, mBody, nested, NavigationEntityKind.Class, access) ] | SynTypeDefnRepr.Simple (simple, _) -> // F# type declaration match simple with - | SynTypeDefnSimpleRepr.Union (_, cases, mb) -> + | SynTypeDefnSimpleRepr.Union (_, cases, mBody) -> let cases = [ for SynUnionCase (ident = SynIdent (id, _); caseType = fldspec) in cases -> - let bodym = unionRanges (fldspecRange fldspec) id.idRange - createMember (id, NavigationItemKind.Other, FSharpGlyph.Struct, bodym, NavigationEntityKind.Union, false, access) + let mBody = unionRanges (fldspecRange fldspec) id.idRange + createMember (id, NavigationItemKind.Other, FSharpGlyph.Struct, mBody, NavigationEntityKind.Union, false, access) ] let nested = cases @ topMembers - let bodym = bodyRange mb nested + let mBody = bodyRange mBody nested [ - createTypeDecl (baseName, lid, FSharpGlyph.Union, m, bodym, nested, NavigationEntityKind.Union, access) + createTypeDecl (baseName, lid, FSharpGlyph.Union, m, mBody, nested, NavigationEntityKind.Union, access) ] - | SynTypeDefnSimpleRepr.Enum (cases, mb) -> + | SynTypeDefnSimpleRepr.Enum (cases, mBody) -> let cases = [ for SynEnumCase (ident = SynIdent (id, _); range = m) in cases -> @@ -283,13 +283,13 @@ module NavigationImpl = ] let nested = cases @ topMembers - let bodym = bodyRange mb nested + let mBody = bodyRange mBody nested [ - createTypeDecl (baseName, lid, FSharpGlyph.Enum, m, bodym, nested, NavigationEntityKind.Enum, access) + createTypeDecl (baseName, lid, FSharpGlyph.Enum, m, mBody, nested, NavigationEntityKind.Enum, access) ] - | SynTypeDefnSimpleRepr.Record (_, fields, mb) -> + | SynTypeDefnSimpleRepr.Record (_, fields, mBody) -> let fields = [ for SynField (_, _, id, _, _, _, _, m) in fields do @@ -299,17 +299,17 @@ module NavigationImpl = ] let nested = fields @ topMembers - let bodym = bodyRange mb nested + let mBody = bodyRange mBody nested [ - createTypeDecl (baseName, lid, FSharpGlyph.Type, m, bodym, nested, NavigationEntityKind.Record, access) + createTypeDecl (baseName, lid, FSharpGlyph.Type, m, mBody, nested, NavigationEntityKind.Record, access) ] - | SynTypeDefnSimpleRepr.TypeAbbrev (_, _, mb) -> - let bodym = bodyRange mb topMembers + | SynTypeDefnSimpleRepr.TypeAbbrev (_, _, mBody) -> + let mBody = bodyRange mBody topMembers [ - createTypeDecl (baseName, lid, FSharpGlyph.Typedef, m, bodym, topMembers, NavigationEntityKind.Class, access) + createTypeDecl (baseName, lid, FSharpGlyph.Typedef, m, mBody, topMembers, NavigationEntityKind.Class, access) ] //| SynTypeDefnSimpleRepr.General of TyconKind * (SynType * Range * ident option) list * (valSpfn * MemberFlags) list * fieldDecls * bool * bool * Range @@ -371,8 +371,8 @@ module NavigationImpl = for decl in decls do match decl with | SynModuleDecl.ModuleAbbrev (id, lid, m) -> - let bodym = rangeOfLid lid - createDecl (baseName, id, NavigationItemKind.Module, FSharpGlyph.Module, m, bodym, [], NavigationEntityKind.Namespace, false, None) + let mBody = rangeOfLid lid + createDecl (baseName, id, NavigationItemKind.Module, FSharpGlyph.Module, m, mBody, [], NavigationEntityKind.Namespace, false, None) | SynModuleDecl.NestedModule (moduleInfo = SynComponentInfo (longId = lid; accessibility = access); decls = decls; range = m) -> // Find let bindings (for the right dropdown) @@ -380,8 +380,8 @@ module NavigationImpl = let newBaseName = (if (baseName = "") then "" else baseName + ".") + (textOfLid lid) let other = processNavigationTopLevelDeclarations (newBaseName, decls) - let bodym = unionRangesChecked (rangeOfDecls nested) (moduleRange (rangeOfLid lid) other) - createDeclLid (baseName, lid, NavigationItemKind.Module, FSharpGlyph.Module, m, bodym, nested, NavigationEntityKind.Module, access) + let mBody = unionRangesChecked (rangeOfDecls nested) (moduleRange (rangeOfLid lid) other) + createDeclLid (baseName, lid, NavigationItemKind.Module, FSharpGlyph.Module, m, mBody, nested, NavigationEntityKind.Module, access) // Get nested modules and types (for the left dropdown) yield! other @@ -414,11 +414,11 @@ module NavigationImpl = else NavigationItemKind.Namespace - let bodym = unionRangesChecked (rangeOfDecls nested) (moduleRange (rangeOfLid id) other) + let mBody = unionRangesChecked (rangeOfDecls nested) (moduleRange (rangeOfLid id) other) let nm = textOfLid id let item = - NavigationItem.Create(nm, kind, FSharpGlyph.Module, m, bodym, singleTopLevel, NavigationEntityKind.Module, false, access) + NavigationItem.Create(nm, kind, FSharpGlyph.Module, m, mBody, singleTopLevel, NavigationEntityKind.Module, false, access) let decl = (item, addItemName (nm), nested) decl @@ -462,17 +462,17 @@ module NavigationImpl = sprintf "%s_%d_of_%d" name idx total // Create declaration (for the left dropdown) - let createDeclLid (baseName, lid, kind, baseGlyph, m, bodym, nested, enclosingEntityKind, access) = + let createDeclLid (baseName, lid, kind, baseGlyph, m, mBody, nested, enclosingEntityKind, access) = let name = (if baseName <> "" then baseName + "." else "") + (textOfLid lid) - let item = NavigationItem.Create(name, kind, baseGlyph, m, bodym, false, enclosingEntityKind, false, access) + let item = NavigationItem.Create(name, kind, baseGlyph, m, mBody, false, enclosingEntityKind, false, access) item, addItemName name, nested - let createTypeDecl (baseName, lid, baseGlyph, m, bodym, nested, enclosingEntityKind, access) = - createDeclLid (baseName, lid, NavigationItemKind.Type, baseGlyph, m, bodym, nested, enclosingEntityKind, access) + let createTypeDecl (baseName, lid, baseGlyph, m, mBody, nested, enclosingEntityKind, access) = + createDeclLid (baseName, lid, NavigationItemKind.Type, baseGlyph, m, mBody, nested, enclosingEntityKind, access) - let createDecl (baseName, id: Ident, kind, baseGlyph, m, bodym, nested, enclosingEntityKind, isAbstract, access) = + let createDecl (baseName, id: Ident, kind, baseGlyph, m, mBody, nested, enclosingEntityKind, isAbstract, access) = let name = (if baseName <> "" then baseName + "." else "") + id.idText - let item = NavigationItem.Create(name, kind, baseGlyph, m, bodym, false, enclosingEntityKind, isAbstract, access) + let item = NavigationItem.Create(name, kind, baseGlyph, m, mBody, false, enclosingEntityKind, isAbstract, access) item, addItemName name, nested let createMember (id: Ident, kind, baseGlyph, m, enclosingEntityKind, isAbstract, access) = @@ -481,10 +481,10 @@ module NavigationImpl = let rec processExnRepr baseName nested inp = let (SynExceptionDefnRepr (_, SynUnionCase (ident = SynIdent (id, _); caseType = fldspec), _, _, access, m)) = inp - let bodym = fldspecRange fldspec + let mBody = fldspecRange fldspec [ - createDecl (baseName, id, NavigationItemKind.Exception, FSharpGlyph.Exception, m, bodym, nested, NavigationEntityKind.Exception, false, access) + createDecl (baseName, id, NavigationItemKind.Exception, FSharpGlyph.Exception, m, mBody, nested, NavigationEntityKind.Exception, false, access) ] and processExnSig baseName inp = @@ -501,16 +501,16 @@ module NavigationImpl = [ match repr with | SynTypeDefnSigRepr.Exception repr -> yield! processExnRepr baseName [] repr - | SynTypeDefnSigRepr.ObjectModel (_, membDefns, mb) -> + | SynTypeDefnSigRepr.ObjectModel (_, membDefns, mBody) -> // F# class declaration let members = processSigMembers membDefns let nested = members @ topMembers - let bodym = bodyRange mb nested - createTypeDecl (baseName, lid, FSharpGlyph.Class, m, bodym, nested, NavigationEntityKind.Class, access) + let mBody = bodyRange mBody nested + createTypeDecl (baseName, lid, FSharpGlyph.Class, m, mBody, nested, NavigationEntityKind.Class, access) | SynTypeDefnSigRepr.Simple (simple, _) -> // F# type declaration match simple with - | SynTypeDefnSimpleRepr.Union (_, cases, mb) -> + | SynTypeDefnSimpleRepr.Union (_, cases, mBody) -> let cases = [ for SynUnionCase (ident = SynIdent (id, _); caseType = fldspec) in cases -> @@ -519,9 +519,9 @@ module NavigationImpl = ] let nested = cases @ topMembers - let bodym = bodyRange mb nested - createTypeDecl (baseName, lid, FSharpGlyph.Union, m, bodym, nested, NavigationEntityKind.Union, access) - | SynTypeDefnSimpleRepr.Enum (cases, mb) -> + let mBody = bodyRange mBody nested + createTypeDecl (baseName, lid, FSharpGlyph.Union, m, mBody, nested, NavigationEntityKind.Union, access) + | SynTypeDefnSimpleRepr.Enum (cases, mBody) -> let cases = [ for SynEnumCase (ident = SynIdent (id, _); range = m) in cases -> @@ -529,9 +529,9 @@ module NavigationImpl = ] let nested = cases @ topMembers - let bodym = bodyRange mb nested - createTypeDecl (baseName, lid, FSharpGlyph.Enum, m, bodym, nested, NavigationEntityKind.Enum, access) - | SynTypeDefnSimpleRepr.Record (_, fields, mb) -> + let mBody = bodyRange mBody nested + createTypeDecl (baseName, lid, FSharpGlyph.Enum, m, mBody, nested, NavigationEntityKind.Enum, access) + | SynTypeDefnSimpleRepr.Record (_, fields, mBody) -> let fields = [ for SynField (_, _, id, _, _, _, _, m) in fields do @@ -541,11 +541,11 @@ module NavigationImpl = ] let nested = fields @ topMembers - let bodym = bodyRange mb nested - createTypeDecl (baseName, lid, FSharpGlyph.Type, m, bodym, nested, NavigationEntityKind.Record, access) - | SynTypeDefnSimpleRepr.TypeAbbrev (_, _, mb) -> - let bodym = bodyRange mb topMembers - createTypeDecl (baseName, lid, FSharpGlyph.Typedef, m, bodym, topMembers, NavigationEntityKind.Class, access) + let mBody = bodyRange mBody nested + createTypeDecl (baseName, lid, FSharpGlyph.Type, m, mBody, nested, NavigationEntityKind.Record, access) + | SynTypeDefnSimpleRepr.TypeAbbrev (_, _, mBody) -> + let mBody = bodyRange mBody topMembers + createTypeDecl (baseName, lid, FSharpGlyph.Typedef, m, mBody, topMembers, NavigationEntityKind.Class, access) //| SynTypeDefnSimpleRepr.General of TyconKind * (SynType * range * ident option) list * (valSpfn * MemberFlags) list * fieldDecls * bool * bool * range //| SynTypeDefnSimpleRepr.LibraryOnlyILAssembly of ILType * range @@ -581,8 +581,8 @@ module NavigationImpl = for decl in decls do match decl with | SynModuleSigDecl.ModuleAbbrev (id, lid, m) -> - let bodym = rangeOfLid lid - createDecl (baseName, id, NavigationItemKind.Module, FSharpGlyph.Module, m, bodym, [], NavigationEntityKind.Module, false, None) + let mBody = rangeOfLid lid + createDecl (baseName, id, NavigationItemKind.Module, FSharpGlyph.Module, m, mBody, [], NavigationEntityKind.Module, false, None) | SynModuleSigDecl.NestedModule (moduleInfo = SynComponentInfo (longId = lid; accessibility = access); moduleDecls = decls; range = m) -> // Find let bindings (for the right dropdown) @@ -591,8 +591,8 @@ module NavigationImpl = let other = processNavigationTopLevelSigDeclarations (newBaseName, decls) // Get nested modules and types (for the left dropdown) - let bodym = unionRangesChecked (rangeOfDecls nested) (moduleRange (rangeOfLid lid) other) - createDeclLid (baseName, lid, NavigationItemKind.Module, FSharpGlyph.Module, m, bodym, nested, NavigationEntityKind.Module, access) + let mBody = unionRangesChecked (rangeOfDecls nested) (moduleRange (rangeOfLid lid) other) + createDeclLid (baseName, lid, NavigationItemKind.Module, FSharpGlyph.Module, m, mBody, nested, NavigationEntityKind.Module, access) yield! other | SynModuleSigDecl.Types (tydefs, _) -> @@ -623,10 +623,10 @@ module NavigationImpl = else NavigationItemKind.Namespace - let bodym = unionRangesChecked (rangeOfDecls nested) (moduleRange (rangeOfLid id) other) + let mBody = unionRangesChecked (rangeOfDecls nested) (moduleRange (rangeOfLid id) other) let item = - NavigationItem.Create(textOfLid id, kind, FSharpGlyph.Module, m, bodym, singleTopLevel, NavigationEntityKind.Module, false, access) + NavigationItem.Create(textOfLid id, kind, FSharpGlyph.Module, m, mBody, singleTopLevel, NavigationEntityKind.Module, false, access) let decl = (item, addItemName (textOfLid id), nested) decl diff --git a/src/Compiler/Service/ServiceParamInfoLocations.fs b/src/Compiler/Service/ServiceParamInfoLocations.fs index ff34dd392d4..b757120b628 100755 --- a/src/Compiler/Service/ServiceParamInfoLocations.fs +++ b/src/Compiler/Service/ServiceParamInfoLocations.fs @@ -73,8 +73,8 @@ module internal ParameterLocationsImpl = match synExpr with | SynExpr.Ident id -> Some([ id.idText ], id.idRange) | SynExpr.LongIdent (_, SynLongIdent ([ id ], [], [ Some _ ]), _, _) -> Some([ id.idText ], id.idRange) - | SynExpr.LongIdent (_, SynLongIdent (lid, _, _), _, lidRange) - | SynExpr.DotGet (_, _, SynLongIdent (lid, _, _), lidRange) -> Some(pathOfLid lid, lidRange) + | SynExpr.LongIdent (_, SynLongIdent (lid, _, _), _, mLongId) + | SynExpr.DotGet (_, _, SynLongIdent (lid, _, _), mLongId) -> Some(pathOfLid lid, mLongId) | SynExpr.TypeApp (synExpr, _, _synTypeList, _commas, _, _, _range) -> digOutIdentFromFuncExpr synExpr | SynExpr.Paren (expr = expr) -> digOutIdentFromFuncExpr expr | _ -> None @@ -213,14 +213,14 @@ module internal ParameterLocationsImpl = let (|StaticParameters|_|) pos (StripParenTypes synType) = match synType with | SynType.App (StripParenTypes (SynType.LongIdent (SynLongIdent (lid, _, _) as lidwd)), - Some (openm), + Some mLess, args, commas, - closemOpt, + mGreaterOpt, _pf, wholem) -> let lidm = lidwd.Range - let betweenTheBrackets = mkRange wholem.FileName openm.Start wholem.End + let betweenTheBrackets = mkRange wholem.FileName mLess.Start wholem.End if SyntaxTraversal.rangeContainsPosEdgesExclusive betweenTheBrackets pos @@ -232,10 +232,10 @@ module internal ParameterLocationsImpl = ParameterLocations( pathOfLid lid, lidm, - openm.Start, + mLess.Start, [], commasAndCloseParen, - closemOpt.IsSome, + mGreaterOpt.IsSome, args |> List.map digOutIdentFromStaticArg ) ) @@ -281,7 +281,7 @@ module internal ParameterLocationsImpl = // EXPR< = error recovery of a form of half-written TypeApp | SynExpr.App (_, _, - SynExpr.App (_, true, SynExpr.LongIdent(longDotId = SynLongIdent(id = [ op ])), synExpr, openm), + SynExpr.App (_, true, SynExpr.LongIdent(longDotId = SynLongIdent(id = [ op ])), synExpr, mLess), SynExpr.ArbitraryAfterError _, wholem) when op.idText = "op_LessThan" -> // Look in the function expression @@ -290,13 +290,13 @@ module internal ParameterLocationsImpl = match fResult with | Some _ -> fResult | _ -> - let typeArgsm = mkRange openm.FileName openm.Start wholem.End + let typeArgsm = mkRange mLess.FileName mLess.Start wholem.End if SyntaxTraversal.rangeContainsPosEdgesExclusive typeArgsm pos then // We found it, dig out ident match digOutIdentFromFuncExpr synExpr with - | Some (lid, lidRange) -> - Some(ParameterLocations(lid, lidRange, op.idRange.Start, [], [ wholem.End ], false, [])) + | Some (lid, mLongId) -> + Some(ParameterLocations(lid, mLongId, op.idRange.Start, [], [ wholem.End ], false, [])) | None -> None else None @@ -316,8 +316,8 @@ module internal ParameterLocationsImpl = | Found (parenLoc, argRanges, commasAndCloseParen, isThereACloseParen), _ -> // We found it, dig out ident match digOutIdentFromFuncExpr synExpr with - | Some (lid, lidRange) -> - assert (isInfix = (posLt parenLoc lidRange.End)) + | Some (lid, mLongId) -> + assert (isInfix = (posLt parenLoc mLongId.End)) if isInfix then // This seems to be an infix operator, since the start of the argument is a position earlier than the end of the long-id being applied to it. @@ -327,7 +327,7 @@ module internal ParameterLocationsImpl = Some( ParameterLocations( lid, - lidRange, + mLongId, parenLoc, argRanges, commasAndCloseParen |> List.map fst, @@ -340,11 +340,11 @@ module internal ParameterLocationsImpl = | _ -> traverseSynExpr synExpr2 // ID and error recovery of these - | SynExpr.TypeApp (synExpr, openm, tyArgs, commas, closemOpt, _, wholem) -> + | SynExpr.TypeApp (synExpr, mLess, tyArgs, commas, mGreaterOpt, _, wholem) -> match traverseSynExpr synExpr with | Some _ as r -> r | None -> - let typeArgsm = mkRange openm.FileName openm.Start wholem.End + let typeArgsm = mkRange mLess.FileName mLess.Start wholem.End if SyntaxTraversal.rangeContainsPosEdgesExclusive typeArgsm pos @@ -364,10 +364,10 @@ module internal ParameterLocationsImpl = ParameterLocations( [ "dummy" ], synExpr.Range, - openm.Start, + mLess.Start, argRanges, commasAndCloseParen, - closemOpt.IsSome, + mGreaterOpt.IsSome, tyArgs |> List.map digOutIdentFromStaticArg ) diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index 757cd90a264..a7ffb760e5a 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -476,8 +476,8 @@ module ParsedInput = ] |> pick expr - | SynExpr.DotGet (exprLeft, dotm, lidwd, _m) -> - let afterDotBeforeLid = mkRange dotm.FileName dotm.End lidwd.Range.Start + | SynExpr.DotGet (exprLeft, mDot, lidwd, _m) -> + let afterDotBeforeLid = mkRange mDot.FileName mDot.End lidwd.Range.Start [ dive exprLeft exprLeft.Range traverseSynExpr diff --git a/src/Compiler/Service/ServiceStructure.fs b/src/Compiler/Service/ServiceStructure.fs index 995e4e4d3e9..cbc625f709b 100644 --- a/src/Compiler/Service/ServiceStructure.fs +++ b/src/Compiler/Service/ServiceStructure.fs @@ -364,30 +364,30 @@ module Structure = members = ms extraImpls = extraImpls newExprRange = newRange - range = wholeRange) -> + range = mWhole) -> let bindings = unionBindingAndMembers bindings ms match argOpt with | Some (args, _) -> - let collapse = Range.endToEnd args.Range wholeRange - rcheck Scope.ObjExpr Collapse.Below wholeRange collapse + let collapse = Range.endToEnd args.Range mWhole + rcheck Scope.ObjExpr Collapse.Below mWhole collapse | None -> - let collapse = Range.endToEnd newRange wholeRange - rcheck Scope.ObjExpr Collapse.Below wholeRange collapse + let collapse = Range.endToEnd newRange mWhole + rcheck Scope.ObjExpr Collapse.Below mWhole collapse parseBindings bindings parseExprInterfaces extraImpls - | SynExpr.TryWith (e, matchClauses, wholeRange, tryPoint, withPoint, _trivia) -> + | SynExpr.TryWith (e, matchClauses, mWhole, tryPoint, withPoint, _trivia) -> match tryPoint, withPoint with | DebugPointAtTry.Yes tryRange, DebugPointAtWith.Yes withRange -> - let fullrange = Range.startToEnd tryRange wholeRange - let collapse = Range.endToEnd tryRange wholeRange + let mFull = Range.startToEnd tryRange mWhole + let collapse = Range.endToEnd tryRange mWhole let collapseTry = Range.endToStart tryRange withRange let fullrangeTry = Range.startToStart tryRange withRange - let collapseWith = Range.endToEnd withRange wholeRange - let fullrangeWith = Range.startToEnd withRange wholeRange - rcheck Scope.TryWith Collapse.Below fullrange collapse + let collapseWith = Range.endToEnd withRange mWhole + let fullrangeWith = Range.startToEnd withRange mWhole + rcheck Scope.TryWith Collapse.Below mFull collapse rcheck Scope.TryInTryWith Collapse.Below fullrangeTry collapseTry rcheck Scope.WithInTryWith Collapse.Below fullrangeWith collapseWith | _ -> () @@ -399,10 +399,10 @@ module Structure = match tryPoint, finallyPoint with | DebugPointAtTry.Yes tryRange, DebugPointAtFinally.Yes finallyRange -> let collapse = Range.endToEnd tryRange finallyExpr.Range - let fullrange = Range.startToEnd tryRange finallyExpr.Range + let mFull = Range.startToEnd tryRange finallyExpr.Range let collapseFinally = Range.endToEnd finallyRange r let fullrangeFinally = Range.startToEnd finallyRange r - rcheck Scope.TryFinally Collapse.Below fullrange collapse + rcheck Scope.TryFinally Collapse.Below mFull collapse rcheck Scope.FinallyInTryFinally Collapse.Below fullrangeFinally collapseFinally | _ -> () @@ -418,9 +418,9 @@ module Structure = match spIfToThen with | DebugPointAtBinding.Yes rt -> // Outline the entire IfThenElse - let fullrange = Range.startToEnd rt r + let mFull = Range.startToEnd rt r let collapse = Range.endToEnd ifExpr.Range r - rcheck Scope.IfThenElse Collapse.Below fullrange collapse + rcheck Scope.IfThenElse Collapse.Below mFull collapse // Outline the `then` scope let thenRange = Range.endToEnd (Range.modEnd -4 trivia.IfToThenRange) thenExpr.Range let thenCollapse = Range.endToEnd trivia.IfToThenRange thenExpr.Range @@ -653,24 +653,24 @@ module Structure = | _ -> () and parseTypeDefn typeDefn = - let (SynTypeDefn (typeInfo = typeInfo; typeRepr = objectModel; members = members; range = fullrange)) = + let (SynTypeDefn (typeInfo = typeInfo; typeRepr = objectModel; members = members; range = mFull)) = typeDefn let (SynComponentInfo (typeParams = TyparDecls typeArgs; range = r)) = typeInfo let typeArgsRange = rangeOfTypeArgsElse r typeArgs - let collapse = Range.endToEnd (Range.modEnd 1 typeArgsRange) fullrange + let collapse = Range.endToEnd (Range.modEnd 1 typeArgsRange) mFull match objectModel with | SynTypeDefnRepr.ObjectModel (defnKind, objMembers, r) -> match defnKind with - | SynTypeDefnKind.Augmentation _ -> rcheck Scope.TypeExtension Collapse.Below fullrange collapse - | _ -> rcheck Scope.Type Collapse.Below fullrange collapse + | SynTypeDefnKind.Augmentation _ -> rcheck Scope.TypeExtension Collapse.Below mFull collapse + | _ -> rcheck Scope.Type Collapse.Below mFull collapse List.iter (parseSynMemberDefn r) objMembers // visit the members of a type extension List.iter (parseSynMemberDefn r) members | SynTypeDefnRepr.Simple (simpleRepr, r) -> - rcheck Scope.Type Collapse.Below fullrange collapse + rcheck Scope.Type Collapse.Below mFull collapse parseSimpleRepr simpleRepr List.iter (parseSynMemberDefn r) members | SynTypeDefnRepr.Exception _ -> () @@ -774,12 +774,12 @@ module Structure = let parseModuleOrNamespace (SynModuleOrNamespace (longId, _, kind, decls, _, attribs, _, r, _)) = parseAttributes attribs let idRange = longIdentRange longId - let fullrange = Range.startToEnd idRange r + let mFull = Range.startToEnd idRange r let collapse = Range.endToEnd idRange r // do not return range for top level implicit module in scripts if kind = SynModuleOrNamespaceKind.NamedModule then - rcheck Scope.Module Collapse.Below fullrange collapse + rcheck Scope.Module Collapse.Below mFull collapse collectHashDirectives decls collectOpens decls @@ -893,9 +893,9 @@ module Structure = | SynMemberSig.Member (valSigs, _, r) -> let collapse = Range.endToEnd valSigs.RangeOfId r rcheck Scope.Member Collapse.Below r collapse - | SynMemberSig.ValField (SynField (attrs, _, _, _, _, _, _, fr), fullrange) -> - let collapse = Range.endToEnd fr fullrange - rcheck Scope.Val Collapse.Below fullrange collapse + | SynMemberSig.ValField (SynField (attrs, _, _, _, _, _, _, fr), mFull) -> + let collapse = Range.endToEnd fr mFull + rcheck Scope.Val Collapse.Below mFull collapse parseAttributes attrs | SynMemberSig.Interface (tp, r) -> rcheck Scope.Interface Collapse.Below r (Range.endToEnd tp.Range r) | SynMemberSig.NestedType (typeDefSig, _r) -> parseTypeDefnSig typeDefSig @@ -913,8 +913,8 @@ module Structure = let typeArgsRange = rangeOfTypeArgsElse r typeArgs let rangeEnd = lastMemberSigRangeElse r memberSigs let collapse = Range.endToEnd (Range.modEnd 1 typeArgsRange) rangeEnd - let fullrange = Range.startToEnd (longIdentRange longId) rangeEnd - fullrange, collapse + let mFull = Range.startToEnd (longIdentRange longId) rangeEnd + mFull, collapse List.iter parseSynMemberDefnSig memberSigs @@ -922,23 +922,23 @@ module Structure = // matches against a type declaration with <'T, ...> and (args, ...) | SynTypeDefnSigRepr.ObjectModel (SynTypeDefnKind.Unspecified, objMembers, _) -> List.iter parseSynMemberDefnSig objMembers - let fullrange, collapse = makeRanges objMembers - rcheck Scope.Type Collapse.Below fullrange collapse + let mFull, collapse = makeRanges objMembers + rcheck Scope.Type Collapse.Below mFull collapse | SynTypeDefnSigRepr.ObjectModel (kind = SynTypeDefnKind.Augmentation _; memberSigs = objMembers) -> - let fullrange, collapse = makeRanges objMembers - rcheck Scope.TypeExtension Collapse.Below fullrange collapse + let mFull, collapse = makeRanges objMembers + rcheck Scope.TypeExtension Collapse.Below mFull collapse List.iter parseSynMemberDefnSig objMembers | SynTypeDefnSigRepr.ObjectModel (_, objMembers, _) -> - let fullrange, collapse = makeRanges objMembers - rcheck Scope.Type Collapse.Below fullrange collapse + let mFull, collapse = makeRanges objMembers + rcheck Scope.Type Collapse.Below mFull collapse List.iter parseSynMemberDefnSig objMembers // visit the members of a type extension | SynTypeDefnSigRepr.Simple (simpleRepr, _) -> - let fullrange, collapse = makeRanges memberSigs - rcheck Scope.Type Collapse.Below fullrange collapse + let mFull, collapse = makeRanges memberSigs + rcheck Scope.Type Collapse.Below mFull collapse parseSimpleRepr simpleRepr | SynTypeDefnSigRepr.Exception _ -> () @@ -1021,8 +1021,8 @@ module Structure = let rangeEnd = lastModuleSigDeclRangeElse moduleRange decls // Outline the full scope of the module let collapse = Range.endToEnd cmpRange rangeEnd - let fullrange = Range.startToEnd moduleRange rangeEnd - rcheck Scope.Module Collapse.Below fullrange collapse + let mFull = Range.startToEnd moduleRange rangeEnd + rcheck Scope.Module Collapse.Below mFull collapse // A module's component info stores the ranges of its attributes parseAttributes attrs collectSigOpens decls @@ -1034,11 +1034,11 @@ module Structure = parseAttributes attribs let rangeEnd = lastModuleSigDeclRangeElse r decls let idrange = longIdentRange longId - let fullrange = Range.startToEnd idrange rangeEnd + let mFull = Range.startToEnd idrange rangeEnd let collapse = Range.endToEnd idrange rangeEnd if kind.IsModule then - rcheck Scope.Module Collapse.Below fullrange collapse + rcheck Scope.Module Collapse.Below mFull collapse collectSigHashDirectives decls collectSigOpens decls diff --git a/src/Compiler/Symbols/Exprs.fs b/src/Compiler/Symbols/Exprs.fs index 24ffc3cb042..0de02d99948 100644 --- a/src/Compiler/Symbols/Exprs.fs +++ b/src/Compiler/Symbols/Exprs.fs @@ -348,12 +348,12 @@ module FSharpExprConvert = | TOp.UnionCaseFieldGetAddr (uref, n, _), [arg], _ -> mkUnionCaseFieldGetProvenViaExprAddr (exprOfExprAddr cenv arg, uref, tyargs, n, m) | TOp.ILAsm ([ I_ldflda fspec ], retTypes), [arg], _ -> mkAsmExpr ([ mkNormalLdfld fspec ], tyargs, [exprOfExprAddr cenv arg], retTypes, m) | TOp.ILAsm ([ I_ldsflda fspec ], retTypes), _, _ -> mkAsmExpr ([ mkNormalLdsfld fspec ], tyargs, args, retTypes, m) - | TOp.ILAsm ([ I_ldelema(_ro, _isNativePtr, shape, _tyarg) ], _), arr :: idxs, [elemty] -> + | TOp.ILAsm ([ I_ldelema(_ro, _isNativePtr, shape, _tyarg) ], _), arr :: idxs, [elemTy] -> match shape.Rank, idxs with - | 1, [idx1] -> mkCallArrayGet g m elemty arr idx1 - | 2, [idx1; idx2] -> mkCallArray2DGet g m elemty arr idx1 idx2 - | 3, [idx1; idx2; idx3] -> mkCallArray3DGet g m elemty arr idx1 idx2 idx3 - | 4, [idx1; idx2; idx3; idx4] -> mkCallArray4DGet g m elemty arr idx1 idx2 idx3 idx4 + | 1, [idx1] -> mkCallArrayGet g m elemTy arr idx1 + | 2, [idx1; idx2] -> mkCallArray2DGet g m elemTy arr idx1 idx2 + | 3, [idx1; idx2; idx3] -> mkCallArray3DGet g m elemTy arr idx1 idx2 idx3 + | 4, [idx1; idx2; idx3; idx4] -> mkCallArray4DGet g m elemTy arr idx1 idx2 idx3 idx4 | _ -> expr | _ -> expr | _ -> expr @@ -618,7 +618,7 @@ module FSharpExprConvert = let bodyR = ConvExpr cenv env body FSharpObjectExprOverride(sgn, tpsR, vslR, bodyR) ] let overridesR = ConvertMethods overrides - let iimplsR = List.map (fun (ity, impls) -> ConvType cenv ity, ConvertMethods impls) iimpls + let iimplsR = iimpls |> List.map (fun (intfTy, impls) -> ConvType cenv intfTy, ConvertMethods impls) E.ObjectExpr(ConvType cenv ty, basecallR, overridesR, iimplsR) @@ -702,8 +702,8 @@ module FSharpExprConvert = let argR = ConvExpr cenv env arg E.ILFieldSet(None, typR, fspec.Name, argR) - | TOp.ILAsm ([ ], [tty]), _, [arg] -> - match tty with + | TOp.ILAsm ([ ], [tgtTy]), _, [arg] -> + match tgtTy with | TTypeConvOp cenv convOp -> let ty = tyOfExpr g arg let op = convOp g m ty arg @@ -992,7 +992,7 @@ module FSharpExprConvert = let parent = ILTypeRef.Create(e.Scope, e.Enclosing.Tail, e.Enclosing.Head) Import.ImportILTypeRef cenv.amap m parent, Some e.Name - let enclosingType = generalizedTyconRef g tcref + let enclosingTy = generalizedTyconRef g tcref let makeCall minfo = ConvObjectModelCallLinear cenv env (isNewObj, minfo, enclTypeArgs, methTypeArgs, [], callArgs) id @@ -1000,7 +1000,7 @@ module FSharpExprConvert = let makeFSCall isMember (vr: ValRef) = let memOrVal = if isMember then - let minfo = MethInfo.FSMeth(g, enclosingType, vr, None) + let minfo = MethInfo.FSMeth(g, enclosingTy, vr, None) FSharpMemberOrFunctionOrValue(cenv, minfo) else FSharpMemberOrFunctionOrValue(cenv, vr) @@ -1117,7 +1117,7 @@ module FSharpExprConvert = if tcref.IsILTycon then try let mdef = resolveILMethodRefWithRescope unscopeILType tcref.ILTyconRawMetadata ilMethRef - let minfo = MethInfo.CreateILMeth(cenv.amap, m, enclosingType, mdef) + let minfo = MethInfo.CreateILMeth(cenv.amap, m, enclosingTy, mdef) FSharpMemberOrFunctionOrValue(cenv, minfo) |> makeCall |> Some with _ -> None @@ -1155,12 +1155,12 @@ module FSharpExprConvert = let argTys = [ ilMethRef.ArgTypes |> List.map (ImportILTypeFromMetadata cenv.amap m scoref tinst1 tinst2) ] let retTy = match ImportReturnTypeFromMetadata cenv.amap m ilMethRef.ReturnType (fun _ -> emptyILCustomAttrs) scoref tinst1 tinst2 with - | None -> if isCtor then enclosingType else g.unit_ty + | None -> if isCtor then enclosingTy else g.unit_ty | Some ty -> ty let linkageType = let ty = mkIteratedFunTy g (List.map (mkRefTupledTy g) argTys) retTy - let ty = if isStatic then ty else mkFunTy g enclosingType ty + let ty = if isStatic then ty else mkFunTy g enclosingTy ty mkForallTyIfNeeded (typars1 @ typars2) ty let argCount = List.sum (List.map List.length argTys) + (if isStatic then 0 else 1) @@ -1325,9 +1325,9 @@ module FSharpExprConvert = let env = { env with suppressWitnesses = true } ConvExpr cenv env eq E.IfThenElse (eqR, ConvDecisionTree cenv env dtreeRetTy dtree m, acc) - | DecisionTreeTest.IsInst (_srcty, tgty) -> + | DecisionTreeTest.IsInst (_srcTy, tgtTy) -> let e1R = ConvExpr cenv env inpExpr - E.IfThenElse (E.TypeTest (ConvType cenv tgty, e1R) |> Mk cenv m g.bool_ty, ConvDecisionTree cenv env dtreeRetTy dtree m, acc) + E.IfThenElse (E.TypeTest (ConvType cenv tgtTy, e1R) |> Mk cenv m g.bool_ty, ConvDecisionTree cenv env dtreeRetTy dtree m, acc) | DecisionTreeTest.ActivePatternCase _ -> wfail("unexpected Test.ActivePatternCase test in quoted expression", m) | DecisionTreeTest.ArrayLength _ -> wfail("FSharp.Compiler.Service cannot yet return array pattern matching", m) | DecisionTreeTest.Error m -> wfail("error recovery", m) diff --git a/src/Compiler/Symbols/SymbolHelpers.fs b/src/Compiler/Symbols/SymbolHelpers.fs index f65cd4541cc..c265024fc40 100644 --- a/src/Compiler/Symbols/SymbolHelpers.fs +++ b/src/Compiler/Symbols/SymbolHelpers.fs @@ -631,9 +631,9 @@ module internal SymbolHelpers = match item with | Item.Types(_name, tys) -> match tys with - | [AppTy g (tyconRef, _typeInst)] -> - if tyconRef.IsProvidedErasedTycon || tyconRef.IsProvidedGeneratedTycon then - Some tyconRef + | [AppTy g (tcref, _typeInst)] -> + if tcref.IsProvidedErasedTycon || tcref.IsProvidedGeneratedTycon then + Some tcref else None | _ -> None @@ -644,10 +644,10 @@ module internal SymbolHelpers = match item with | Item.Types(_name, tys) -> match tys with - | [AppTy g (tyconRef, _typeInst)] -> - if tyconRef.IsProvidedErasedTycon || tyconRef.IsProvidedGeneratedTycon then + | [AppTy g (tcref, _typeInst)] -> + if tcref.IsProvidedErasedTycon || tcref.IsProvidedGeneratedTycon then let typeBeforeArguments = - match tyconRef.TypeReprInfo with + match tcref.TypeReprInfo with | TProvidedTypeRepr info -> info.ProvidedType | _ -> failwith "unreachable" let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments, provider) -> typeBeforeArguments.GetStaticParameters provider), range=m) diff --git a/src/Compiler/Symbols/SymbolPatterns.fs b/src/Compiler/Symbols/SymbolPatterns.fs index bddfe60e135..e44375cb97c 100644 --- a/src/Compiler/Symbols/SymbolPatterns.fs +++ b/src/Compiler/Symbols/SymbolPatterns.fs @@ -43,7 +43,7 @@ module FSharpSymbolPatterns = if entity.IsFSharpAbbreviation then match entity.AbbreviatedType with | TypeWithDefinition def -> getEntityAbbreviatedType def - | abbreviatedType -> entity, Some abbreviatedType + | abbreviatedTy -> entity, Some abbreviatedTy else entity, None let (|Attribute|_|) (entity: FSharpEntity) = @@ -151,12 +151,12 @@ module FSharpSymbolPatterns = | _ -> false if isMutable then Some() else None - /// Entity (originalEntity, abbreviatedEntity, abbreviatedType) + /// Entity (originalEntity, abbreviatedEntity, abbreviatedTy) let (|FSharpEntity|_|) (symbol: FSharpSymbol) = match symbol with | :? FSharpEntity as entity -> - let abbreviatedEntity, abbreviatedType = getEntityAbbreviatedType entity - Some (entity, abbreviatedEntity, abbreviatedType) + let abbreviatedEntity, abbreviatedTy = getEntityAbbreviatedType entity + Some (entity, abbreviatedEntity, abbreviatedTy) | _ -> None let (|Parameter|_|) (symbol: FSharpSymbol) = diff --git a/src/Compiler/Symbols/Symbols.fs b/src/Compiler/Symbols/Symbols.fs index 6475f93a08d..602ccb7459d 100644 --- a/src/Compiler/Symbols/Symbols.fs +++ b/src/Compiler/Symbols/Symbols.fs @@ -350,7 +350,7 @@ type FSharpSymbol(cenv: SymbolEnv, item: unit -> Item, access: FSharpSymbol -> C member sym.TryGetAttribute<'T>() = sym.Attributes |> Seq.tryFind (fun attr -> attr.IsAttribute<'T>()) -type FSharpEntity(cenv: SymbolEnv, entity:EntityRef) = +type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) = inherit FSharpSymbol(cenv, (fun () -> checkEntityIsResolved entity @@ -588,8 +588,8 @@ type FSharpEntity(cenv: SymbolEnv, entity:EntityRef) = if isUnresolved() then makeReadOnlyCollection [] else let ty = generalizedTyconRef cenv.g entity DiagnosticsLogger.protectAssemblyExploration [] (fun () -> - [ for ity in GetImmediateInterfacesOfType SkipUnrefInterfaces.Yes cenv.g cenv.amap range0 ty do - yield FSharpType(cenv, ity) ]) + [ for intfTy in GetImmediateInterfacesOfType SkipUnrefInterfaces.Yes cenv.g cenv.amap range0 ty do + yield FSharpType(cenv, intfTy) ]) |> makeReadOnlyCollection member _.AllInterfaces = @@ -642,10 +642,13 @@ type FSharpEntity(cenv: SymbolEnv, entity:EntityRef) = else for minfo in GetImmediateIntrinsicMethInfosOfType (None, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 entityTy do yield createMember minfo + let props = GetImmediateIntrinsicPropInfosOfType (None, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 entityTy let events = cenv.infoReader.GetImmediateIntrinsicEventsOfType (None, AccessibleFromSomeFSharpCode, range0, entityTy) + for pinfo in props do yield FSharpMemberOrFunctionOrValue(cenv, P pinfo, Item.Property (pinfo.PropertyName, [pinfo])) + for einfo in events do yield FSharpMemberOrFunctionOrValue(cenv, E einfo, Item.Event einfo) @@ -657,8 +660,8 @@ type FSharpEntity(cenv: SymbolEnv, entity:EntityRef) = let vref = mkNestedValRef entity v yield FSharpMemberOrFunctionOrValue(cenv, V vref, Item.Value vref) match v.MemberInfo.Value.MemberFlags.MemberKind, v.ApparentEnclosingEntity with - | SynMemberKind.PropertyGet, Parent p -> - let pinfo = FSProp(cenv.g, generalizedTyconRef cenv.g p, Some vref, None) + | SynMemberKind.PropertyGet, Parent tcref -> + let pinfo = FSProp(cenv.g, generalizedTyconRef cenv.g tcref, Some vref, None) yield FSharpMemberOrFunctionOrValue(cenv, P pinfo, Item.Property (pinfo.PropertyName, [pinfo])) | SynMemberKind.PropertySet, Parent p -> let pinfo = FSProp(cenv.g, generalizedTyconRef cenv.g p, None, Some vref) @@ -1306,7 +1309,7 @@ type FSharpActivePatternGroup(cenv, apinfo:ActivePatternInfo, ty, valOpt) = |> Option.bind (fun vref -> match vref.DeclaringEntity with | ParentNone -> None - | Parent p -> Some (FSharpEntity(cenv, p))) + | Parent tcref -> Some (FSharpEntity(cenv, tcref))) type FSharpGenericParameter(cenv, v:Typar) = @@ -1411,7 +1414,7 @@ type FSharpAbstractSignature(cenv, info: SlotSig) = member _.Name = info.Name - member _.DeclaringType = FSharpType(cenv, info.ImplementedType) + member _.DeclaringType = FSharpType(cenv, info.DeclaringType) type FSharpGenericParameterMemberConstraint(cenv, info: TraitConstraintInfo) = let (TTrait(tys, nm, flags, atys, retTy, _)) = info @@ -2076,7 +2079,7 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = | E e -> // INCOMPLETENESS: Attribs is empty here, so we can't look at return attributes for .NET or F# methods let retTy = - try PropTypOfEventInfo cenv.infoReader range0 AccessibleFromSomewhere e + try PropTypeOfEventInfo cenv.infoReader range0 AccessibleFromSomewhere e with _ -> // For non-standard events, just use the delegate type as the ReturnParameter type e.GetDelegateType(cenv.amap, range0) @@ -2197,17 +2200,17 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = member _.IsValCompiledAsMethod = match d with - | V valRef -> IlxGen.IsFSharpValCompiledAsMethod cenv.g valRef.Deref + | V vref -> IlxGen.IsFSharpValCompiledAsMethod cenv.g vref.Deref | _ -> false member _.IsValue = match d with - | V valRef -> not (isForallFunctionTy cenv.g valRef.Type) + | V vref -> not (isForallFunctionTy cenv.g vref.Type) | _ -> false member _.IsFunction = match d with - | V valRef -> isForallFunctionTy cenv.g valRef.Type + | V vref -> isForallFunctionTy cenv.g vref.Type | _ -> false override x.Equals(other: obj) = @@ -2326,7 +2329,7 @@ type FSharpType(cenv, ty:TType) = DiagnosticsLogger.protectAssemblyExploration true <| fun () -> match stripTyparEqns ty with | TType_app (tcref, _, _) -> FSharpEntity(cenv, tcref).IsUnresolved - | TType_measure (Measure.Con tcref) -> FSharpEntity(cenv, tcref).IsUnresolved + | TType_measure (Measure.Const tcref) -> FSharpEntity(cenv, tcref).IsUnresolved | TType_measure (Measure.Prod _) -> FSharpEntity(cenv, cenv.g.measureproduct_tcr).IsUnresolved | TType_measure Measure.One -> FSharpEntity(cenv, cenv.g.measureone_tcr).IsUnresolved | TType_measure (Measure.Inv _) -> FSharpEntity(cenv, cenv.g.measureinverse_tcr).IsUnresolved @@ -2342,7 +2345,7 @@ type FSharpType(cenv, ty:TType) = isResolved() && protect <| fun () -> match stripTyparEqns ty with - | TType_app _ | TType_measure (Measure.Con _ | Measure.Prod _ | Measure.Inv _ | Measure.One _) -> true + | TType_app _ | TType_measure (Measure.Const _ | Measure.Prod _ | Measure.Inv _ | Measure.One _) -> true | _ -> false member _.IsTupleType = @@ -2363,7 +2366,7 @@ type FSharpType(cenv, ty:TType) = protect <| fun () -> match stripTyparEqns ty with | TType_app (tcref, _, _) -> FSharpEntity(cenv, tcref) - | TType_measure (Measure.Con tcref) -> FSharpEntity(cenv, tcref) + | TType_measure (Measure.Const tcref) -> FSharpEntity(cenv, tcref) | TType_measure (Measure.Prod _) -> FSharpEntity(cenv, cenv.g.measureproduct_tcr) | TType_measure Measure.One -> FSharpEntity(cenv, cenv.g.measureone_tcr) | TType_measure (Measure.Inv _) -> FSharpEntity(cenv, cenv.g.measureinverse_tcr) @@ -2375,8 +2378,8 @@ type FSharpType(cenv, ty:TType) = | TType_anon (_, tyargs) | TType_app (_, tyargs, _) | TType_tuple (_, tyargs) -> (tyargs |> List.map (fun ty -> FSharpType(cenv, ty)) |> makeReadOnlyCollection) - | TType_fun(d, r, _) -> [| FSharpType(cenv, d); FSharpType(cenv, r) |] |> makeReadOnlyCollection - | TType_measure (Measure.Con _) -> [| |] |> makeReadOnlyCollection + | TType_fun(domainTy, rangeTy, _) -> [| FSharpType(cenv, domainTy); FSharpType(cenv, rangeTy) |] |> makeReadOnlyCollection + | TType_measure (Measure.Const _) -> [| |] |> makeReadOnlyCollection | TType_measure (Measure.Prod (t1, t2)) -> [| FSharpType(cenv, TType_measure t1); FSharpType(cenv, TType_measure t2) |] |> makeReadOnlyCollection | TType_measure Measure.One -> [| |] |> makeReadOnlyCollection | TType_measure (Measure.Inv t1) -> [| FSharpType(cenv, TType_measure t1) |] |> makeReadOnlyCollection @@ -2443,8 +2446,8 @@ type FSharpType(cenv, ty:TType) = |> Option.map (fun ty -> FSharpType(cenv, ty)) member _.Instantiate(instantiation:(FSharpGenericParameter * FSharpType) list) = - let typI = instType (instantiation |> List.map (fun (tyv, ty) -> tyv.TypeParameter, ty.Type)) ty - FSharpType(cenv, typI) + let resTy = instType (instantiation |> List.map (fun (tyv, ty) -> tyv.TypeParameter, ty.Type)) ty + FSharpType(cenv, resTy) member _.Type = ty member private x.cenv = cenv @@ -2469,7 +2472,7 @@ type FSharpType(cenv, ty:TType) = | TType_app (tc1, b1, _) -> 10200 + int32 tc1.Stamp + List.sumBy hashType b1 | TType_ucase _ -> 10300 // shouldn't occur in symbols | TType_tuple (_, l1) -> 10400 + List.sumBy hashType l1 - | TType_fun (dty, rty, _) -> 10500 + hashType dty + hashType rty + | TType_fun (domainTy, rangeTy, _) -> 10500 + hashType domainTy + hashType rangeTy | TType_measure _ -> 10600 | TType_anon (_,l1) -> 10800 + List.sumBy hashType l1 hashType ty @@ -2593,9 +2596,9 @@ type FSharpStaticParameter(cenv, sp: Tainted< TypeProviders.ProvidedParameterInf inherit FSharpSymbol(cenv, (fun () -> protect <| fun () -> - let spKind = Import.ImportProvidedType cenv.amap m (sp.PApply((fun x -> x.ParameterType), m)) + let paramTy = Import.ImportProvidedType cenv.amap m (sp.PApply((fun x -> x.ParameterType), m)) let nm = sp.PUntaint((fun p -> p.Name), m) - Item.ArgName((mkSynId m nm, spKind, None))), + Item.ArgName((mkSynId m nm, paramTy, None))), (fun _ _ _ -> true)) member _.Name = diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs index 546a1b1ade7..1834bb0fbf7 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs @@ -373,12 +373,12 @@ let mkSynOperator (opm: range) (oper: string) = let mkSynInfix opm (l: SynExpr) oper (r: SynExpr) = let firstTwoRange = unionRanges l.Range opm - let wholeRange = unionRanges l.Range r.Range + let mWhole = unionRanges l.Range r.Range let app1 = SynExpr.App(ExprAtomicFlag.NonAtomic, true, mkSynOperator opm oper, l, firstTwoRange) - SynExpr.App(ExprAtomicFlag.NonAtomic, false, app1, r, wholeRange) + SynExpr.App(ExprAtomicFlag.NonAtomic, false, app1, r, mWhole) let mkSynBifix m oper x1 x2 = let app1 = SynExpr.App(ExprAtomicFlag.NonAtomic, true, mkSynOperator m oper, x1, m) @@ -417,17 +417,17 @@ let mkSynDotBrackGet m mDot a b = SynExpr.DotIndexedGet(a, b, mDot, m) let mkSynQMarkSet m a b c = mkSynTrifix m qmarkSet a b c -let mkSynDotParenGet lhsm dotm a b = +let mkSynDotParenGet mLhs mDot a b = match b with | SynExpr.Tuple (false, [ _; _ ], _, _) -> - errorR (Deprecated(FSComp.SR.astDeprecatedIndexerNotation (), lhsm)) - SynExpr.Const(SynConst.Unit, lhsm) + errorR (Deprecated(FSComp.SR.astDeprecatedIndexerNotation (), mLhs)) + SynExpr.Const(SynConst.Unit, mLhs) | SynExpr.Tuple (false, [ _; _; _ ], _, _) -> - errorR (Deprecated(FSComp.SR.astDeprecatedIndexerNotation (), lhsm)) - SynExpr.Const(SynConst.Unit, lhsm) + errorR (Deprecated(FSComp.SR.astDeprecatedIndexerNotation (), mLhs)) + SynExpr.Const(SynConst.Unit, mLhs) - | _ -> mkSynInfix dotm a parenGet b + | _ -> mkSynInfix mDot a parenGet b let mkSynUnit m = SynExpr.Const(SynConst.Unit, m) @@ -452,24 +452,24 @@ let mkSynAssign (l: SynExpr) (r: SynExpr) = | SynExpr.App (_, _, SynExpr.DotGet (e, _, v, _), x, _) -> SynExpr.DotNamedIndexedPropertySet(e, v, x, r, m) | l -> SynExpr.Set(l, r, m) -let mkSynDot dotm m l (SynIdent (r, rTrivia)) = +let mkSynDot mDot m l (SynIdent (r, rTrivia)) = match l with | SynExpr.LongIdent (isOpt, SynLongIdent (lid, dots, trivia), None, _) -> // REVIEW: MEMORY PERFORMANCE: This list operation is memory intensive (we create a lot of these list nodes) - SynExpr.LongIdent(isOpt, SynLongIdent(lid @ [ r ], dots @ [ dotm ], trivia @ [ rTrivia ]), None, m) - | SynExpr.Ident id -> SynExpr.LongIdent(false, SynLongIdent([ id; r ], [ dotm ], [ None; rTrivia ]), None, m) + SynExpr.LongIdent(isOpt, SynLongIdent(lid @ [ r ], dots @ [ mDot ], trivia @ [ rTrivia ]), None, m) + | SynExpr.Ident id -> SynExpr.LongIdent(false, SynLongIdent([ id; r ], [ mDot ], [ None; rTrivia ]), None, m) | SynExpr.DotGet (e, dm, SynLongIdent (lid, dots, trivia), _) -> // REVIEW: MEMORY PERFORMANCE: This is memory intensive (we create a lot of these list nodes) - SynExpr.DotGet(e, dm, SynLongIdent(lid @ [ r ], dots @ [ dotm ], trivia @ [ rTrivia ]), m) - | expr -> SynExpr.DotGet(expr, dotm, SynLongIdent([ r ], [], [ rTrivia ]), m) + SynExpr.DotGet(e, dm, SynLongIdent(lid @ [ r ], dots @ [ mDot ], trivia @ [ rTrivia ]), m) + | expr -> SynExpr.DotGet(expr, mDot, SynLongIdent([ r ], [], [ rTrivia ]), m) -let mkSynDotMissing dotm m l = +let mkSynDotMissing mDot m l = match l with | SynExpr.LongIdent (isOpt, SynLongIdent (lid, dots, trivia), None, _) -> // REVIEW: MEMORY PERFORMANCE: This list operation is memory intensive (we create a lot of these list nodes) - SynExpr.LongIdent(isOpt, SynLongIdent(lid, dots @ [ dotm ], trivia), None, m) - | SynExpr.Ident id -> SynExpr.LongIdent(false, SynLongIdent([ id ], [ dotm ], []), None, m) - | SynExpr.DotGet (e, dm, SynLongIdent (lid, dots, trivia), _) -> SynExpr.DotGet(e, dm, SynLongIdent(lid, dots @ [ dotm ], trivia), m) // REVIEW: MEMORY PERFORMANCE: This is memory intensive (we create a lot of these list nodes) + SynExpr.LongIdent(isOpt, SynLongIdent(lid, dots @ [ mDot ], trivia), None, m) + | SynExpr.Ident id -> SynExpr.LongIdent(false, SynLongIdent([ id ], [ mDot ], []), None, m) + | SynExpr.DotGet (e, dm, SynLongIdent (lid, dots, trivia), _) -> SynExpr.DotGet(e, dm, SynLongIdent(lid, dots @ [ mDot ], trivia), m) // REVIEW: MEMORY PERFORMANCE: This is memory intensive (we create a lot of these list nodes) | expr -> SynExpr.DiscardAfterMissingQualificationAfterDot(expr, m) let mkSynFunMatchLambdas synArgNameGenerator isMember wholem ps arrow e = @@ -974,9 +974,9 @@ let (|ParsedHashDirectiveArguments|) (input: ParsedHashDirectiveArgument list) = | ParsedHashDirectiveArgument.SourceIdentifier (_, v, _) -> v) input -let prependIdentInLongIdentWithTrivia (SynIdent (ident, identTrivia)) dotm lid = +let prependIdentInLongIdentWithTrivia (SynIdent (ident, identTrivia)) mDot lid = match lid with - | SynLongIdent (lid, dots, trivia) -> SynLongIdent(ident :: lid, dotm :: dots, identTrivia :: trivia) + | SynLongIdent (lid, dots, trivia) -> SynLongIdent(ident :: lid, mDot :: dots, identTrivia :: trivia) let mkDynamicArgExpr expr = match expr with diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi b/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi index edda8d21d5b..0c7010b40fa 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi @@ -143,7 +143,7 @@ val mkSynQMarkSet: m: range -> a: SynExpr -> b: SynExpr -> c: SynExpr -> SynExpr //val mkSynDotBrackSeqSliceGet: m:range -> mDot:range -> arr:SynExpr -> argsList:SynIndexerArg list -> SynExpr -val mkSynDotParenGet: lhsm: range -> dotm: range -> a: SynExpr -> b: SynExpr -> SynExpr +val mkSynDotParenGet: mLhs: range -> mDot: range -> a: SynExpr -> b: SynExpr -> SynExpr val mkSynUnit: m: range -> SynExpr @@ -153,9 +153,9 @@ val mkSynDelay: m: range -> e: SynExpr -> SynExpr val mkSynAssign: l: SynExpr -> r: SynExpr -> SynExpr -val mkSynDot: dotm: range -> m: range -> l: SynExpr -> r: SynIdent -> SynExpr +val mkSynDot: mDot: range -> m: range -> l: SynExpr -> r: SynIdent -> SynExpr -val mkSynDotMissing: dotm: range -> m: range -> l: SynExpr -> SynExpr +val mkSynDotMissing: mDot: range -> m: range -> l: SynExpr -> SynExpr val mkSynFunMatchLambdas: synArgNameGenerator: SynArgNameGenerator -> @@ -337,7 +337,7 @@ val (|SynPipeRight2|_|): SynExpr -> (SynExpr * SynExpr * SynExpr) option /// 'e1 |||> e2' val (|SynPipeRight3|_|): SynExpr -> (SynExpr * SynExpr * SynExpr * SynExpr) option -val prependIdentInLongIdentWithTrivia: ident: SynIdent -> dotm: range -> lid: SynLongIdent -> SynLongIdent +val prependIdentInLongIdentWithTrivia: ident: SynIdent -> mDot: range -> lid: SynLongIdent -> SynLongIdent val mkDynamicArgExpr: expr: SynExpr -> SynExpr diff --git a/src/Compiler/TypedTree/TcGlobals.fs b/src/Compiler/TypedTree/TcGlobals.fs index 51060755e80..cf248940c9a 100755 --- a/src/Compiler/TypedTree/TcGlobals.fs +++ b/src/Compiler/TypedTree/TcGlobals.fs @@ -564,8 +564,8 @@ type TcGlobals( let tryDecodeTupleTy tupInfo l = match l with - | [t1;t2;t3;t4;t5;t6;t7;marker] -> - match marker with + | [t1;t2;t3;t4;t5;t6;t7;markerTy] -> + match markerTy with | TType_app(tcref, [t8], _) when tyconRefEq tcref v_ref_tuple1_tcr -> mkRawRefTupleTy [t1;t2;t3;t4;t5;t6;t7;t8] |> Some | TType_app(tcref, [t8], _) when tyconRefEq tcref v_struct_tuple1_tcr -> mkRawStructTupleTy [t1;t2;t3;t4;t5;t6;t7;t8] |> Some | TType_tuple (_structness2, t8plus) -> TType_tuple (tupInfo, [t1;t2;t3;t4;t5;t6;t7] @ t8plus) |> Some @@ -1832,11 +1832,11 @@ type TcGlobals( let info = makeOtherIntrinsicValRef (fslib_MFOperators_nleref, lower, None, Some nm, [vara], ([[varaTy]], varaTy)) let tyargs = [aty] Some (info, tyargs, argExprs) - | "get_Item", [arrTy; _], Some rty, [_; _] when isArrayTy g arrTy -> - Some (g.array_get_info, [rty], argExprs) - | "set_Item", [arrTy; _; ety], _, [_; _; _] when isArrayTy g arrTy -> - Some (g.array_set_info, [ety], argExprs) - | "get_Item", [sty; _; _], _, [_; _] when isStringTy g sty -> + | "get_Item", [arrTy; _], Some retTy, [_; _] when isArrayTy g arrTy -> + Some (g.array_get_info, [retTy], argExprs) + | "set_Item", [arrTy; _; elemTy], _, [_; _; _] when isArrayTy g arrTy -> + Some (g.array_set_info, [elemTy], argExprs) + | "get_Item", [stringTy; _; _], _, [_; _] when isStringTy g stringTy -> Some (g.getstring_info, [], argExprs) | "op_UnaryPlus", [aty], _, [_] -> // Call Operators.id diff --git a/src/Compiler/TypedTree/TypedTree.fs b/src/Compiler/TypedTree/TypedTree.fs index 2d3f8c0943f..d71fd222745 100644 --- a/src/Compiler/TypedTree/TypedTree.fs +++ b/src/Compiler/TypedTree/TypedTree.fs @@ -1156,7 +1156,7 @@ type Entity = member x.MembersOfFSharpTyconSorted = x.TypeContents.tcaug_adhoc |> NameMultiMap.rangeReversingEachBucket - |> List.filter (fun v -> not v.IsCompilerGenerated) + |> List.filter (fun vref -> not vref.IsCompilerGenerated) /// Gets all immediate members of an F# type definition keyed by name, including compiler-generated ones. /// Note: result is a indexed table, and for each name the results are in reverse declaration order @@ -1179,16 +1179,16 @@ type Entity = member x.AllGeneratedValues = [ match x.GeneratedCompareToValues with | None -> () - | Some (v1, v2) -> yield v1; yield v2 + | Some (vref1, vref2) -> yield vref1; yield vref2 match x.GeneratedCompareToWithComparerValues with | None -> () | Some v -> yield v match x.GeneratedHashAndEqualsValues with | None -> () - | Some (v1, v2) -> yield v1; yield v2 + | Some (vref1, vref2) -> yield vref1; yield vref2 match x.GeneratedHashAndEqualsWithComparerValues with | None -> () - | Some (v1, v2, v3) -> yield v1; yield v2; yield v3 ] + | Some (vref1, vref2, vref3) -> yield vref1; yield vref2; yield vref3 ] /// Gets the data indicating the compiled representation of a type or module in terms of Abstract IL data structures. @@ -3720,32 +3720,32 @@ type ValRef = member x.ResolvedTarget = x.binding /// Dereference the ValRef to a Val. - member vr.Deref = - if obj.ReferenceEquals(vr.binding, null) then + member x.Deref = + if obj.ReferenceEquals(x.binding, null) then let res = - let nlr = vr.nlr + let nlr = x.nlr let e = nlr.EnclosingEntity.Deref let possible = e.ModuleOrNamespaceType.TryLinkVal(nlr.EnclosingEntity.nlr.Ccu, nlr.ItemKey) match possible with | ValueNone -> error (InternalUndefinedItemRef (FSComp.SR.tastUndefinedItemRefVal, e.DisplayNameWithStaticParameters, nlr.AssemblyName, sprintf "%+A" nlr.ItemKey.PartialKey)) | ValueSome h -> h - vr.binding <- nullableSlotFull res + x.binding <- nullableSlotFull res res - else vr.binding + else x.binding /// Dereference the ValRef to a Val option. - member vr.TryDeref = - if obj.ReferenceEquals(vr.binding, null) then + member x.TryDeref = + if obj.ReferenceEquals(x.binding, null) then let resOpt = - match vr.nlr.EnclosingEntity.TryDeref with + match x.nlr.EnclosingEntity.TryDeref with | ValueNone -> ValueNone - | ValueSome e -> e.ModuleOrNamespaceType.TryLinkVal(vr.nlr.EnclosingEntity.nlr.Ccu, vr.nlr.ItemKey) + | ValueSome e -> e.ModuleOrNamespaceType.TryLinkVal(x.nlr.EnclosingEntity.nlr.Ccu, x.nlr.ItemKey) match resOpt with | ValueNone -> () | ValueSome res -> - vr.binding <- nullableSlotFull res + x.binding <- nullableSlotFull res resOpt - else ValueSome vr.binding + else ValueSome x.binding /// The type of the value. May be a TType_forall for a generic value. /// May be a type variable or type containing type variables during type inference. @@ -3942,7 +3942,7 @@ type ValRef = /// Represents a reference to a case of a union type [] type UnionCaseRef = - | UnionCaseRef of TyconRef * string + | UnionCaseRef of tyconRef: TyconRef * caseName: string /// Get a reference to the type containing this union case member x.TyconRef = let (UnionCaseRef(tcref, _)) = x in tcref @@ -4001,7 +4001,7 @@ type UnionCaseRef = /// Represents a reference to a field in a record, class or struct [] type RecdFieldRef = - | RecdFieldRef of tcref: TyconRef * id: string + | RecdFieldRef of tyconRef: TyconRef * fieldName: string /// Get a reference to the type containing this union case member x.TyconRef = let (RecdFieldRef(tcref, _)) = x in tcref @@ -4098,7 +4098,7 @@ type TType = | TType_anon (anonInfo, _tinst) -> defaultArg anonInfo.Assembly.QualifiedName "" | TType_fun _ -> "" | TType_measure _ -> "" - | TType_var (tp, _) -> tp.Solution |> function Some sln -> sln.GetAssemblyName() | None -> "" + | TType_var (tp, _) -> tp.Solution |> function Some slnTy -> slnTy.GetAssemblyName() | None -> "" | TType_ucase (_uc, _tinst) -> let (TILObjectReprData(scope, _nesting, _definition)) = _uc.Tycon.ILTyconInfo scope.QualifiedName @@ -4120,7 +4120,7 @@ type TType = | TupInfo.Const false -> "" | TupInfo.Const true -> "struct ") + "{|" + String.concat "," (Seq.map2 (fun nm ty -> nm + " " + string ty + ";") anonInfo.SortedNames tinst) + ")" + "|}" - | TType_fun (d, r, _) -> "(" + string d + " -> " + string r + ")" + | TType_fun (domainTy, retTy, _) -> "(" + string domainTy + " -> " + string retTy + ")" | TType_ucase (uc, tinst) -> "ucase " + uc.CaseName + (match tinst with [] -> "" | tys -> "<" + String.concat "," (List.map string tys) + ">") | TType_var (tp, _) -> match tp.Solution with @@ -4197,7 +4197,7 @@ type Measure = | Var of typar: Typar /// A constant, leaf unit-of-measure such as 'kg' or 'm' - | Con of tyconRef: TyconRef + | Const of tyconRef: TyconRef /// A product of two units of measure | Prod of measure1: Measure * measure2: Measure @@ -5061,7 +5061,7 @@ type ObjExprMethod = type SlotSig = | TSlotSig of methodName: string * - implementedType: TType * + declaringType: TType * classTypars: Typars * methodTypars: Typars * formalParams: SlotParam list list * @@ -5071,7 +5071,7 @@ type SlotSig = member ss.Name = let (TSlotSig(nm, _, _, _, _, _)) = ss in nm /// The (instantiated) type which the slot is logically a part of - member ss.ImplementedType = let (TSlotSig(_, ty, _, _, _, _)) = ss in ty + member ss.DeclaringType = let (TSlotSig(_, ty, _, _, _, _)) = ss in ty /// The class type parameters of the slot member ss.ClassTypars = let (TSlotSig(_, _, ctps, _, _, _)) = ss in ctps diff --git a/src/Compiler/TypedTree/TypedTree.fsi b/src/Compiler/TypedTree/TypedTree.fsi index cdcf93e4518..57037ba27d8 100644 --- a/src/Compiler/TypedTree/TypedTree.fsi +++ b/src/Compiler/TypedTree/TypedTree.fsi @@ -2818,7 +2818,7 @@ type ValRef = /// Represents a reference to a case of a union type [] type UnionCaseRef = - | UnionCaseRef of TyconRef * string + | UnionCaseRef of tyconRef: TyconRef * caseName: string /// Get a field of the union case by index member FieldByIndex: n: int -> RecdField @@ -2867,7 +2867,7 @@ type UnionCaseRef = /// Represents a reference to a field in a record, class or struct [] type RecdFieldRef = - | RecdFieldRef of tcref: TyconRef * id: string + | RecdFieldRef of tyconRef: TyconRef * fieldName: string override ToString: unit -> string @@ -2990,7 +2990,7 @@ type Measure = | Var of typar: Typar /// A constant, leaf unit-of-measure such as 'kg' or 'm' - | Con of tyconRef: TyconRef + | Const of tyconRef: TyconRef /// A product of two units of measure | Prod of measure1: Measure * measure2: Measure @@ -3688,7 +3688,7 @@ type ObjExprMethod = type SlotSig = | TSlotSig of methodName: string * - implementedType: TType * + declaringType: TType * classTypars: Typars * methodTypars: Typars * formalParams: SlotParam list list * @@ -3709,7 +3709,7 @@ type SlotSig = member FormalReturnType: TType option /// The (instantiated) type which the slot is logically a part of - member ImplementedType: TType + member DeclaringType: TType /// The method type parameters of the slot member MethodTypars: Typars diff --git a/src/Compiler/TypedTree/TypedTreeBasics.fs b/src/Compiler/TypedTree/TypedTreeBasics.fs index 1ec0b619604..63a45fb9b9a 100644 --- a/src/Compiler/TypedTree/TypedTreeBasics.fs +++ b/src/Compiler/TypedTree/TypedTreeBasics.fs @@ -93,24 +93,24 @@ let mkRawStructTupleTy tys = TType_tuple (tupInfoStruct, tys) // Equality relations on locally defined things //--------------------------------------------------------------------------- -let typarEq (lv1: Typar) (lv2: Typar) = (lv1.Stamp = lv2.Stamp) +let typarEq (tp1: Typar) (tp2: Typar) = (tp1.Stamp = tp2.Stamp) /// Equality on type variables, implemented as reference equality. This should be equivalent to using typarEq. let typarRefEq (tp1: Typar) (tp2: Typar) = (tp1 === tp2) /// Equality on value specs, implemented as reference equality -let valEq (lv1: Val) (lv2: Val) = (lv1 === lv2) +let valEq (v1: Val) (v2: Val) = (v1 === v2) /// Equality on CCU references, implemented as reference equality except when unresolved -let ccuEq (mv1: CcuThunk) (mv2: CcuThunk) = - (mv1 === mv2) || - (if mv1.IsUnresolvedReference || mv2.IsUnresolvedReference then - mv1.AssemblyName = mv2.AssemblyName +let ccuEq (ccu1: CcuThunk) (ccu2: CcuThunk) = + (ccu1 === ccu2) || + (if ccu1.IsUnresolvedReference || ccu2.IsUnresolvedReference then + ccu1.AssemblyName = ccu2.AssemblyName else - mv1.Contents === mv2.Contents) + ccu1.Contents === ccu2.Contents) /// For dereferencing in the middle of a pattern -let (|ValDeref|) (vr: ValRef) = vr.Deref +let (|ValDeref|) (vref: ValRef) = vref.Deref //-------------------------------------------------------------------------- // Make references to TAST items diff --git a/src/Compiler/TypedTree/TypedTreeBasics.fsi b/src/Compiler/TypedTree/TypedTreeBasics.fsi index fe4930a71d7..e739aec4062 100644 --- a/src/Compiler/TypedTree/TypedTreeBasics.fsi +++ b/src/Compiler/TypedTree/TypedTreeBasics.fsi @@ -61,19 +61,19 @@ val mkRawRefTupleTy: tys: TTypes -> TType val mkRawStructTupleTy: tys: TTypes -> TType -val typarEq: lv1: Typar -> lv2: Typar -> bool +val typarEq: tp1: Typar -> tp2: Typar -> bool /// Equality on type variables, implemented as reference equality. This should be equivalent to using typarEq. val typarRefEq: tp1: Typar -> tp2: Typar -> bool /// Equality on value specs, implemented as reference equality -val valEq: lv1: Val -> lv2: Val -> bool +val valEq: v1: Val -> v2: Val -> bool /// Equality on CCU references, implemented as reference equality except when unresolved -val ccuEq: mv1: CcuThunk -> mv2: CcuThunk -> bool +val ccuEq: ccu1: CcuThunk -> ccu2: CcuThunk -> bool /// For dereferencing in the middle of a pattern -val (|ValDeref|): vr: ValRef -> Val +val (|ValDeref|): vref: ValRef -> Val val mkRecdFieldRef: tcref: TyconRef -> f: string -> RecdFieldRef diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index cef7fe70b74..8229107c74a 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -45,32 +45,32 @@ type TyparMap<'T> = | TPMap of StampMap<'T> member tm.Item - with get (v: Typar) = + with get (tp: Typar) = let (TPMap m) = tm - m[v.Stamp] + m[tp.Stamp] - member tm.ContainsKey (v: Typar) = + member tm.ContainsKey (tp: Typar) = let (TPMap m) = tm - m.ContainsKey(v.Stamp) + m.ContainsKey(tp.Stamp) - member tm.TryFind (v: Typar) = + member tm.TryFind (tp: Typar) = let (TPMap m) = tm - m.TryFind(v.Stamp) + m.TryFind(tp.Stamp) - member tm.Add (v: Typar, x) = + member tm.Add (tp: Typar, x) = let (TPMap m) = tm - TPMap (m.Add(v.Stamp, x)) + TPMap (m.Add(tp.Stamp, x)) static member Empty: TyparMap<'T> = TPMap Map.empty [] type TyconRefMap<'T>(imap: StampMap<'T>) = - member m.Item with get (v: TyconRef) = imap[v.Stamp] - member m.TryFind (v: TyconRef) = imap.TryFind v.Stamp - member m.ContainsKey (v: TyconRef) = imap.ContainsKey v.Stamp - member m.Add (v: TyconRef) x = TyconRefMap (imap.Add (v.Stamp, x)) - member m.Remove (v: TyconRef) = TyconRefMap (imap.Remove v.Stamp) - member m.IsEmpty = imap.IsEmpty + member _.Item with get (tcref: TyconRef) = imap[tcref.Stamp] + member _.TryFind (tcref: TyconRef) = imap.TryFind tcref.Stamp + member _.ContainsKey (tcref: TyconRef) = imap.ContainsKey tcref.Stamp + member _.Add (tcref: TyconRef) x = TyconRefMap (imap.Add (tcref.Stamp, x)) + member _.Remove (tcref: TyconRef) = TyconRefMap (imap.Remove tcref.Stamp) + member _.IsEmpty = imap.IsEmpty static member Empty: TyconRefMap<'T> = TyconRefMap Map.empty static member OfList vs = (vs, TyconRefMap<'T>.Empty) ||> List.foldBack (fun (x, y) acc -> acc.Add x y) @@ -79,14 +79,14 @@ type TyconRefMap<'T>(imap: StampMap<'T>) = [] type ValMap<'T>(imap: StampMap<'T>) = - member m.Contents = imap - member m.Item with get (v: Val) = imap[v.Stamp] - member m.TryFind (v: Val) = imap.TryFind v.Stamp - member m.ContainsVal (v: Val) = imap.ContainsKey v.Stamp - member m.Add (v: Val) x = ValMap (imap.Add(v.Stamp, x)) - member m.Remove (v: Val) = ValMap (imap.Remove(v.Stamp)) + member _.Contents = imap + member _.Item with get (v: Val) = imap[v.Stamp] + member _.TryFind (v: Val) = imap.TryFind v.Stamp + member _.ContainsVal (v: Val) = imap.ContainsKey v.Stamp + member _.Add (v: Val) x = ValMap (imap.Add(v.Stamp, x)) + member _.Remove (v: Val) = ValMap (imap.Remove(v.Stamp)) static member Empty = ValMap<'T> Map.empty - member m.IsEmpty = imap.IsEmpty + member _.IsEmpty = imap.IsEmpty static member OfList vs = (vs, ValMap<'T>.Empty) ||> List.foldBack (fun (x, y) acc -> acc.Add x y) //-------------------------------------------------------------------------- @@ -207,11 +207,11 @@ let rec remapTypeAux (tyenv: Remap) (ty: TType) = if tupInfo === tupInfoR && l === lR then ty else TType_tuple (tupInfoR, lR) - | TType_fun (d, r, flags) as ty -> - let dR = remapTypeAux tyenv d - let rR = remapTypeAux tyenv r - if d === dR && r === rR then ty else - TType_fun (dR, rR, flags) + | TType_fun (domainTy, rangeTy, flags) as ty -> + let domainTyR = remapTypeAux tyenv domainTy + let retTyR = remapTypeAux tyenv rangeTy + if domainTy === domainTyR && rangeTy === retTyR then ty else + TType_fun (domainTyR, retTyR, flags) | TType_forall (tps, ty) -> let tpsR, tyenv = copyAndRemapAndBindTypars tyenv tps @@ -224,9 +224,9 @@ let rec remapTypeAux (tyenv: Remap) (ty: TType) = and remapMeasureAux tyenv unt = match unt with | Measure.One -> unt - | Measure.Con tcref -> + | Measure.Const tcref -> match tyenv.tyconRefRemap.TryFind tcref with - | Some tcref -> Measure.Con tcref + | Some tcref -> Measure.Const tcref | None -> unt | Measure.Prod(u1, u2) -> Measure.Prod(remapMeasureAux tyenv u1, remapMeasureAux tyenv u2) | Measure.RationalPower(u, q) -> Measure.RationalPower(remapMeasureAux tyenv u, q) @@ -235,8 +235,8 @@ and remapMeasureAux tyenv unt = match tp.Solution with | None -> match ListAssoc.tryFind typarEq tp tyenv.tpinst with - | Some v -> - match v with + | Some tpTy -> + match tpTy with | TType_measure unt -> unt | _ -> failwith "remapMeasureAux: incorrect kinds" | None -> unt @@ -257,10 +257,10 @@ and remapTyparConstraintsAux tyenv cs = Some(TyparConstraint.MayResolveMember (remapTraitInfo tyenv traitInfo, m)) | TyparConstraint.DefaultsTo(priority, ty, m) -> Some(TyparConstraint.DefaultsTo(priority, remapTypeAux tyenv ty, m)) - | TyparConstraint.IsEnum(uty, m) -> - Some(TyparConstraint.IsEnum(remapTypeAux tyenv uty, m)) - | TyparConstraint.IsDelegate(uty1, uty2, m) -> - Some(TyparConstraint.IsDelegate(remapTypeAux tyenv uty1, remapTypeAux tyenv uty2, m)) + | TyparConstraint.IsEnum(underlyingTy, m) -> + Some(TyparConstraint.IsEnum(remapTypeAux tyenv underlyingTy, m)) + | TyparConstraint.IsDelegate(argTys, retTy, m) -> + Some(TyparConstraint.IsDelegate(remapTypeAux tyenv argTys, remapTypeAux tyenv retTy, m)) | TyparConstraint.SimpleChoice(tys, m) -> Some(TyparConstraint.SimpleChoice(remapTypesAux tyenv tys, m)) | TyparConstraint.SupportsComparison _ @@ -443,7 +443,7 @@ let reduceTyconRefAbbrevMeasureable (tcref: TyconRef) = let rec stripUnitEqnsFromMeasureAux canShortcut unt = match stripUnitEqnsAux canShortcut unt with - | Measure.Con tcref when tcref.IsTypeAbbrev -> + | Measure.Const tcref when tcref.IsTypeAbbrev -> stripUnitEqnsFromMeasureAux canShortcut (reduceTyconRefAbbrevMeasureable tcref) | m -> m @@ -456,7 +456,7 @@ let stripUnitEqnsFromMeasure m = stripUnitEqnsFromMeasureAux false m /// What is the contribution of unit-of-measure constant ucref to unit-of-measure expression measure? let rec MeasureExprConExponent g abbrev ucref unt = match (if abbrev then stripUnitEqnsFromMeasure unt else stripUnitEqns unt) with - | Measure.Con ucrefR -> if tyconRefEq g ucrefR ucref then OneRational else ZeroRational + | Measure.Const ucrefR -> if tyconRefEq g ucrefR ucref then OneRational else ZeroRational | Measure.Inv untR -> NegRational(MeasureExprConExponent g abbrev ucref untR) | Measure.Prod(unt1, unt2) -> AddRational(MeasureExprConExponent g abbrev ucref unt1) (MeasureExprConExponent g abbrev ucref unt2) | Measure.RationalPower(untR, q) -> MulRational (MeasureExprConExponent g abbrev ucref untR) q @@ -466,7 +466,7 @@ let rec MeasureExprConExponent g abbrev ucref unt = /// after remapping tycons? let rec MeasureConExponentAfterRemapping g r ucref unt = match stripUnitEqnsFromMeasure unt with - | Measure.Con ucrefR -> if tyconRefEq g (r ucrefR) ucref then OneRational else ZeroRational + | Measure.Const ucrefR -> if tyconRefEq g (r ucrefR) ucref then OneRational else ZeroRational | Measure.Inv untR -> NegRational(MeasureConExponentAfterRemapping g r ucref untR) | Measure.Prod(unt1, unt2) -> AddRational(MeasureConExponentAfterRemapping g r ucref unt1) (MeasureConExponentAfterRemapping g r ucref unt2) | Measure.RationalPower(untR, q) -> MulRational (MeasureConExponentAfterRemapping g r ucref untR) q @@ -511,7 +511,7 @@ let ListMeasureVarOccsWithNonZeroExponents untexpr = let ListMeasureConOccsWithNonZeroExponents g eraseAbbrevs untexpr = let rec gather acc unt = match (if eraseAbbrevs then stripUnitEqnsFromMeasure unt else stripUnitEqns unt) with - | Measure.Con c -> + | Measure.Const c -> if List.exists (fun (cR, _) -> tyconRefEq g c cR) acc then acc else let e = MeasureExprConExponent g eraseAbbrevs c untexpr if e = ZeroRational then acc else (c, e) :: acc @@ -526,7 +526,7 @@ let ListMeasureConOccsWithNonZeroExponents g eraseAbbrevs untexpr = let ListMeasureConOccsAfterRemapping g r unt = let rec gather acc unt = match stripUnitEqnsFromMeasure unt with - | Measure.Con c -> if List.exists (tyconRefEq g (r c)) acc then acc else r c :: acc + | Measure.Const c -> if List.exists (tyconRefEq g (r c)) acc then acc else r c :: acc | Measure.Prod(unt1, unt2) -> gather (gather acc unt1) unt2 | Measure.RationalPower(untR, _) -> gather acc untR | Measure.Inv untR -> gather acc untR @@ -552,8 +552,8 @@ let ProdMeasures ms = | [] -> Measure.One | m :: ms -> List.foldBack MeasureProdOpt ms m -let isDimensionless g tyarg = - match stripTyparEqns tyarg with +let isDimensionless g ty = + match stripTyparEqns ty with | TType_measure unt -> isNil (ListMeasureVarOccsWithNonZeroExponents unt) && isNil (ListMeasureConOccsWithNonZeroExponents g true unt) @@ -581,7 +581,7 @@ let normalizeMeasure g ms = match vs, cs with | [], [] -> Measure.One | [(v, e)], [] when e = OneRational -> Measure.Var v - | vs, cs -> List.foldBack (fun (v, e) -> fun m -> Measure.Prod (Measure.RationalPower (Measure.Var v, e), m)) vs (List.foldBack (fun (c, e) -> fun m -> Measure.Prod (Measure.RationalPower (Measure.Con c, e), m)) cs Measure.One) + | vs, cs -> List.foldBack (fun (v, e) -> fun m -> Measure.Prod (Measure.RationalPower (Measure.Var v, e), m)) vs (List.foldBack (fun (c, e) -> fun m -> Measure.Prod (Measure.RationalPower (Measure.Const c, e), m)) cs Measure.One) let tryNormalizeMeasureInType g ty = match ty with @@ -789,8 +789,8 @@ let rec stripTyEqnsAndErase eraseFuncAndTuple (g: TcGlobals) ty = else ty - | TType_fun(a, b, flags) when eraseFuncAndTuple -> - TType_app(g.fastFunc_tcr, [ a; b ], flags) + | TType_fun(domainTy, rangeTy, flags) when eraseFuncAndTuple -> + TType_app(g.fastFunc_tcr, [ domainTy; rangeTy ], flags) | TType_tuple(tupInfo, l) when eraseFuncAndTuple -> mkCompiledTupleTy g (evalTupInfoIsStruct tupInfo) l @@ -816,7 +816,7 @@ let rec stripExnEqns (eref: TyconRef) = let primDestForallTy g ty = ty |> stripTyEqns g |> (function TType_forall (tyvs, tau) -> (tyvs, tau) | _ -> failwith "primDestForallTy: not a forall type") -let destFunTy g ty = ty |> stripTyEqns g |> (function TType_fun (tyv, tau, _) -> (tyv, tau) | _ -> failwith "destFunTy: not a function type") +let destFunTy g ty = ty |> stripTyEqns g |> (function TType_fun (domainTy, rangeTy, _) -> (domainTy, rangeTy) | _ -> failwith "destFunTy: not a function type") let destAnyTupleTy g ty = ty |> stripTyEqns g |> (function TType_tuple (tupInfo, l) -> tupInfo, l | _ -> failwith "destAnyTupleTy: not a tuple type") @@ -880,7 +880,7 @@ let argsOfAppTy g ty = ty |> stripTyEqns g |> (function TType_app(_, tinst, _) - let tryDestTyparTy g ty = ty |> stripTyEqns g |> (function TType_var (v, _) -> ValueSome v | _ -> ValueNone) -let tryDestFunTy g ty = ty |> stripTyEqns g |> (function TType_fun (tyv, tau, _) -> ValueSome(tyv, tau) | _ -> ValueNone) +let tryDestFunTy g ty = ty |> stripTyEqns g |> (function TType_fun (domainTy, rangeTy, _) -> ValueSome(domainTy, rangeTy) | _ -> ValueNone) let tryTcrefOfAppTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref, _, _) -> ValueSome tcref | _ -> ValueNone) @@ -900,14 +900,14 @@ let tryNiceEntityRefOfTy ty = let ty = stripTyparEqnsAux false ty match ty with | TType_app (tcref, _, _) -> ValueSome tcref - | TType_measure (Measure.Con tcref) -> ValueSome tcref + | TType_measure (Measure.Const tcref) -> ValueSome tcref | _ -> ValueNone let tryNiceEntityRefOfTyOption ty = let ty = stripTyparEqnsAux false ty match ty with | TType_app (tcref, _, _) -> Some tcref - | TType_measure (Measure.Con tcref) -> Some tcref + | TType_measure (Measure.Const tcref) -> Some tcref | _ -> None let mkInstForAppTy g ty = @@ -931,12 +931,12 @@ let convertToTypeWithMetadataIfPossible g ty = // TType modifications //--------------------------------------------------------------------------- -let stripMeasuresFromTType g tt = - match tt with - | TType_app(a, b, flags) -> - let bR = b |> List.filter (isMeasureTy g >> not) - TType_app(a, bR, flags) - | _ -> tt +let stripMeasuresFromTy g ty = + match ty with + | TType_app(tcref, tinst, flags) -> + let tinstR = tinst |> List.filter (isMeasureTy g >> not) + TType_app(tcref, tinstR, flags) + | _ -> ty //--------------------------------------------------------------------------- // Equivalence of types up to alpha-equivalence @@ -990,30 +990,29 @@ and traitKeysAEquivAux erasureFlag g aenv witnessInfo1 witnessInfo2 = and returnTypesAEquivAux erasureFlag g aenv retTy retTy2 = match retTy, retTy2 with | None, None -> true - | Some t1, Some t2 -> typeAEquivAux erasureFlag g aenv t1 t2 + | Some ty1, Some ty2 -> typeAEquivAux erasureFlag g aenv ty1 ty2 | _ -> false - and typarConstraintsAEquivAux erasureFlag g aenv tpc1 tpc2 = match tpc1, tpc2 with - | TyparConstraint.CoercesTo(acty, _), - TyparConstraint.CoercesTo(fcty, _) -> - typeAEquivAux erasureFlag g aenv acty fcty + | TyparConstraint.CoercesTo(tgtTy1, _), + TyparConstraint.CoercesTo(tgtTy2, _) -> + typeAEquivAux erasureFlag g aenv tgtTy1 tgtTy2 | TyparConstraint.MayResolveMember(trait1, _), TyparConstraint.MayResolveMember(trait2, _) -> traitsAEquivAux erasureFlag g aenv trait1 trait2 - | TyparConstraint.DefaultsTo(_, acty, _), - TyparConstraint.DefaultsTo(_, fcty, _) -> - typeAEquivAux erasureFlag g aenv acty fcty + | TyparConstraint.DefaultsTo(_, dfltTy1, _), + TyparConstraint.DefaultsTo(_, dfltTy2, _) -> + typeAEquivAux erasureFlag g aenv dfltTy1 dfltTy2 - | TyparConstraint.IsEnum(uty1, _), TyparConstraint.IsEnum(uty2, _) -> - typeAEquivAux erasureFlag g aenv uty1 uty2 + | TyparConstraint.IsEnum(underlyingTy1, _), TyparConstraint.IsEnum(underlyingTy2, _) -> + typeAEquivAux erasureFlag g aenv underlyingTy1 underlyingTy2 - | TyparConstraint.IsDelegate(aty1, bty1, _), TyparConstraint.IsDelegate(aty2, bty2, _) -> - typeAEquivAux erasureFlag g aenv aty1 aty2 && - typeAEquivAux erasureFlag g aenv bty1 bty2 + | TyparConstraint.IsDelegate(argTys1, retTy1, _), TyparConstraint.IsDelegate(argTys2, retTy2, _) -> + typeAEquivAux erasureFlag g aenv argTys1 argTys2 && + typeAEquivAux erasureFlag g aenv retTy1 retTy2 | TyparConstraint.SimpleChoice (tys1, _), TyparConstraint.SimpleChoice(tys2, _) -> ListSet.equals (typeAEquivAux erasureFlag g aenv) tys1 tys2 @@ -1036,9 +1035,9 @@ and typarsAEquivAux erasureFlag g (aenv: TypeEquivEnv) tps1 tps2 = let aenv = aenv.BindEquivTypars tps1 tps2 List.forall2 (typarConstraintSetsAEquivAux erasureFlag g aenv) tps1 tps2 -and tcrefAEquiv g aenv tc1 tc2 = - tyconRefEq g tc1 tc2 || - (match aenv.EquivTycons.TryFind tc1 with Some v -> tyconRefEq g v tc2 | None -> false) +and tcrefAEquiv g aenv tcref1 tcref2 = + tyconRefEq g tcref1 tcref2 || + (match aenv.EquivTycons.TryFind tcref1 with Some v -> tyconRefEq g v tcref2 | None -> false) and typeAEquivAux erasureFlag g aenv ty1 ty2 = let ty1 = stripTyEqnsWrtErasure erasureFlag g ty1 @@ -1052,27 +1051,27 @@ and typeAEquivAux erasureFlag g aenv ty1 ty2 = | TType_var (tp1, _), _ -> match aenv.EquivTypars.TryFind tp1 with - | Some v -> typeEquivAux erasureFlag g v ty2 + | Some tpTy1 -> typeEquivAux erasureFlag g tpTy1 ty2 | None -> false - | TType_app (tc1, b1, _), TType_app (tc2, b2, _) -> - tcrefAEquiv g aenv tc1 tc2 && - typesAEquivAux erasureFlag g aenv b1 b2 + | TType_app (tcref1, tinst1, _), TType_app (tcref2, tinst2, _) -> + tcrefAEquiv g aenv tcref1 tcref2 && + typesAEquivAux erasureFlag g aenv tinst1 tinst2 - | TType_ucase (UnionCaseRef(tc1, n1), b1), TType_ucase (UnionCaseRef(tc2, n2), b2) -> - n1=n2 && - tcrefAEquiv g aenv tc1 tc2 && - typesAEquivAux erasureFlag g aenv b1 b2 + | TType_ucase (UnionCaseRef(tcref1, ucase1), tinst1), TType_ucase (UnionCaseRef(tcref2, ucase2), tinst2) -> + ucase1=ucase2 && + tcrefAEquiv g aenv tcref1 tcref2 && + typesAEquivAux erasureFlag g aenv tinst1 tinst2 - | TType_tuple (s1, l1), TType_tuple (s2, l2) -> - structnessAEquiv s1 s2 && typesAEquivAux erasureFlag g aenv l1 l2 + | TType_tuple (tupInfo1, l1), TType_tuple (tupInfo2, l2) -> + structnessAEquiv tupInfo1 tupInfo2 && typesAEquivAux erasureFlag g aenv l1 l2 | TType_anon (anonInfo1, l1), TType_anon (anonInfo2, l2) -> anonInfoEquiv anonInfo1 anonInfo2 && typesAEquivAux erasureFlag g aenv l1 l2 - | TType_fun (dtys1, rty1, _), TType_fun (dtys2, retTy2, _) -> - typeAEquivAux erasureFlag g aenv dtys1 dtys2 && typeAEquivAux erasureFlag g aenv rty1 retTy2 + | TType_fun (domainTy1, rangeTy1, _), TType_fun (domainTy2, rangeTy2, _) -> + typeAEquivAux erasureFlag g aenv domainTy1 domainTy2 && typeAEquivAux erasureFlag g aenv rangeTy1 rangeTy2 | TType_measure m1, TType_measure m2 -> match erasureFlag with @@ -1081,7 +1080,6 @@ and typeAEquivAux erasureFlag g aenv ty1 ty2 = | _ -> false - and anonInfoEquiv (anonInfo1: AnonRecdTypeInfo) (anonInfo2: AnonRecdTypeInfo) = ccuEq anonInfo1.Assembly anonInfo2.Assembly && structnessAEquiv anonInfo1.TupInfo anonInfo2.TupInfo && @@ -1094,7 +1092,7 @@ and structnessAEquiv un1 un2 = and measureAEquiv g aenv un1 un2 = let vars1 = ListMeasureVarOccs un1 let trans tp1 = if aenv.EquivTypars.ContainsKey tp1 then destAnyParTy g aenv.EquivTypars[tp1] else tp1 - let remapTyconRef tc = if aenv.EquivTycons.ContainsKey tc then aenv.EquivTycons[tc] else tc + let remapTyconRef tcref = if aenv.EquivTycons.ContainsKey tcref then aenv.EquivTycons[tcref] else tcref let vars1R = List.map trans vars1 let vars2 = ListSet.subtract typarEq (ListMeasureVarOccs un2) vars1R let cons1 = ListMeasureConOccsAfterRemapping g remapTyconRef un1 @@ -1161,7 +1159,9 @@ let rec getErasedTypes g ty = //--------------------------------------------------------------------------- let valOrder = { new IComparer with member _.Compare(v1, v2) = compare v1.Stamp v2.Stamp } -let tyconOrder = { new IComparer with member _.Compare(tc1, tc2) = compare tc1.Stamp tc2.Stamp } + +let tyconOrder = { new IComparer with member _.Compare(tycon1, tycon2) = compare tycon1.Stamp tycon2.Stamp } + let recdFieldRefOrder = { new IComparer with member _.Compare(RecdFieldRef(tcref1, nm1), RecdFieldRef(tcref2, nm2)) = @@ -1180,8 +1180,8 @@ let unionCaseRefOrder = // Make some common types //--------------------------------------------------------------------------- -let mkFunTy (g: TcGlobals) d r = - TType_fun (d, r, g.knownWithoutNull) +let mkFunTy (g: TcGlobals) domainTy rangeTy = + TType_fun (domainTy, rangeTy, g.knownWithoutNull) let mkForallTy d r = TType_forall (d, r) @@ -1396,7 +1396,7 @@ let NormalizeDeclaredTyparsForEquiRecursiveInference g tps = type GeneralizedType = GeneralizedType of Typars * TType let mkGenericBindRhs g m generalizedTyparsForRecursiveBlock typeScheme bodyExpr = - let (GeneralizedType(generalizedTypars, tauType)) = typeScheme + let (GeneralizedType(generalizedTypars, tauTy)) = typeScheme // Normalize the generalized typars let generalizedTypars = NormalizeDeclaredTyparsForEquiRecursiveInference g generalizedTypars @@ -1414,7 +1414,7 @@ let mkGenericBindRhs g m generalizedTyparsForRecursiveBlock typeScheme bodyExpr // We record an expression node that indicates that a free choice can be made // for these. This expression node effectively binds the type variables. let freeChoiceTypars = ListSet.subtract typarEq generalizedTyparsForRecursiveBlock generalizedTypars - mkTypeLambda m generalizedTypars (mkTypeChoose m freeChoiceTypars bodyExpr, tauType) + mkTypeLambda m generalizedTypars (mkTypeChoose m freeChoiceTypars bodyExpr, tauTy) let isBeingGeneralized tp typeScheme = let (GeneralizedType(generalizedTypars, _)) = typeScheme @@ -1512,36 +1512,36 @@ let mkExnCaseFieldGet (e1, ecref, j, m) = let mkExnCaseFieldSet (e1, ecref, j, e2, m) = Expr.Op (TOp.ExnFieldSet (ecref, j), [], [e1;e2], m) -let mkDummyLambda (g: TcGlobals) (e: Expr, ety) = - let m = e.Range - mkLambda m (fst (mkCompGenLocal m "unitVar" g.unit_ty)) (e, ety) +let mkDummyLambda (g: TcGlobals) (bodyExpr: Expr, bodyExprTy) = + let m = bodyExpr.Range + mkLambda m (fst (mkCompGenLocal m "unitVar" g.unit_ty)) (bodyExpr, bodyExprTy) -let mkWhile (g: TcGlobals) (spWhile, marker, e1, e2, m) = - Expr.Op (TOp.While (spWhile, marker), [], [mkDummyLambda g (e1, g.bool_ty);mkDummyLambda g (e2, g.unit_ty)], m) +let mkWhile (g: TcGlobals) (spWhile, marker, guardExpr, bodyExpr, m) = + Expr.Op (TOp.While (spWhile, marker), [], [mkDummyLambda g (guardExpr, g.bool_ty);mkDummyLambda g (bodyExpr, g.unit_ty)], m) -let mkIntegerForLoop (g: TcGlobals) (spFor, spIn, v, e1, dir, e2, e3: Expr, m) = - Expr.Op (TOp.IntegerForLoop (spFor, spIn, dir), [], [mkDummyLambda g (e1, g.int_ty) ;mkDummyLambda g (e2, g.int_ty);mkLambda e3.Range v (e3, g.unit_ty)], m) +let mkIntegerForLoop (g: TcGlobals) (spFor, spIn, v, startExpr, dir, finishExpr, bodyExpr: Expr, m) = + Expr.Op (TOp.IntegerForLoop (spFor, spIn, dir), [], [mkDummyLambda g (startExpr, g.int_ty) ;mkDummyLambda g (finishExpr, g.int_ty);mkLambda bodyExpr.Range v (bodyExpr, g.unit_ty)], m) -let mkTryWith g (e1, vf, ef: Expr, vh, eh: Expr, m, ty, spTry, spWith) = - Expr.Op (TOp.TryWith (spTry, spWith), [ty], [mkDummyLambda g (e1, ty);mkLambda ef.Range vf (ef, ty);mkLambda eh.Range vh (eh, ty)], m) +let mkTryWith g (bodyExpr, filterVal, filterExpr: Expr, handlerVal, handlerExpr: Expr, m, ty, spTry, spWith) = + Expr.Op (TOp.TryWith (spTry, spWith), [ty], [mkDummyLambda g (bodyExpr, ty);mkLambda filterExpr.Range filterVal (filterExpr, ty);mkLambda handlerExpr.Range handlerVal (handlerExpr, ty)], m) -let mkTryFinally (g: TcGlobals) (e1, e2, m, ty, spTry, spFinally) = - Expr.Op (TOp.TryFinally (spTry, spFinally), [ty], [mkDummyLambda g (e1, ty);mkDummyLambda g (e2, g.unit_ty)], m) +let mkTryFinally (g: TcGlobals) (bodyExpr, finallyExpr, m, ty, spTry, spFinally) = + Expr.Op (TOp.TryFinally (spTry, spFinally), [ty], [mkDummyLambda g (bodyExpr, ty);mkDummyLambda g (finallyExpr, g.unit_ty)], m) let mkDefault (m, ty) = Expr.Const (Const.Zero, m, ty) -let mkValSet m v e = - Expr.Op (TOp.LValueOp (LSet, v), [], [e], m) +let mkValSet m vref e = + Expr.Op (TOp.LValueOp (LSet, vref), [], [e], m) -let mkAddrSet m v e = - Expr.Op (TOp.LValueOp (LByrefSet, v), [], [e], m) +let mkAddrSet m vref e = + Expr.Op (TOp.LValueOp (LByrefSet, vref), [], [e], m) -let mkAddrGet m v = - Expr.Op (TOp.LValueOp (LByrefGet, v), [], [], m) +let mkAddrGet m vref = + Expr.Op (TOp.LValueOp (LByrefGet, vref), [], [], m) -let mkValAddr m readonly v = - Expr.Op (TOp.LValueOp (LAddrOf readonly, v), [], [], m) +let mkValAddr m readonly vref = + Expr.Op (TOp.LValueOp (LAddrOf readonly, vref), [], [], m) //-------------------------------------------------------------------------- // Maps tracking extra information for values @@ -1682,9 +1682,9 @@ let tryDestForallTy g ty = let rec stripFunTy g ty = if isFunTy g ty then - let d, r = destFunTy g ty - let more, rty = stripFunTy g r - d :: more, rty + let domainTy, rangeTy = destFunTy g ty + let more, retTy = stripFunTy g rangeTy + domainTy :: more, retTy else [], ty let applyForallTy g ty tyargs = @@ -1696,23 +1696,24 @@ let reduceIteratedFunTy g ty args = if not (isFunTy g ty) then failwith "reduceIteratedFunTy" snd (destFunTy g ty)) ty args -let applyTyArgs g functy tyargs = - if isForallTy g functy then applyForallTy g functy tyargs else functy +let applyTyArgs g ty tyargs = + if isForallTy g ty then applyForallTy g ty tyargs else ty -let applyTys g functy (tyargs, argTys) = - let afterTyappTy = applyTyArgs g functy tyargs +let applyTys g funcTy (tyargs, argTys) = + let afterTyappTy = applyTyArgs g funcTy tyargs reduceIteratedFunTy g afterTyappTy argTys -let formalApplyTys g functy (tyargs, args) = +let formalApplyTys g funcTy (tyargs, args) = reduceIteratedFunTy g - (if isNil tyargs then functy else snd (destForallTy g functy)) + (if isNil tyargs then funcTy else snd (destForallTy g funcTy)) args let rec stripFunTyN g n ty = assert (n >= 0) if n > 0 && isFunTy g ty then let d, r = destFunTy g ty - let more, rty = stripFunTyN g (n-1) r in d :: more, rty + let more, retTy = stripFunTyN g (n-1) r + d :: more, retTy else [], ty let tryDestAnyTupleTy g ty = @@ -1796,10 +1797,10 @@ let destListTy (g: TcGlobals) ty = | ValueSome (tcref, [ty]) when tyconRefEq g tcref g.list_tcr_canon -> ty | _ -> failwith "destListTy" -let tyconRefEqOpt g tcOpt tc = - match tcOpt with +let tyconRefEqOpt g tcrefOpt tcref = + match tcrefOpt with | None -> false - | Some tc2 -> tyconRefEq g tc2 tc + | Some tcref2 -> tyconRefEq g tcref2 tcref let isStringTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref, _, _) -> tyconRefEq g tcref g.system_String_tcref | _ -> false) @@ -1830,13 +1831,13 @@ let isByrefTy g ty = let isInByrefTag g ty = ty |> stripTyEqns g |> (function TType_app(tcref, [], _) -> tyconRefEq g g.byrefkind_In_tcr tcref | _ -> false) let isInByrefTy g ty = ty |> stripTyEqns g |> (function - | TType_app(tcref, [_; tag], _) when g.byref2_tcr.CanDeref -> tyconRefEq g g.byref2_tcr tcref && isInByrefTag g tag + | TType_app(tcref, [_; tagTy], _) when g.byref2_tcr.CanDeref -> tyconRefEq g g.byref2_tcr tcref && isInByrefTag g tagTy | _ -> false) let isOutByrefTag g ty = ty |> stripTyEqns g |> (function TType_app(tcref, [], _) -> tyconRefEq g g.byrefkind_Out_tcr tcref | _ -> false) let isOutByrefTy g ty = ty |> stripTyEqns g |> (function - | TType_app(tcref, [_; tag], _) when g.byref2_tcr.CanDeref -> tyconRefEq g g.byref2_tcr tcref && isOutByrefTag g tag + | TType_app(tcref, [_; tagTy], _) when g.byref2_tcr.CanDeref -> tyconRefEq g g.byref2_tcr tcref && isOutByrefTag g tagTy | _ -> false) #if !NO_TYPEPROVIDERS @@ -2059,7 +2060,7 @@ let MemberIsExplicitImpl g (membInfo: ValMemberInfo) = membInfo.MemberFlags.IsOverrideOrExplicitImpl && match membInfo.ImplementedSlotSigs with | [] -> false - | slotsigs -> slotsigs |> List.forall (fun slotsig -> isInterfaceTy g slotsig.ImplementedType) + | slotsigs -> slotsigs |> List.forall (fun slotsig -> isInterfaceTy g slotsig.DeclaringType) let ValIsExplicitImpl g (v: Val) = match v.MemberInfo with @@ -2239,8 +2240,8 @@ and accFreeInTyparConstraint opts tpc acc = | TyparConstraint.MayResolveMember (traitInfo, _) -> accFreeInTrait opts traitInfo acc | TyparConstraint.DefaultsTo(_, defaultTy, _) -> accFreeInType opts defaultTy acc | TyparConstraint.SimpleChoice(tys, _) -> accFreeInTypes opts tys acc - | TyparConstraint.IsEnum(uty, _) -> accFreeInType opts uty acc - | TyparConstraint.IsDelegate(aty, bty, _) -> accFreeInType opts aty (accFreeInType opts bty acc) + | TyparConstraint.IsEnum(underlyingTy, _) -> accFreeInType opts underlyingTy acc + | TyparConstraint.IsDelegate(argTys, retTy, _) -> accFreeInType opts argTys (accFreeInType opts retTy acc) | TyparConstraint.SupportsComparison _ | TyparConstraint.SupportsEquality _ | TyparConstraint.SupportsNull _ @@ -2302,18 +2303,18 @@ and accFreeInType opts ty acc = | TType_anon (anonInfo, l) -> accFreeInTypes opts l (accFreeInTupInfo opts anonInfo.TupInfo acc) - | TType_app (tc, tinst, _) -> - let acc = accFreeTycon opts tc acc + | TType_app (tcref, tinst, _) -> + let acc = accFreeTycon opts tcref acc match tinst with | [] -> acc // optimization to avoid unneeded call | [h] -> accFreeInType opts h acc // optimization to avoid unneeded call | _ -> accFreeInTypes opts tinst acc - | TType_ucase (UnionCaseRef(tc, _), tinst) -> - accFreeInTypes opts tinst (accFreeTycon opts tc acc) + | TType_ucase (UnionCaseRef(tcref, _), tinst) -> + accFreeInTypes opts tinst (accFreeTycon opts tcref acc) - | TType_fun (d, r, _) -> - accFreeInType opts d (accFreeInType opts r acc) + | TType_fun (domainTy, rangeTy, _) -> + accFreeInType opts domainTy (accFreeInType opts rangeTy acc) | TType_var (r, _) -> accFreeTyparRef opts r acc @@ -2375,10 +2376,10 @@ and accFreeInTyparConstraintLeftToRight g cxFlag thruFlag acc tpc = accFreeInTypeLeftToRight g cxFlag thruFlag acc defaultTy | TyparConstraint.SimpleChoice(tys, _) -> accFreeInTypesLeftToRight g cxFlag thruFlag acc tys - | TyparConstraint.IsEnum(uty, _) -> - accFreeInTypeLeftToRight g cxFlag thruFlag acc uty - | TyparConstraint.IsDelegate(aty, bty, _) -> - accFreeInTypeLeftToRight g cxFlag thruFlag (accFreeInTypeLeftToRight g cxFlag thruFlag acc aty) bty + | TyparConstraint.IsEnum(underlyingTy, _) -> + accFreeInTypeLeftToRight g cxFlag thruFlag acc underlyingTy + | TyparConstraint.IsDelegate(argTys, retTy, _) -> + accFreeInTypeLeftToRight g cxFlag thruFlag (accFreeInTypeLeftToRight g cxFlag thruFlag acc argTys) retTy | TyparConstraint.SupportsComparison _ | TyparConstraint.SupportsEquality _ | TyparConstraint.SupportsNull _ @@ -2419,9 +2420,9 @@ and accFreeInTypeLeftToRight g cxFlag thruFlag acc ty = | TType_ucase (_, tinst) -> accFreeInTypesLeftToRight g cxFlag thruFlag acc tinst - | TType_fun (d, r, _) -> - let dacc = accFreeInTypeLeftToRight g cxFlag thruFlag acc d - accFreeInTypeLeftToRight g cxFlag thruFlag dacc r + | TType_fun (domainTy, rangeTy, _) -> + let dacc = accFreeInTypeLeftToRight g cxFlag thruFlag acc domainTy + accFreeInTypeLeftToRight g cxFlag thruFlag dacc rangeTy | TType_var (r, _) -> accFreeTyparRefLeftToRight g cxFlag thruFlag acc r @@ -2546,12 +2547,12 @@ let GetMemberTypeInMemberForm g memberFlags valReprInfo numEnclosingTypars ty m let paramArgInfos = match paramArgInfos, valReprInfo.ArgInfos with // static member and module value unit argument elimination - | [[(argType, _)]], [[]] -> - assert isUnitTy g argType + | [[(argTy, _)]], [[]] -> + assert isUnitTy g argTy [[]] // instance member unit argument elimination - | [[(argType, _)]], [[_objArg];[]] -> - assert isUnitTy g argType + | [[(argTy, _)]], [[_objArg];[]] -> + assert isUnitTy g argTy [[]] | _ -> paramArgInfos @@ -2770,10 +2771,10 @@ module PrettyTypes = let niceTypars, renaming = NewPrettyTypars [] ftps names // strip universal types for printing - let getTauStayTau t = - match t with + let getTauStayTau ty = + match ty with | TType_forall (_, tau) -> tau - | _ -> t + | _ -> ty let tauThings = mapTys getTauStayTau things let prettyThings = mapTys (instType renaming) tauThings @@ -2858,8 +2859,8 @@ module SimplifyTypes = let ty = stripTyparEqns ty let z = f z ty match ty with - | TType_forall (_, body) -> - foldTypeButNotConstraints f z body + | TType_forall (_, bodyTy) -> + foldTypeButNotConstraints f z bodyTy | TType_app (_, tys, _) | TType_ucase (_, tys) @@ -2867,8 +2868,8 @@ module SimplifyTypes = | TType_tuple (_, tys) -> List.fold (foldTypeButNotConstraints f) z tys - | TType_fun (s, t, _) -> - foldTypeButNotConstraints f (foldTypeButNotConstraints f z s) t + | TType_fun (domainTy, rangeTy, _) -> + foldTypeButNotConstraints f (foldTypeButNotConstraints f z domainTy) rangeTy | TType_var _ -> z @@ -3184,7 +3185,7 @@ let tyconRefToFullName (tcref:TyconRef) = seq { yield! namespaceParts; yield tcref.DisplayName } |> String.concat "." let rec qualifiedInterfaceImplementationNameAux g (x:TType) : string = - match stripMeasuresFromTType g (stripTyEqnsAndErase true g x) with + match stripMeasuresFromTy g (stripTyEqnsAndErase true g x) with | TType_app (a, [], _) -> tyconRefToFullName a @@ -3203,8 +3204,8 @@ let rec qualifiedInterfaceImplementationNameAux g (x:TType) : string = failwithf "unexpected: expected TType_app but got %O" (x.GetType()) /// for types in the global namespace, `global is prepended (note the backtick) -let qualifiedInterfaceImplementationName g (tt:TType) memberName = - let interfaceName = tt |> qualifiedInterfaceImplementationNameAux g +let qualifiedInterfaceImplementationName g (ty: TType) memberName = + let interfaceName = ty |> qualifiedInterfaceImplementationNameAux g sprintf "%s.%s" interfaceName memberName let qualifiedMangledNameOfTyconRef tcref nm = @@ -4951,7 +4952,7 @@ and accFreeInTest (opts: FreeVarOptions) discrim acc = | DecisionTreeTest.ArrayLength(_, ty) -> accFreeVarsInTy opts ty acc | DecisionTreeTest.Const _ | DecisionTreeTest.IsNull -> acc - | DecisionTreeTest.IsInst (srcty, tgty) -> accFreeVarsInTy opts srcty (accFreeVarsInTy opts tgty acc) + | DecisionTreeTest.IsInst (srcTy, tgtTy) -> accFreeVarsInTy opts srcTy (accFreeVarsInTy opts tgtTy acc) | DecisionTreeTest.ActivePatternCase (exp, tys, _, activePatIdentity, _, _) -> accFreeInExpr opts exp (accFreeVarsInTys opts tys @@ -5826,7 +5827,7 @@ and remapDecisionTree ctxt compgen tmenv x = | DecisionTreeTest.UnionCase (uc, tinst) -> DecisionTreeTest.UnionCase(remapUnionCaseRef tmenv.tyconRefRemap uc, remapTypes tmenv tinst) | DecisionTreeTest.ArrayLength (n, ty) -> DecisionTreeTest.ArrayLength(n, remapType tmenv ty) | DecisionTreeTest.Const _ -> test - | DecisionTreeTest.IsInst (srcty, tgty) -> DecisionTreeTest.IsInst (remapType tmenv srcty, remapType tmenv tgty) + | DecisionTreeTest.IsInst (srcTy, tgtTy) -> DecisionTreeTest.IsInst (remapType tmenv srcTy, remapType tmenv tgtTy) | DecisionTreeTest.IsNull -> DecisionTreeTest.IsNull | DecisionTreeTest.ActivePatternCase _ -> failwith "DecisionTreeTest.ActivePatternCase should only be used during pattern match compilation" | DecisionTreeTest.Error(m) -> DecisionTreeTest.Error(m) @@ -8597,8 +8598,8 @@ let rec typeEnc g (gtpsType, gtpsMethod) ty = else sprintf "System.Tuple%s"(tyargsEnc g (gtpsType, gtpsMethod) tys) - | TType_fun (f, x, _) -> - "Microsoft.FSharp.Core.FSharpFunc" + tyargsEnc g (gtpsType, gtpsMethod) [f;x] + | TType_fun (domainTy, rangeTy, _) -> + "Microsoft.FSharp.Core.FSharpFunc" + tyargsEnc g (gtpsType, gtpsMethod) [domainTy; rangeTy] | TType_var (typar, _) -> typarEnc g (gtpsType, gtpsMethod) typar @@ -8869,22 +8870,22 @@ let canUseUnboxFast g m ty = // // No sequence point is generated for this expression form as this function is only // used for compiler-generated code. -let mkIsInstConditional g m tgty vinputExpr v e2 e3 = +let mkIsInstConditional g m tgtTy vinputExpr v e2 e3 = - if canUseTypeTestFast g tgty && isRefTy g tgty then + if canUseTypeTestFast g tgtTy && isRefTy g tgtTy then let mbuilder = MatchBuilder(DebugPointAtBinding.NoneAtInvisible, m) let tg2 = mbuilder.AddResultTarget(e2) let tg3 = mbuilder.AddResultTarget(e3) let dtree = TDSwitch(exprForVal m v, [TCase(DecisionTreeTest.IsNull, tg3)], Some tg2, m) let expr = mbuilder.Close(dtree, m, tyOfExpr g e2) - mkCompGenLet m v (mkIsInst tgty vinputExpr m) expr + mkCompGenLet m v (mkIsInst tgtTy vinputExpr m) expr else let mbuilder = MatchBuilder(DebugPointAtBinding.NoneAtInvisible, m) - let tg2 = TDSuccess([mkCallUnbox g m tgty vinputExpr], mbuilder.AddTarget(TTarget([v], e2, None))) + let tg2 = TDSuccess([mkCallUnbox g m tgtTy vinputExpr], mbuilder.AddTarget(TTarget([v], e2, None))) let tg3 = mbuilder.AddResultTarget(e3) - let dtree = TDSwitch(vinputExpr, [TCase(DecisionTreeTest.IsInst(tyOfExpr g vinputExpr, tgty), tg2)], Some tg3, m) + let dtree = TDSwitch(vinputExpr, [TCase(DecisionTreeTest.IsInst(tyOfExpr g vinputExpr, tgtTy), tg2)], Some tg3, m) let expr = mbuilder.Close(dtree, m, tyOfExpr g e2) expr @@ -10114,7 +10115,7 @@ let (|ResumableCodeInvoke|_|) g expr = let ComputeUseMethodImpl g (v: Val) = v.ImplementedSlotSigs |> List.exists (fun slotsig -> - let oty = slotsig.ImplementedType + let oty = slotsig.DeclaringType let otcref = tcrefOfAppTy g oty let tcref = v.MemberApparentEntity diff --git a/src/Compiler/TypedTree/TypedTreeOps.fsi b/src/Compiler/TypedTree/TypedTreeOps.fsi index 1a89375f930..5d27bff7fbc 100755 --- a/src/Compiler/TypedTree/TypedTreeOps.fsi +++ b/src/Compiler/TypedTree/TypedTreeOps.fsi @@ -845,7 +845,7 @@ val isDimensionless: TcGlobals -> TType -> bool // TType modifications and comparisons //--------------------------------------------------------------------------- -val stripMeasuresFromTType: TcGlobals -> TType -> TType +val stripMeasuresFromTy: TcGlobals -> TType -> TType //------------------------------------------------------------------------- // Equivalence of types (up to substitution of type variables in the left-hand type) diff --git a/src/Compiler/TypedTree/TypedTreePickle.fs b/src/Compiler/TypedTree/TypedTreePickle.fs index 3f5ba37afde..57c557d2b8a 100644 --- a/src/Compiler/TypedTree/TypedTreePickle.fs +++ b/src/Compiler/TypedTree/TypedTreePickle.fs @@ -1575,7 +1575,7 @@ let p_measure_one = p_byte 4 // Pickle a unit-of-measure variable or constructor let p_measure_varcon unt st = match unt with - | Measure.Con tcref -> p_measure_con tcref st + | Measure.Const tcref -> p_measure_con tcref st | Measure.Var v -> p_measure_var v st | _ -> pfailwith st "p_measure_varcon: expected measure variable or constructor" @@ -1604,7 +1604,7 @@ let rec p_measure_power unt q st = let rec p_normalized_measure unt st = let unt = stripUnitEqnsAux false unt match unt with - | Measure.Con tcref -> p_measure_con tcref st + | Measure.Const tcref -> p_measure_con tcref st | Measure.Inv x -> p_byte 1 st; p_normalized_measure x st | Measure.Prod(x1, x2) -> p_byte 2 st; p_normalized_measure x1 st; p_normalized_measure x2 st | Measure.Var v -> p_measure_var v st @@ -1625,7 +1625,7 @@ let u_rational st = let rec u_measure_expr st = let tag = u_byte st match tag with - | 0 -> let a = u_tcref st in Measure.Con a + | 0 -> let a = u_tcref st in Measure.Const a | 1 -> let a = u_measure_expr st in Measure.Inv a | 2 -> let a, b = u_tup2 u_measure_expr u_measure_expr st in Measure.Prod (a, b) | 3 -> let a = u_tpref st in Measure.Var a @@ -2437,7 +2437,7 @@ and p_dtree_discrim x st = | DecisionTreeTest.UnionCase (ucref, tinst) -> p_byte 0 st; p_tup2 p_ucref p_tys (ucref, tinst) st | DecisionTreeTest.Const c -> p_byte 1 st; p_const c st | DecisionTreeTest.IsNull -> p_byte 2 st - | DecisionTreeTest.IsInst (srcty, tgty) -> p_byte 3 st; p_ty srcty st; p_ty tgty st + | DecisionTreeTest.IsInst (srcTy, tgtTy) -> p_byte 3 st; p_ty srcTy st; p_ty tgtTy st | DecisionTreeTest.ArrayLength (n, ty) -> p_byte 4 st; p_tup2 p_int p_ty (n, ty) st | DecisionTreeTest.ActivePatternCase _ -> pfailwith st "DecisionTreeTest.ActivePatternCase: only used during pattern match compilation" | DecisionTreeTest.Error _ -> pfailwith st "DecisionTreeTest.Error: only used during pattern match compilation" diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index ebc1d2cb28c..2238c89041b 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -141,15 +141,15 @@ type BindingSet = BindingSetPreAttrs of range * bool * bool * (SynAttributes -> let mkClassMemberLocalBindings(isStatic, initialRangeOpt, attrs, vis, BindingSetPreAttrs(_, isRec, isUse, declsPreAttrs, bindingSetRange)) = let ignoredFreeAttrs, decls = declsPreAttrs attrs vis - let wholeRange = + let mWhole = match initialRangeOpt with | None -> bindingSetRange | Some m -> unionRanges m bindingSetRange // decls could have a leading attribute |> fun m -> (m, decls) ||> unionRangeWithListBy (fun (SynBinding(range = m)) -> m) - if not (isNil ignoredFreeAttrs) then warning(Error(FSComp.SR.parsAttributesIgnored(), wholeRange)); - if isUse then errorR(Error(FSComp.SR.parsUseBindingsIllegalInImplicitClassConstructors(), wholeRange)) - SynMemberDefn.LetBindings (decls, isStatic, isRec, wholeRange) + if not (isNil ignoredFreeAttrs) then warning(Error(FSComp.SR.parsAttributesIgnored(), mWhole)); + if isUse then errorR(Error(FSComp.SR.parsUseBindingsIllegalInImplicitClassConstructors(), mWhole)) + SynMemberDefn.LetBindings (decls, isStatic, isRec, mWhole) let mkLocalBindings (mWhole, BindingSetPreAttrs(_, isRec, isUse, declsPreAttrs, _), mIn, body: SynExpr) = let ignoredFreeAttrs, decls = declsPreAttrs [] None @@ -830,12 +830,12 @@ moduleSpfn: _xmlDoc.MarkAsInvalid() let attrs = $1 @ cas let xmlDoc = grabXmlDoc(parseState, $1, 1) - let mTc = + let mDefn = (d3, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) |> unionRanges range |> unionRangeWithXmlDoc xmlDoc - let tc = (SynTypeDefnSig(SynComponentInfo(attrs, a, cs, b, xmlDoc, d, d2, d3), equalsRange, typeRepr, withKeyword, members, mTc)) - let m = (mTc, $5) ||> unionRangeWithListBy (fun (a: SynTypeDefnSig) -> a.Range) |> unionRanges (rhs parseState 3) + let tc = SynTypeDefnSig(SynComponentInfo(attrs, a, cs, b, xmlDoc, d, d2, d3), equalsRange, typeRepr, withKeyword, members, mDefn) + let m = (mDefn, $5) ||> unionRangeWithListBy (fun (a: SynTypeDefnSig) -> a.Range) |> unionRanges (rhs parseState 3) SynModuleSigDecl.Types (tc :: $5, m) } | opt_attributes opt_declVisibility exconSpfn @@ -844,8 +844,8 @@ moduleSpfn: let xmlDoc = grabXmlDoc(parseState, $1, 1) let mDefnReprWithAttributes = (d2, $1) ||> unionRangeWithListBy (fun a -> a.Range) |> unionRangeWithXmlDoc xmlDoc let mWhole = (mDefnReprWithAttributes, members) ||> unionRangeWithListBy (fun (m: SynMemberSig) -> m.Range) - let ec = SynExceptionSig(SynExceptionDefnRepr($1@cas, a, b, xmlDoc, d, mDefnReprWithAttributes), withKeyword, members, mWhole) - SynModuleSigDecl.Exception(ec, mWhole) } + let synExnDefn = SynExceptionSig(SynExceptionDefnRepr($1@cas, a, b, xmlDoc, d, mDefnReprWithAttributes), withKeyword, members, mWhole) + SynModuleSigDecl.Exception(synExnDefn, mWhole) } | openDecl { SynModuleSigDecl.Open($1, (rhs parseState 1)) } @@ -901,7 +901,8 @@ tyconSpfnList: | AND tyconSpfn tyconSpfnList { let xmlDoc = grabXmlDoc(parseState, [], 1) let tyconSpfn = - let (SynTypeDefnSig(SynComponentInfo (a, typars, c, lid, _xmlDoc, fixity, vis, rangeOfLid) as componentInfo, equalsRange, typeRepr, withKeyword, members, range)) = $2 + let (SynTypeDefnSig(componentInfo, equalsRange, typeRepr, withKeyword, members, range)) = $2 + let (SynComponentInfo(a, typars, c, lid, _xmlDoc, fixity, vis, mLongId)) = componentInfo if xmlDoc.IsEmpty then if _xmlDoc.IsEmpty then $2 else let range = unionRangeWithXmlDoc _xmlDoc range @@ -910,7 +911,8 @@ tyconSpfnList: else _xmlDoc.MarkAsInvalid() let range = unionRangeWithXmlDoc xmlDoc range - SynTypeDefnSig(SynComponentInfo (a, typars, c, lid, xmlDoc, fixity, vis, rangeOfLid), equalsRange, typeRepr, withKeyword, members, range) + let componentInfo = SynComponentInfo (a, typars, c, lid, xmlDoc, fixity, vis, mLongId) + SynTypeDefnSig(componentInfo, equalsRange, typeRepr, withKeyword, members, range) tyconSpfn :: $3 } | @@ -920,9 +922,9 @@ tyconSpfnList: /* A type definition in a signature */ tyconSpfn: | typeNameInfo EQUALS tyconSpfnRhsBlock - { let lhsm = rhs parseState 1 + { let mLhs = rhs parseState 1 let mEquals = rhs parseState 2 - $3 lhsm $1 (Some mEquals) } + $3 mLhs $1 (Some mEquals) } | typeNameInfo opt_classSpfn { let mWithKwd, members = $2 let (SynComponentInfo(range=range)) = $1 @@ -949,22 +951,22 @@ tyconSpfnRhsBlock: /* representation. */ | OBLOCKBEGIN tyconSpfnRhs opt_OBLOCKSEP classSpfnMembers opt_classSpfn oblockend opt_classSpfn { let m = lhs parseState - (fun lhsm nameInfo mEquals -> + (fun mLhs nameInfo mEquals -> let members = $4 @ (snd $5) - $2 lhsm nameInfo mEquals (checkForMultipleAugmentations m members (snd $7))) } + $2 mLhs nameInfo mEquals (checkForMultipleAugmentations m members (snd $7))) } | tyconSpfnRhs opt_classSpfn { let m = lhs parseState - (fun lhsm nameInfo mEquals -> + (fun mLhs nameInfo mEquals -> let _, members = $2 - $1 lhsm nameInfo mEquals members) } + $1 mLhs nameInfo mEquals members) } /* The right-hand-side of a type definition in a signature */ tyconSpfnRhs: | tyconDefnOrSpfnSimpleRepr - { (fun lhsm nameInfo mEquals augmentation -> - let declRange = unionRanges lhsm $1.Range + { (fun mLhs nameInfo mEquals augmentation -> + let declRange = unionRanges mLhs $1.Range let mWhole = (declRange, augmentation) ||> unionRangeWithListBy (fun (mem: SynMemberSig) -> mem.Range) SynTypeDefnSig(nameInfo, mEquals, SynTypeDefnSigRepr.Simple ($1, $1.Range), None, augmentation, mWhole)) } @@ -1063,7 +1065,7 @@ classMemberSpfn: let isInline, doc, vis2, id, explicitValTyparDecls, (ty, arity), (mEquals, optLiteralValue) = $4, grabXmlDoc(parseState, $1, 1), $5, $6, $7, $9, $11 let mWith, getSetRangeOpt, getSet = $10 let getSetAdjuster arity = match arity, getSet with SynValInfo([], _), SynMemberKind.Member -> SynMemberKind.PropertyGet | _ -> getSet - let wholeRange = + let mWhole = let m = rhs parseState 3 match getSetRangeOpt with | None -> unionRanges m ty.Range @@ -1074,9 +1076,9 @@ classMemberSpfn: match optLiteralValue with | None -> m | Some e -> unionRanges m e.Range - let valSpfn = SynValSig($1, id, explicitValTyparDecls, ty, arity, isInline, false, doc, vis2, optLiteralValue, wholeRange, { ValKeyword = None; WithKeyword = mWith; EqualsRange = mEquals }) + let valSpfn = SynValSig($1, id, explicitValTyparDecls, ty, arity, isInline, false, doc, vis2, optLiteralValue, mWhole, { ValKeyword = None; WithKeyword = mWith; EqualsRange = mEquals }) let _, flags = $3 - SynMemberSig.Member(valSpfn, flags (getSetAdjuster arity), wholeRange) } + SynMemberSig.Member(valSpfn, flags (getSetAdjuster arity), mWhole) } | opt_attributes opt_declVisibility interfaceMember appType { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) @@ -1087,18 +1089,18 @@ classMemberSpfn: SynMemberSig.Inherit ($4, unionRanges (rhs parseState 3) ($4).Range) } | opt_attributes opt_declVisibility VAL fieldDecl - { let wholeRange = rhs2 parseState 1 4 + { let mWhole = rhs2 parseState 1 4 if Option.isSome $2 then errorR (Error (FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2)) - let (SynField(_, _, _, _, _, xmlDoc, _, _)) as field = $4 $1 false wholeRange - let wholeRange = unionRangeWithXmlDoc xmlDoc wholeRange - SynMemberSig.ValField (field, wholeRange) } + let (SynField(_, _, _, _, _, xmlDoc, _, _)) as field = $4 $1 false mWhole + let mWhole = unionRangeWithXmlDoc xmlDoc mWhole + SynMemberSig.ValField (field, mWhole) } | opt_attributes opt_declVisibility STATIC VAL fieldDecl - { let wholeRange = rhs2 parseState 1 5 + { let mWhole = rhs2 parseState 1 5 if Option.isSome $2 then errorR (Error (FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2)) - let (SynField(_, _, _, _, _, xmlDoc, _, _)) as field = $5 $1 true wholeRange - let wholeRange = unionRangeWithXmlDoc xmlDoc wholeRange - SynMemberSig.ValField(field, wholeRange) } + let (SynField(_, _, _, _, _, xmlDoc, _, _)) as field = $5 $1 true mWhole + let mWhole = unionRangeWithXmlDoc xmlDoc mWhole + SynMemberSig.ValField(field, mWhole) } | opt_attributes opt_declVisibility STATIC typeKeyword tyconSpfn { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) @@ -1374,9 +1376,9 @@ moduleDefn: let (SynTypeDefn(SynComponentInfo(cas, a, cs, b, _xmlDoc, d, d2, d3), e, f, g, h, trivia)) = $4 _xmlDoc.MarkAsInvalid() let attrs = $1@cas - let mTc = (h, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) |> unionRangeWithXmlDoc xmlDoc + let mDefn = (h, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) |> unionRangeWithXmlDoc xmlDoc let mType = rhs parseState 3 - let tc = (SynTypeDefn(SynComponentInfo(attrs, a, cs, b, xmlDoc, d, d2, d3), e, f, g, mTc, { trivia with TypeKeyword = Some mType })) + let tc = SynTypeDefn(SynComponentInfo(attrs, a, cs, b, xmlDoc, d, d2, d3), e, f, g, mDefn, { trivia with TypeKeyword = Some mType }) let types = tc :: $5 [ SynModuleDecl.Types(types, (rhs parseState 3, types) ||> unionRangeWithListBy (fun t -> t.Range) ) ] } @@ -1387,8 +1389,8 @@ moduleDefn: let xmlDoc = grabXmlDoc(parseState, $1, 1) let defnReprRange = (d2, $1) ||> unionRangeWithListBy (fun a -> a.Range) |> unionRangeWithXmlDoc xmlDoc let mWhole = (f, $1) ||> unionRangeWithListBy (fun a -> a.Range) |> unionRangeWithXmlDoc xmlDoc - let ec = (SynExceptionDefn(SynExceptionDefnRepr($1@cas, a, b, xmlDoc, d, defnReprRange), withKeyword, e, mWhole)) - [ SynModuleDecl.Exception(ec, mWhole) ] } + let synExnDefn = SynExceptionDefn(SynExceptionDefnRepr($1@cas, a, b, xmlDoc, d, defnReprRange), withKeyword, e, mWhole) + [ SynModuleDecl.Exception(synExnDefn, mWhole) ] } /* 'module' definitions */ | opt_attributes opt_declVisibility moduleIntro EQUALS namedModuleDefnBlock @@ -1614,7 +1616,8 @@ tyconDefnList: | AND tyconDefn tyconDefnList { let xmlDoc = grabXmlDoc(parseState, [], 1) let tyconDefn = - let (SynTypeDefn(SynComponentInfo (a, typars, c, lid, _xmlDoc, fixity, vis, rangeOfLid) as componentInfo, typeRepr, members, implicitConstructor, range, trivia)) = $2 + let (SynTypeDefn(componentInfo, typeRepr, members, implicitConstructor, range, trivia)) = $2 + let (SynComponentInfo(a, typars, c, lid, _xmlDoc, fixity, vis, mLongId)) = componentInfo if xmlDoc.IsEmpty then if _xmlDoc.IsEmpty then $2 else let range = unionRangeWithXmlDoc _xmlDoc range @@ -1623,7 +1626,8 @@ tyconDefnList: else _xmlDoc.MarkAsInvalid() let range = unionRangeWithXmlDoc xmlDoc range - SynTypeDefn(SynComponentInfo (a, typars, c, lid, xmlDoc, fixity, vis, rangeOfLid), typeRepr, members, implicitConstructor, range, trivia) + let componentInfo = SynComponentInfo (a, typars, c, lid, xmlDoc, fixity, vis, mLongId) + SynTypeDefn(componentInfo, typeRepr, members, implicitConstructor, range, trivia) tyconDefn :: $3 } | { [] } @@ -1910,15 +1914,15 @@ classDefnMember: let isInline, doc, id, explicitValTyparDecls = $4, grabXmlDoc(parseState, $1, 1), $5, $6 let mWith, getSetRangeOpt, getSet = $9 let getSetAdjuster arity = match arity, getSet with SynValInfo([], _), SynMemberKind.Member -> SynMemberKind.PropertyGet | _ -> getSet - let wholeRange = + let mWhole = let m = rhs parseState 1 match getSetRangeOpt with | None -> unionRanges m ty.Range | Some m2 -> unionRanges m m2 |> unionRangeWithXmlDoc doc - if Option.isSome $2 then errorR(Error(FSComp.SR.parsAccessibilityModsIllegalForAbstract(), wholeRange)) - let valSpfn = SynValSig($1, id, explicitValTyparDecls, ty, arity, isInline, false, doc, None, None, wholeRange, { ValKeyword = None; WithKeyword = mWith; EqualsRange = None }) - [ SynMemberDefn.AbstractSlot(valSpfn, AbstractMemberFlags $3 (getSetAdjuster arity), wholeRange) ] } + if Option.isSome $2 then errorR(Error(FSComp.SR.parsAccessibilityModsIllegalForAbstract(), mWhole)) + let valSpfn = SynValSig($1, id, explicitValTyparDecls, ty, arity, isInline, false, doc, None, None, mWhole, { ValKeyword = None; WithKeyword = mWith; EqualsRange = None }) + [ SynMemberDefn.AbstractSlot(valSpfn, AbstractMemberFlags $3 (getSetAdjuster arity), mWhole) ] } | opt_attributes opt_declVisibility inheritsDefn { if not (isNil $1) then errorR(Error(FSComp.SR.parsAttributesIllegalOnInherit(), rhs parseState 1)) @@ -1998,13 +2002,13 @@ atomicPatternLongIdent: raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsUnexpectedSymbolDot()) let underscore = ident("_", rhs parseState 1) - let dotm = rhs parseState 2 - None, prependIdentInLongIdentWithTrivia (SynIdent(underscore, None)) dotm $3 } + let mDot = rhs parseState 2 + None, prependIdentInLongIdentWithTrivia (SynIdent(underscore, None)) mDot $3 } | GLOBAL DOT pathOp { let globalIdent = ident(MangledGlobalName, rhs parseState 1) - let dotm = rhs parseState 2 - None, prependIdentInLongIdentWithTrivia (SynIdent(globalIdent, None)) dotm $3 } + let mDot = rhs parseState 2 + None, prependIdentInLongIdentWithTrivia (SynIdent(globalIdent, None)) mDot $3 } | pathOp { (None, $1) } @@ -2014,8 +2018,8 @@ atomicPatternLongIdent: raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsUnexpectedSymbolDot()) let underscore = ident("_", rhs parseState 2) - let dotm = rhs parseState 3 - Some($1), prependIdentInLongIdentWithTrivia (SynIdent(underscore, None)) dotm $4 } + let mDot = rhs parseState 3 + Some($1), prependIdentInLongIdentWithTrivia (SynIdent(underscore, None)) mDot $4 } | access pathOp { (Some($1), $2) } @@ -2184,7 +2188,7 @@ tyconDefnOrSpfnSimpleRepr: /* A union type definition */ | opt_attributes opt_declVisibility unionTypeRepr { if not (isNil $1) then errorR(Error(FSComp.SR.parsAttributesIllegalHere(), rhs parseState 1)) - let rangesOf3 = $3 |> List.map (function |Choice1Of2(ec)->ec.Range | Choice2Of2(uc)->uc.Range) + let rangesOf3 = $3 |> List.map (function Choice1Of2 ec -> ec.Range | Choice2Of2 uc -> uc.Range) let mWhole = (rhs2 parseState 1 2, rangesOf3) ||> List.fold unionRanges if $3 |> List.exists (function Choice1Of2 _ -> true | _ -> false) then ( if Option.isSome $2 then errorR(Error(FSComp.SR.parsEnumTypesCannotHaveVisibilityDeclarations(), rhs parseState 2)); @@ -2207,12 +2211,12 @@ tyconDefnOrSpfnSimpleRepr: /* An inline-assembly type definition, for FSharp.Core library only */ | opt_attributes opt_declVisibility LPAREN HASH string HASH rparen { if not (isNil $1) then errorR(Error(FSComp.SR.parsAttributesIllegalHere(), rhs parseState 1)) - let lhsm = lhs parseState - if parseState.LexBuffer.ReportLibraryOnlyFeatures then libraryOnlyError lhsm + let mLhs = lhs parseState + if parseState.LexBuffer.ReportLibraryOnlyFeatures then libraryOnlyError mLhs if Option.isSome $2 then errorR(Error(FSComp.SR.parsInlineAssemblyCannotHaveVisibilityDeclarations(), rhs parseState 2)) let s, _ = $5 let ilType = ParseAssemblyCodeType s parseState.LexBuffer.ReportLibraryOnlyFeatures parseState.LexBuffer.LanguageVersion (rhs parseState 5) - SynTypeDefnSimpleRepr.LibraryOnlyILAssembly (box ilType, lhsm) } + SynTypeDefnSimpleRepr.LibraryOnlyILAssembly (box ilType, mLhs) } /* The core of a record type definition */ @@ -2513,8 +2517,8 @@ unionCaseReprElements: unionCaseReprElement: | ident COLON appType { let xmlDoc = grabXmlDoc(parseState, [], 1) - let wholeRange = rhs2 parseState 1 3 |> unionRangeWithXmlDoc xmlDoc - mkSynNamedField ($1, $3, xmlDoc, wholeRange) } + let mWhole = rhs2 parseState 1 3 |> unionRangeWithXmlDoc xmlDoc + mkSynNamedField ($1, $3, xmlDoc, mWhole) } | appType { let xmlDoc = grabXmlDoc(parseState, [], 1) @@ -2539,19 +2543,19 @@ recdFieldDeclList: /* A field declaration in a record type */ recdFieldDecl: | opt_attributes fieldDecl - { let wholeRange = rhs2 parseState 1 2 - let fld = $2 $1 false wholeRange - let (SynField (a, b, c, d, e, xmlDoc, vis, wholeRange)) = fld + { let mWhole = rhs2 parseState 1 2 + let fld = $2 $1 false mWhole + let (SynField (a, b, c, d, e, xmlDoc, vis, mWhole)) = fld if Option.isSome vis then errorR (Error (FSComp.SR.parsRecordFieldsCannotHaveVisibilityDeclarations (), rhs parseState 2)) - let wholeRange = unionRangeWithXmlDoc xmlDoc wholeRange - SynField (a, b, c, d, e, xmlDoc, None, wholeRange) } + let mWhole = unionRangeWithXmlDoc xmlDoc mWhole + SynField (a, b, c, d, e, xmlDoc, None, mWhole) } /* Part of a field or val declaration in a record type or object type */ fieldDecl: | opt_mutable opt_access ident COLON typ - { fun attrs stat wholeRange -> - let xmlDoc = grabXmlDocAtRangeStart(parseState, attrs, wholeRange) - SynField(attrs, stat, Some $3, $5, $1, xmlDoc, $2, wholeRange) } + { fun attrs stat mWhole -> + let xmlDoc = grabXmlDocAtRangeStart(parseState, attrs, mWhole) + SynField(attrs, stat, Some $3, $5, $1, xmlDoc, $2, mWhole) } /* An exception definition */ exconDefn: @@ -3322,12 +3326,12 @@ parenPattern: { SynPat.Ands(List.rev $1, rhs2 parseState 1 3) } | parenPattern COLON typeWithTypeConstraints %prec paren_pat_colon - { let lhsm = lhs parseState - SynPat.Typed($1, $3, lhsm) } + { let mLhs = lhs parseState + SynPat.Typed($1, $3, mLhs) } | attributes parenPattern %prec paren_pat_attribs - { let lhsm = lhs parseState - SynPat.Attrib($2, $1, lhsm) } + { let mLhs = lhs parseState + SynPat.Attrib($2, $1, mLhs) } | parenPattern COLON_COLON parenPattern { SynPat.LongIdent (SynLongIdent(mkSynCaseName (rhs parseState 2) opNameCons, [], [ Some (IdentTrivia.OriginalNotation "::") ]), None, None, SynArgPats.Pats [ SynPat.Tuple (false, [$1;$3], rhs2 parseState 1 3) ], None, lhs parseState) } @@ -3990,18 +3994,18 @@ declExpr: | declExpr DOT_DOT declExpr { let wholem = rhs2 parseState 1 3 - let opm = rhs parseState 2 - SynExpr.IndexRange(Some $1, opm, Some $3, rhs parseState 1, rhs parseState 3, wholem) } + let mOperator = rhs parseState 2 + SynExpr.IndexRange(Some $1, mOperator, Some $3, rhs parseState 1, rhs parseState 3, wholem) } | declExpr DOT_DOT %prec open_range_expr { let wholem = rhs2 parseState 1 2 - let opm = rhs parseState 2 - SynExpr.IndexRange(Some $1, opm, None, rhs parseState 1, opm, wholem) } + let mOperator = rhs parseState 2 + SynExpr.IndexRange(Some $1, mOperator, None, rhs parseState 1, mOperator, wholem) } | DOT_DOT declExpr %prec open_range_expr { let wholem = rhs2 parseState 1 2 - let opm = rhs parseState 1 - SynExpr.IndexRange(None, opm, Some $2, opm, rhs parseState 2, wholem) } + let mOperator = rhs parseState 1 + SynExpr.IndexRange(None, mOperator, Some $2, mOperator, rhs parseState 2, wholem) } | STAR { let m = rhs parseState 1 @@ -4351,61 +4355,61 @@ atomicExpr: atomicExprQualification: | identOrOp { let idm = rhs parseState 1 - (fun e lhsm dotm -> mkSynDot dotm lhsm e $1) } + (fun e mLhs mDot -> mkSynDot mDot mLhs e $1) } | GLOBAL - { (fun e lhsm dotm -> + { (fun e mLhs mDot -> reportParseErrorAt (rhs parseState 3) (FSComp.SR.nrGlobalUsedOnlyAsFirstName()) - let fixedLhsm = mkRange lhsm.FileName lhsm.Start dotm.End // previous lhsm is wrong after 'recover' - mkSynDotMissing dotm fixedLhsm e) } + let fixedLhsm = mkRange mLhs.FileName mLhs.Start mDot.End // previous mLhs is wrong after 'recover' + mkSynDotMissing mDot fixedLhsm e) } | /* empty */ - { (fun e lhsm dotm -> - reportParseErrorAt dotm (FSComp.SR.parsMissingQualificationAfterDot()) - let fixedLhsm = mkRange lhsm.FileName lhsm.Start dotm.End // previous lhsm is wrong after 'recover' - mkSynDotMissing dotm fixedLhsm e) } + { (fun e mLhs mDot -> + reportParseErrorAt mDot (FSComp.SR.parsMissingQualificationAfterDot()) + let fixedLhsm = mkRange mLhs.FileName mLhs.Start mDot.End // previous mLhs is wrong after 'recover' + mkSynDotMissing mDot fixedLhsm e) } | recover - { (fun e lhsm dotm -> - reportParseErrorAt dotm (FSComp.SR.parsMissingQualificationAfterDot()) - let fixedLhsm = mkRange lhsm.FileName lhsm.Start dotm.End // previous lhsm is wrong after 'recover' + { (fun e mLhs mDot -> + reportParseErrorAt mDot (FSComp.SR.parsMissingQualificationAfterDot()) + let fixedLhsm = mkRange mLhs.FileName mLhs.Start mDot.End // previous mLhs is wrong after 'recover' // Include 'e' in the returned expression but throw it away SynExpr.DiscardAfterMissingQualificationAfterDot (e, fixedLhsm)) } | LPAREN COLON_COLON rparen DOT INT32 - { (fun e lhsm dotm -> + { (fun e mLhs mDot -> if parseState.LexBuffer.ReportLibraryOnlyFeatures then libraryOnlyError(lhs parseState) - SynExpr.LibraryOnlyUnionCaseFieldGet (e, mkSynCaseName lhsm opNameCons, (fst $5), lhsm)) } + SynExpr.LibraryOnlyUnionCaseFieldGet (e, mkSynCaseName mLhs opNameCons, (fst $5), mLhs)) } | LPAREN typedSequentialExpr rparen { let lpr = rhs parseState 1 let rpr = rhs parseState 3 - (fun e lhsm dotm -> + (fun e mLhs mDot -> // Check for expr.( * ) // Note that "*" is parsed as an expression (it is allowed in "foo.[3,*]") match $2 with - | SynExpr.IndexRange (None, opm, None, _m1, _m2, _) -> - mkSynDot dotm lhsm e (SynIdent(ident(CompileOpName "*", opm), Some(IdentTrivia.OriginalNotationWithParen(lpr, "*", rpr)))) + | SynExpr.IndexRange (None, mOperator, None, _m1, _m2, _) -> + mkSynDot mDot mLhs e (SynIdent(ident(CompileOpName "*", mOperator), Some(IdentTrivia.OriginalNotationWithParen(lpr, "*", rpr)))) | _ -> if parseState.LexBuffer.SupportsFeature LanguageFeature.MLCompatRevisions then mlCompatError (FSComp.SR.mlCompatMultiPrefixTyparsNoLongerSupported()) (lhs parseState) else mlCompatWarning (FSComp.SR.parsParenFormIsForML()) (lhs parseState) - mkSynDotParenGet lhsm dotm e $2) } + mkSynDotParenGet mLhs mDot e $2) } | LBRACK typedSequentialExpr RBRACK - { (fun e lhsm dotm -> mkSynDotBrackGet lhsm dotm e $2) } + { (fun e mLhs mDot -> mkSynDotBrackGet mLhs mDot e $2) } | LBRACK typedSequentialExpr recover { reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnmatchedBracket()) - (fun e lhsm dotm -> exprFromParseError (mkSynDotBrackGet lhsm dotm e $2)) } + (fun e mLhs mDot -> exprFromParseError (mkSynDotBrackGet mLhs mDot e $2)) } | LBRACK error RBRACK { let mArg = rhs2 parseState 1 3 - (fun e lhsm dotm -> mkSynDotBrackGet lhsm dotm e (arbExpr("indexerExpr1", mArg))) } + (fun e mLhs mDot -> mkSynDotBrackGet mLhs mDot e (arbExpr("indexerExpr1", mArg))) } | LBRACK recover { reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnmatchedBracket()) let mArg = (rhs parseState 1).EndRange - (fun e lhsm dotm -> exprFromParseError (mkSynDotBrackGet lhsm dotm e (arbExpr("indexerExpr2", mArg)))) } + (fun e mLhs mDot -> exprFromParseError (mkSynDotBrackGet mLhs mDot e (arbExpr("indexerExpr2", mArg)))) } /* the start of atomicExprAfterType must not overlap with the valid postfix tokens of the type syntax, e.g. new List(...) */ atomicExprAfterType: @@ -4499,8 +4503,8 @@ parenExpr: | LPAREN parenExprBody ends_other_than_rparen_coming_soon_or_recover { if not $3 then reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnmatchedParen()) - let lhsm = unionRangeWithPos (rhs parseState 1) (rhs parseState 2).End - SynExpr.Paren (exprFromParseError ($2 lhsm), rhs parseState 1, None, lhsm) } + let mLhs = unionRangeWithPos (rhs parseState 1) (rhs parseState 2).End + SynExpr.Paren (exprFromParseError ($2 mLhs), rhs parseState 1, None, mLhs) } | LPAREN error rparen { // silent recovery @@ -4508,18 +4512,18 @@ parenExpr: | LPAREN TYPE_COMING_SOON { reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnmatchedParen()) - let lhsm = unionRangeWithPos (rhs parseState 1) (rhs parseState 2).Start - arbExpr("parenExpr2tcs", lhsm) } + let mLhs = unionRangeWithPos (rhs parseState 1) (rhs parseState 2).Start + arbExpr("parenExpr2tcs", mLhs) } | LPAREN MODULE_COMING_SOON { reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnmatchedParen()) - let lhsm = unionRangeWithPos (rhs parseState 1) (rhs parseState 2).Start - arbExpr("parenExpr2mcs", lhsm) } + let mLhs = unionRangeWithPos (rhs parseState 1) (rhs parseState 2).Start + arbExpr("parenExpr2mcs", mLhs) } | LPAREN RBRACE_COMING_SOON { reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnmatchedParen()) - let lhsm = unionRangeWithPos (rhs parseState 1) (rhs parseState 2).Start - arbExpr("parenExpr2rbcs", lhsm) } + let mLhs = unionRangeWithPos (rhs parseState 1) (rhs parseState 2).Start + arbExpr("parenExpr2rbcs", mLhs) } | LPAREN OBLOCKEND_COMING_SOON { let lparenRange = (rhs parseState 1) @@ -4534,8 +4538,8 @@ parenExpr: // to extend all the way over the "recover", to the end of the file if necessary // // let mLeftParen = rhs parseState 1 - //let lhsm = if $2 then unionRangeWithPos mLeftParen (rhs parseState 2).Start else mLeftParen - //arbExpr("parenExpr2", lhsm) } + //let mLhs = if $2 then unionRangeWithPos mLeftParen (rhs parseState 2).Start else mLeftParen + //arbExpr("parenExpr2", mLhs) } parenExprBody: | staticallyKnownHeadTypars COLON LPAREN classMemberSpfn rparen typedSequentialExpr @@ -4596,21 +4600,21 @@ braceExprBody: listExprElements: | sequentialExpr - { (fun lhsm -> SynExpr.ArrayOrListComputed (false, $1, lhsm)) } + { (fun mLhs -> SynExpr.ArrayOrListComputed (false, $1, mLhs)) } | - { (fun lhsm -> SynExpr.ArrayOrList (false, [ ], lhsm)) } + { (fun mLhs -> SynExpr.ArrayOrList (false, [ ], mLhs)) } arrayExprElements: | sequentialExpr - { (fun lhsm -> SynExpr.ArrayOrListComputed (true, $1, lhsm)) } + { (fun mLhs -> SynExpr.ArrayOrListComputed (true, $1, mLhs)) } | - { (fun lhsm -> SynExpr.ArrayOrList (true, [ ], lhsm)) } + { (fun mLhs -> SynExpr.ArrayOrList (true, [ ], mLhs)) } computationExpr: | sequentialExpr - { $1.Range, (fun lhsm -> SynExpr.ComputationExpr (false, $1, lhsm)) } + { $1.Range, (fun mLhs -> SynExpr.ComputationExpr (false, $1, mLhs)) } arrowThenExprR: | RARROW typedSequentialExprBlockR diff --git a/src/FSharp.Core/Linq.fs b/src/FSharp.Core/Linq.fs index 5b383f2c3d2..7093d0c72d4 100644 --- a/src/FSharp.Core/Linq.fs +++ b/src/FSharp.Core/Linq.fs @@ -593,11 +593,11 @@ module LeafExpressionConverter = | NullableConstruction arg -> Expression.Convert(ConvExprToLinqInContext env arg, x.Type) |> asExpr | _ -> Expression.New(ctorInfo, ConvExprsToLinq env args) |> asExpr - | Patterns.NewDelegate(dty, vs, b) -> + | Patterns.NewDelegate(delegateTy, vs, b) -> let vsP = List.map ConvVarToLinq vs let env = {env with varEnv = List.foldBack2 (fun (v:Var) vP -> Map.add v (vP |> asExpr)) vs vsP env.varEnv } let bodyP = ConvExprToLinqInContext env b - Expression.Lambda(dty, bodyP, vsP) |> asExpr + Expression.Lambda(delegateTy, bodyP, vsP) |> asExpr | Patterns.NewTuple args -> let tupTy = diff --git a/src/FSharp.Core/quotations.fs b/src/FSharp.Core/quotations.fs index 54ca7e2e3c4..44c625de5f5 100644 --- a/src/FSharp.Core/quotations.fs +++ b/src/FSharp.Core/quotations.fs @@ -1408,11 +1408,11 @@ module Patterns = | Unique of 'T | Ambiguous of 'R - let typeEquals (s: Type) (t: Type) = - s.Equals t + let typeEquals (ty1: Type) (ty2: Type) = + ty1.Equals ty2 - let typesEqual (ss: Type list) (tt: Type list) = - (ss.Length = tt.Length) && List.forall2 typeEquals ss tt + let typesEqual (tys1: Type list) (tys2: Type list) = + (tys1.Length = tys2.Length) && List.forall2 typeEquals tys1 tys2 let instFormal (typarEnv: Type[]) (ty: Instantiable<'T>) = ty (fun i -> typarEnv.[i]) diff --git a/tests/scripts/identifierAnalysisByType.fsx b/tests/scripts/identifierAnalysisByType.fsx index 7ac8de7a20b..d3b5c4e9415 100644 --- a/tests/scripts/identifierAnalysisByType.fsx +++ b/tests/scripts/identifierAnalysisByType.fsx @@ -60,7 +60,7 @@ symbols |> Array.filter (fun (v, _) -> v.GenericParameters.Count = 0) |> Array.filter (fun (v, _) -> v.CurriedParameterGroups.Count = 0) |> Array.filter (fun (v, _) -> not v.FullType.IsGenericParameter) -|> Array.map (fun (v, vUse) -> getTypeText v, v, vUse) +|> Array.map (fun (v, vUse) -> getTypeText v, v, vUse.ToString()) |> Array.filter (fun (vTypeText, v, _) -> match vTypeText with | "System.String" -> false @@ -77,6 +77,7 @@ symbols |> Array.map (fun (key, g) -> key, (g + |> Array.distinctBy (fun (_, _, vUse) -> vUse) |> Array.groupBy (fun (_, v, _) -> v.DisplayName) |> Array.sortByDescending (snd >> Array.length))) |> Array.filter (fun (_, g) -> g.Length > 1) @@ -87,7 +88,7 @@ symbols for (nm, entries) in g do printfn " %s (%d times)" nm (Array.length entries) for (_, _, vUse) in entries do - printfn " %s" (vUse.ToString()) + printfn " %s" vUse printfn "") (* From f89e6518d167705d5c0bae534dfb49c6a9a39f85 Mon Sep 17 00:00:00 2001 From: Hadrian Tang Date: Tue, 12 Jul 2022 22:58:17 +0800 Subject: [PATCH 10/11] Subtraction of two chars, new conversions, and fixes for dynamic operator invocations and QuotationToExpression (#11681) Co-authored-by: Vlad Zarytovskii Co-authored-by: Don Syme --- src/Compiler/Checking/ConstraintSolver.fs | 33 +- src/Compiler/TypedTree/TcGlobals.fs | 2 +- src/Compiler/pars.fsy | 2 +- src/FSharp.Core/Linq.fs | 488 ++-- src/FSharp.Core/Linq.fsi | 2 +- src/FSharp.Core/Query.fs | 15 +- src/FSharp.Core/prim-types.fs | 650 +++-- src/FSharp.Core/prim-types.fsi | 4 + .../FSharp.Core.UnitTests.fsproj | 1 + .../FSharp.Core/OperatorsModule1.fs | 98 +- .../FSharp.Core/OperatorsModule2.fs | 119 +- .../FSharp.Core/OperatorsModuleChecked.fs | 34 +- .../FSharp.Core/OperatorsModuleDynamic.fs | 1105 ++++++++ tests/FSharp.Core.UnitTests/SurfaceArea.fs | 1 + tests/fsharp/core/libtest/test.fsx | 40 + tests/fsharp/core/quotes/test.fsx | 2314 +++++++++++++++-- tests/fsharp/tools/eval/test.fsx | 33 +- tests/service/ExprTests.fs | 46 +- 18 files changed, 4288 insertions(+), 699 deletions(-) create mode 100644 tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs diff --git a/src/Compiler/Checking/ConstraintSolver.fs b/src/Compiler/Checking/ConstraintSolver.fs index 0119827bdf5..dd9fd013553 100644 --- a/src/Compiler/Checking/ConstraintSolver.fs +++ b/src/Compiler/Checking/ConstraintSolver.fs @@ -428,7 +428,7 @@ let isFpTy g ty = /// decimal or decimal<_> let isDecimalTy g ty = - typeEquivAux EraseMeasures g g.decimal_ty ty + typeEquivAux EraseMeasures g g.decimal_ty ty let IsNonDecimalNumericOrIntegralEnumType g ty = IsIntegerOrIntegerEnumTy g ty || isFpTy g ty @@ -443,7 +443,7 @@ let IsRelationalType g ty = IsNumericType g ty || isStringTy g ty || isCharTy g let IsCharOrStringType g ty = isCharTy g ty || isStringTy g ty /// Checks the argument type for a built-in solution to an op_Addition, op_Subtraction or op_Modulus constraint. -let IsAddSubModType nm g ty = IsNumericOrIntegralEnumType g ty || (nm = "op_Addition" && IsCharOrStringType g ty) +let IsAddSubModType nm g ty = IsNumericOrIntegralEnumType g ty || (nm = "op_Addition" && IsCharOrStringType g ty) || (nm = "op_Subtraction" && isCharTy g ty) /// Checks the argument type for a built-in solution to a bitwise operator constraint let IsBitwiseOpType g ty = IsIntegerOrIntegerEnumTy g ty || (isEnumTy g ty) @@ -1601,25 +1601,30 @@ and SolveMemberConstraint (csenv: ConstraintSolverEnv) ignoreUnresolvedOverload do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace retTy argTy return TTraitBuiltIn - | _, _, false, "op_Explicit", [argTy] - when (// The input type. + // Conversions from non-decimal numbers / strings / chars to non-decimal numbers / chars are built-in + | _, _, false, "op_Explicit", [argTy] + when (// The input type. (IsNonDecimalNumericOrIntegralEnumType g argTy || isStringTy g argTy || isCharTy g argTy) && // The output type - (IsNonDecimalNumericOrIntegralEnumType g retTy || isCharTy g retTy) && - // Exclusion: IntPtr and UIntPtr do not support .Parse() from string - not (isStringTy g argTy && isNativeIntegerTy g retTy) && - // Exclusion: No conversion from char to decimal - not (isCharTy g argTy && isDecimalTy g retTy)) -> + (IsNonDecimalNumericOrIntegralEnumType g retTy || isCharTy g retTy)) -> return TTraitBuiltIn - - | _, _, false, "op_Explicit", [argTy] - when (// The input type. - (IsNumericOrIntegralEnumType g argTy || isStringTy g argTy) && + // Conversions from (including decimal) numbers / strings / chars to decimals are built-in + | _, _, false, "op_Explicit", [argTy] + when (// The input type. + (IsNumericOrIntegralEnumType g argTy || isStringTy g argTy || isCharTy g argTy) && // The output type - (isDecimalTy g retTy)) -> + (isDecimalTy g retTy)) -> + return TTraitBuiltIn + // Conversions from decimal numbers to native integers are built-in + // The rest of decimal conversions are handled via op_Explicit lookup on System.Decimal (which also looks for op_Implicit) + | _, _, false, "op_Explicit", [argTy] + when (// The input type. + (isDecimalTy g argTy) && + // The output type + (isNativeIntegerTy g retTy)) -> return TTraitBuiltIn | [], _, false, "Pow", [argTy1; argTy2] diff --git a/src/Compiler/TypedTree/TcGlobals.fs b/src/Compiler/TypedTree/TcGlobals.fs index cf248940c9a..5075d68b504 100755 --- a/src/Compiler/TypedTree/TcGlobals.fs +++ b/src/Compiler/TypedTree/TcGlobals.fs @@ -1779,7 +1779,7 @@ type TcGlobals( [ arg0Ty; arg1Ty ], Some retTy -> [vara; varb; varc], [ varaTy; varbTy ], varcTy, [ arg0Ty; arg1Ty; retTy ] - | ("UnaryNegationDynamic" | "CheckedUnaryNegationDynamic" | "LogicalNotDynamic" | "ExplicitDynamic"), + | ("UnaryNegationDynamic" | "CheckedUnaryNegationDynamic" | "LogicalNotDynamic" | "ExplicitDynamic" | "CheckedExplicitDynamic"), [ arg0Ty ], Some retTy -> [vara; varb ], [ varaTy ], varbTy, [ arg0Ty; retTy ] diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 2238c89041b..a21e22dc891 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -1493,7 +1493,7 @@ namedModuleDefnBlock: { Choice1Of2 $1.LongIdent } -/* A module definition that inccludes a 'begin'...'end' (rarely used in F# with #light syntax) */ +/* A module definition that includes a 'begin'...'end' (rarely used in F# with #light syntax) */ wrappedNamedModuleDefn: | structOrBegin moduleDefnsOrExprPossiblyEmpty END { $2 } diff --git a/src/FSharp.Core/Linq.fs b/src/FSharp.Core/Linq.fs index 7093d0c72d4..33a1dd18265 100644 --- a/src/FSharp.Core/Linq.fs +++ b/src/FSharp.Core/Linq.fs @@ -75,7 +75,170 @@ module LeafExpressionConverter = let NullableConstructor = typedefof>.GetConstructors().[0] - + + let getNonNullableType typ = match Nullable.GetUnderlyingType typ with null -> typ | t -> t + + // https://github.com/dotnet/runtime/blob/fa779e8cb2b5868a0ac2fd4215f39ffb91f0dab0/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs#L72 + /// Can LINQ Expressions' BinaryExpression's (Left/Right)Shift construct a SimpleBinaryExpression from the type in question? Otherwise, use the F# operator as the user-defined method. + let isLinqExpressionsInteger typ = + let typ = getNonNullableType typ + not typ.IsEnum && + match Type.GetTypeCode typ with + | TypeCode.Byte + | TypeCode.SByte + | TypeCode.Int16 + | TypeCode.Int32 + | TypeCode.Int64 + | TypeCode.UInt16 + | TypeCode.UInt32 + | TypeCode.UInt64 -> true + | _ -> false + + // https://github.com/dotnet/runtime/blob/fa779e8cb2b5868a0ac2fd4215f39ffb91f0dab0/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/BinaryExpression.cs#L2226 + /// Can LINQ Expressions' BinaryExpression's (Left/Right)Shift construct a SimpleBinaryExpression from the type in question? Otherwise, use the F# operator as the user-defined method. + let isLinqExpressionsSimpleShift left right = + isLinqExpressionsInteger left && getNonNullableType right = typeof + + // https://github.com/dotnet/runtime/blob/cf7e7a46f8a4a6225a8f1e059a846ccdebf0454c/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs#L110 + /// Can LINQ Expressions' (UnaryExpression/BinaryExpression)'s arithmetic operations construct a (SimpleBinaryExpression/UnaryExpression) from the type in question? Otherwise, use the F# operator as the user-defined method. + let isLinqExpressionsArithmeticType typ = + let typ = getNonNullableType typ + not typ.IsEnum && + match Type.GetTypeCode typ with + | TypeCode.Int16 + | TypeCode.Int32 + | TypeCode.Int64 + | TypeCode.Double + | TypeCode.Single + | TypeCode.UInt16 + | TypeCode.UInt32 + | TypeCode.UInt64 -> true + | _ -> false + + // https://github.com/dotnet/runtime/blob/7bd472498e690e9421df86d5a9d728faa939742c/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs#L132 + /// Can LINQ Expressions' UnaryExpression.(Checked)Negate construct a UnaryExpression from the type in question? Otherwise, use the F# operator as the user-defined method. + let isLinqExpressionsArithmeticTypeButNotUnsignedInt typ = + isLinqExpressionsArithmeticType typ && + let typ = getNonNullableType typ + not typ.IsEnum && + match Type.GetTypeCode typ with + | TypeCode.UInt16 + | TypeCode.UInt32 + | TypeCode.UInt64 -> false + | _ -> true + + // https://github.com/dotnet/runtime/blob/7bd472498e690e9421df86d5a9d728faa939742c/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs#L149 + /// Can LINQ Expressions' (UnaryExpression.Not/BinaryExpression.Binary(And/Or/ExclusiveOr)) construct a (UnaryExpression/SimpleBinaryExpression) from the type in question? Otherwise, use the F# operator as the user-defined method. + let isLinqExpressionsIntegerOrBool typ = + let typ = getNonNullableType typ + not typ.IsEnum && + match Type.GetTypeCode typ with + | TypeCode.Int64 + | TypeCode.Int32 + | TypeCode.Int16 + | TypeCode.UInt64 + | TypeCode.UInt32 + | TypeCode.UInt16 + | TypeCode.Boolean + | TypeCode.SByte + | TypeCode.Byte -> true + | _ -> false + + // https://github.com/dotnet/runtime/blob/7bd472498e690e9421df86d5a9d728faa939742c/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs#L47 + /// Can LINQ Expressions' BinaryExpression's comparison operations construct a (SimpleBinaryExpression/LogicalBinaryExpression) from the type in question? Otherwise, use the F# operator as the user-defined method. + let isLinqExpressionsNumeric typ = + let typ = getNonNullableType typ + not typ.IsEnum && + match Type.GetTypeCode typ with + | TypeCode.Char + | TypeCode.SByte + | TypeCode.Byte + | TypeCode.Int16 + | TypeCode.Int32 + | TypeCode.Int64 + | TypeCode.Double + | TypeCode.Single + | TypeCode.UInt16 + | TypeCode.UInt32 + | TypeCode.UInt64 -> true + | _ -> false + + // https://github.com/dotnet/runtime/blob/afaf666eff08435123eb649ac138419f4c9b9344/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/BinaryExpression.cs#L1047 + /// Can LINQ Expressions' BinaryExpression's equality operations provide built-in structural equality from the type in question? Otherwise, use the F# operator as the user-defined method. + let isLinqExpressionsStructurallyEquatable typ = + isLinqExpressionsNumeric typ || typ = typeof || getNonNullableType(typ).IsEnum + + // https://github.com/dotnet/runtime/blob/4c92aef2b08f9c4374c520e7e664a44f1ad8ce56/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/BinaryExpression.cs#L1221 + /// Can LINQ Expressions' BinaryExpression's comparison operations provide built-in comparison from the type in question? Otherwise, use the F# operator as the user-defined method. + let isLinqExpressionsComparable = isLinqExpressionsNumeric + + /// Can LINQ Expressions' BinaryExpression's equality operations provide built-in equality from the type in question? Otherwise, use the F# operator as the user-defined method. + let isLinqExpressionsEquatable typ = + isLinqExpressionsStructurallyEquatable typ || typ = typeof + + /// Can LINQ Expressions' BinaryExpression's conversion operations provide built-in conversion from source to dest? Otherwise, use the F# operator as the user-defined method. + let isLinqExpressionsConvertible source dest = + // https://github.com/dotnet/runtime/blob/4c92aef2b08f9c4374c520e7e664a44f1ad8ce56/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/UnaryExpression.cs#L757 + // expression.Type.HasIdentityPrimitiveOrNullableConversionTo(type) || expression.Type.HasReferenceConversionTo(type)) + // In other words, source.HasIdentityPrimitiveOrNullableConversionTo dest || source.HasReferenceConversionTo dest + + // https://github.com/dotnet/runtime/blob/4c92aef2b08f9c4374c520e7e664a44f1ad8ce56/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs#L532 + let isConvertible typ = + let typ = getNonNullableType typ + typ.IsEnum || + match Type.GetTypeCode typ with + | TypeCode.Boolean + | TypeCode.Byte + | TypeCode.SByte + | TypeCode.Int16 + | TypeCode.Int32 + | TypeCode.Int64 + | TypeCode.UInt16 + | TypeCode.UInt32 + | TypeCode.UInt64 + | TypeCode.Single + | TypeCode.Double + | TypeCode.Char -> true + | _ -> false + // https://github.com/dotnet/runtime/blob/4c92aef2b08f9c4374c520e7e664a44f1ad8ce56/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs#L229 + // HasIdentityPrimitiveOrNullableConversionTo + getNonNullableType(source).IsEquivalentTo dest + || dest.IsEquivalentTo(getNonNullableType source) + || isConvertible source && isConvertible dest + && (getNonNullableType dest <> typeof || source.IsEnum && source.GetEnumUnderlyingType() = typeof) + + || + // https://github.com/dotnet/runtime/blob/4c92aef2b08f9c4374c520e7e664a44f1ad8ce56/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs#L458 + // IsLegalExplicitVariantDelegateConversion + // https://github.com/dotnet/runtime/blob/4c92aef2b08f9c4374c520e7e664a44f1ad8ce56/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs#L260 + // HasReferenceConversionTo + let rec hasReferenceConversionTo source dest = + + // { if (source == typeof(void) || dest == typeof(void)) return false; } invalidates an identity conversion. This is handled by the IsEquivalentTo check above. + let nnSourceType, nnDestType = getNonNullableType source, getNonNullableType dest + + // Down conversion + nnSourceType.IsAssignableFrom nnDestType + // Up conversion + || nnDestType.IsAssignableFrom nnSourceType + + // Interface conversion + || source.IsInterface || dest.IsInterface + + // The following part shouldn't be needed for our usage of isLinqExpressionsConvertible here because we only use this for potentially nullable built-in numeric types +(* + // Variant delegate conversion + if (IsLegalExplicitVariantDelegateConversion(source, dest)) + { + return true; + } + + // Object conversion handled by assignable above. + Debug.Assert(source != typeof(object) && dest != typeof(object)); + + return (source.IsArray || dest.IsArray) && StrictHasReferenceConversionTo(source, dest, true); +*) + hasReferenceConversionTo source dest let SpecificCallToMethodInfo (minfo: System.Reflection.MethodInfo) = let isg1 = minfo.IsGenericMethod let gmd = if isg1 then minfo.GetGenericMethodDefinition() else null @@ -87,19 +250,20 @@ module LeafExpressionConverter = if isg1 then minfo2.IsGenericMethod && gmd = minfo2.GetGenericMethodDefinition() else minfo = minfo2 ) -> - Some (obj, (minfo2.GetGenericArguments() |> Array.toList), args) + Some (obj, minfo2, args) | _ -> None) - - let (|SpecificCallToMethod|_|) (mhandle: System.RuntimeMethodHandle) = + let (|SpecificCallToMethod|_|) (mhandle: RuntimeMethodHandle) = let minfo = (System.Reflection.MethodInfo.GetMethodFromHandle mhandle) :?> MethodInfo SpecificCallToMethodInfo minfo + let (|GenericArgs|) (minfo: MethodInfo) = minfo.GetGenericArguments() + let (|PhysicalEqualityQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun (x, y) -> LanguagePrimitives.PhysicalEquality x y)) let (|GenericEqualityQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun (x, y) -> LanguagePrimitives.GenericEquality x y)) let (|EqualsQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun (x, y) -> x = y)) let (|GreaterQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun (x, y) -> x > y)) let (|GreaterEqQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun (x, y) -> x >= y)) - let (|LessQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun (x, y) -> x < y)) + let (|LessQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun (x, y) -> x < y)) let (|LessEqQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun (x, y) -> x <= y)) let (|NotEqQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun (x, y) -> x <> y)) @@ -185,6 +349,8 @@ module LeafExpressionConverter = let (|ConvUInt16Q|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Operators.uint16 x)) let (|ConvUInt32Q|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Operators.uint32 x)) let (|ConvUInt64Q|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Operators.uint64 x)) + let (|ConvIntPtrQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Operators.nativeint x)) + let (|ConvUIntPtrQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Operators.unativeint x)) let (|ConvInt8Q|_|) = SpecificCallToMethodInfo (typeof.Assembly.GetType("Microsoft.FSharp.Core.ExtraTopLevelOperators").GetMethod("ToSByte")) let (|ConvUInt8Q|_|) = SpecificCallToMethodInfo (typeof.Assembly.GetType("Microsoft.FSharp.Core.ExtraTopLevelOperators").GetMethod("ToByte")) @@ -208,10 +374,8 @@ module LeafExpressionConverter = let (|ConvNullableUInt16Q|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Nullable.uint16 x)) let (|ConvNullableUInt32Q|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Nullable.uint32 x)) let (|ConvNullableUInt64Q|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Nullable.uint64 x)) - // LINQ expressions can't do native integer operations, so we don't convert these - //let (|ConvNullableIntPtrQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Nullable.nativeint x)) - //let (|ConvNullableUIntPtrQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Nullable.unativeint x)) - + let (|ConvNullableIntPtrQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Nullable.nativeint x)) + let (|ConvNullableUIntPtrQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Nullable.unativeint x)) let (|UnboxGeneric|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> LanguagePrimitives.IntrinsicFunctions.UnboxGeneric x)) let (|TypeTestGeneric|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> LanguagePrimitives.IntrinsicFunctions.TypeTestGeneric x)) @@ -226,6 +390,8 @@ module LeafExpressionConverter = let (|CheckedConvUInt16Q|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Checked.uint16 x)) let (|CheckedConvUInt32Q|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Checked.uint32 x)) let (|CheckedConvUInt64Q|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Checked.uint64 x)) + let (|CheckedConvIntPtrQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Checked.nativeint x)) + let (|CheckedConvUIntPtrQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> Checked.unativeint x)) let (|ImplicitExpressionConversionHelperQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> ImplicitExpressionConversionHelper x)) let (|MemberInitializationHelperQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> MemberInitializationHelper x)) let (|NewAnonymousObjectHelperQ|_|) = (|SpecificCallToMethod|_|) (methodhandleof (fun x -> NewAnonymousObjectHelper x)) @@ -287,7 +453,7 @@ module LeafExpressionConverter = | Patterns.Value(x, ty) -> Expression.Constant(x, ty) |> asExpr - | UnboxGeneric(_, [toTy], [x]) + | UnboxGeneric(_, GenericArgs [|toTy|], [x]) | Patterns.Coerce(x, toTy) -> let converted = ConvExprToLinqInContext env x @@ -299,7 +465,7 @@ module LeafExpressionConverter = | Patterns.TypeTest(x, toTy) -> Expression.TypeIs(ConvExprToLinqInContext env x, toTy) |> asExpr - | TypeTestGeneric(_, [toTy], [x]) -> + | TypeTestGeneric(_, GenericArgs [|toTy|], [x]) -> Expression.TypeIs(ConvExprToLinqInContext env x, toTy) |> asExpr // Expr.*Get @@ -355,147 +521,115 @@ module LeafExpressionConverter = let props = ctor.DeclaringType.GetProperties() Expression.New(ctor, argsR, [| for p in props -> (p :> MemberInfo) |]) |> asExpr - // Do the same thing as C# compiler for string addition - | PlusQ (_, [ty1; ty2; ty3], [x1; x2]) when (ty1 = typeof) && (ty2 = typeof) && (ty3 = typeof) -> + | PlusQ (_, GenericArgs [|ty1; ty2; ty3|], [x1; x2]) when ty1 = typeof && ty2 = typeof && ty3 = typeof -> Expression.Add(ConvExprToLinqInContext env x1, ConvExprToLinqInContext env x2, StringConcat) |> asExpr - | GenericEqualityQ _ - | EqualsQ _ -> transBinOp inp env false args false Expression.Equal - | NotEqQ _ -> transBinOp inp env false args false Expression.NotEqual - | GreaterQ _ -> transBinOp inp env false args false Expression.GreaterThan - | GreaterEqQ _ -> transBinOp inp env false args false Expression.GreaterThanOrEqual - | LessQ _ -> transBinOp inp env false args false Expression.LessThan - | LessEqQ _ -> transBinOp inp env false args false Expression.LessThanOrEqual - | NotQ (_, _, [x1]) -> Expression.Not(ConvExprToLinqInContext env x1) |> asExpr - - | StaticEqualsQ _ -> transBinOp inp env false args false Expression.Equal - | StaticNotEqQ _ -> transBinOp inp env false args false Expression.NotEqual - | StaticGreaterQ _ -> transBinOp inp env false args false Expression.GreaterThan - | StaticGreaterEqQ _ -> transBinOp inp env false args false Expression.GreaterThanOrEqual - | StaticLessQ _ -> transBinOp inp env false args false Expression.LessThan - | StaticLessEqQ _ -> transBinOp inp env false args false Expression.LessThanOrEqual - - | NullableEqualsQ _ -> transBinOp inp env false args true Expression.Equal - | NullableNotEqQ _ -> transBinOp inp env false args true Expression.NotEqual - | NullableGreaterQ _ -> transBinOp inp env false args true Expression.GreaterThan - | NullableGreaterEqQ _ -> transBinOp inp env false args true Expression.GreaterThanOrEqual - | NullableLessQ _ -> transBinOp inp env false args true Expression.LessThan - | NullableLessEqQ _ -> transBinOp inp env false args true Expression.LessThanOrEqual - - | EqualsNullableQ _ -> transBinOp inp env true args false Expression.Equal - | NotEqNullableQ _ -> transBinOp inp env true args false Expression.NotEqual - | GreaterNullableQ _ -> transBinOp inp env true args false Expression.GreaterThan - | GreaterEqNullableQ _ -> transBinOp inp env true args false Expression.GreaterThanOrEqual - | LessNullableQ _ -> transBinOp inp env true args false Expression.LessThan - | LessEqNullableQ _ -> transBinOp inp env true args false Expression.LessThanOrEqual - - | NullableEqualsNullableQ _ -> transBinOp inp env false args false Expression.Equal - | NullableNotEqNullableQ _ -> transBinOp inp env false args false Expression.NotEqual - | NullableGreaterNullableQ _ -> transBinOp inp env false args false Expression.GreaterThan - | NullableGreaterEqNullableQ _ -> transBinOp inp env false args false Expression.GreaterThanOrEqual - | NullableLessNullableQ _ -> transBinOp inp env false args false Expression.LessThan - | NullableLessEqNullableQ _ -> transBinOp inp env false args false Expression.LessThanOrEqual + // LanguagePrimitives.PhysicalEquality's generic constraint of both sides being the same reference type is already sufficient for Linq Expressions' requirements + | PhysicalEqualityQ (_, m, [x1; x2]) -> transBoolOpNoWitness (fun _ -> true) env false x1 x2 false (fun (l, r, _, _) -> Expression.ReferenceEqual(l, r)) m + | GenericEqualityQ (_, m, [x1; x2]) + | EqualsQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsStructurallyEquatable env false x1 x2 false Expression.Equal m + | NotEqQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsStructurallyEquatable env false x1 x2 false Expression.NotEqual m + | GreaterQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env false x1 x2 false Expression.GreaterThan m + | GreaterEqQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env false x1 x2 false Expression.GreaterThanOrEqual m + | LessQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env false x1 x2 false Expression.LessThan m + | LessEqQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env false x1 x2 false Expression.LessThanOrEqual m + | NotQ (_, _, [x1]) -> Expression.Not(ConvExprToLinqInContext env x1) |> asExpr + + | StaticEqualsQ (_, _, [x1; x2]) -> transBoolOp isLinqExpressionsEquatable inp env x1 x2 Expression.Equal (methodhandleof (fun (x, y) -> LanguagePrimitives.EqualityDynamic x y)) + | StaticNotEqQ (_, _, [x1; x2]) -> transBoolOp isLinqExpressionsEquatable inp env x1 x2 Expression.NotEqual (methodhandleof (fun (x, y) -> LanguagePrimitives.InequalityDynamic x y)) + | StaticGreaterQ (_, _, [x1; x2]) -> transBoolOp isLinqExpressionsComparable inp env x1 x2 Expression.GreaterThan (methodhandleof (fun (x, y) -> LanguagePrimitives.GreaterThanDynamic x y)) + | StaticGreaterEqQ (_, _, [x1; x2]) -> transBoolOp isLinqExpressionsComparable inp env x1 x2 Expression.GreaterThanOrEqual (methodhandleof (fun (x, y) -> LanguagePrimitives.GreaterThanOrEqualDynamic x y)) + | StaticLessQ (_, _, [x1; x2]) -> transBoolOp isLinqExpressionsComparable inp env x1 x2 Expression.LessThan (methodhandleof (fun (x, y) -> LanguagePrimitives.LessThanDynamic x y)) + | StaticLessEqQ (_, _, [x1; x2]) -> transBoolOp isLinqExpressionsComparable inp env x1 x2 Expression.LessThanOrEqual (methodhandleof (fun (x, y) -> LanguagePrimitives.LessThanOrEqualDynamic x y)) + + | NullableEqualsQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsStructurallyEquatable env false x1 x2 true Expression.Equal m + | NullableNotEqQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsStructurallyEquatable env false x1 x2 true Expression.NotEqual m + | NullableGreaterQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env false x1 x2 true Expression.GreaterThan m + | NullableGreaterEqQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env false x1 x2 true Expression.GreaterThanOrEqual m + | NullableLessQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env false x1 x2 true Expression.LessThan m + | NullableLessEqQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env false x1 x2 true Expression.LessThanOrEqual m + + | EqualsNullableQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsStructurallyEquatable env true x1 x2 false Expression.Equal m + | NotEqNullableQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsStructurallyEquatable env true x1 x2 false Expression.NotEqual m + | GreaterNullableQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env true x1 x2 false Expression.GreaterThan m + | GreaterEqNullableQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env true x1 x2 false Expression.GreaterThanOrEqual m + | LessNullableQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env true x1 x2 false Expression.LessThan m + | LessEqNullableQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env true x1 x2 false Expression.LessThanOrEqual m + + | NullableEqualsNullableQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsStructurallyEquatable env false x1 x2 false Expression.Equal m + | NullableNotEqNullableQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsStructurallyEquatable env false x1 x2 false Expression.NotEqual m + | NullableGreaterNullableQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env false x1 x2 false Expression.GreaterThan m + | NullableGreaterEqNullableQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env false x1 x2 false Expression.GreaterThanOrEqual m + | NullableLessNullableQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env false x1 x2 false Expression.LessThan m + | NullableLessEqNullableQ (_, m, [x1; x2]) -> transBoolOpNoWitness isLinqExpressionsComparable env false x1 x2 false Expression.LessThanOrEqual m // Detect the F# quotation encoding of decimal literals | MakeDecimalQ (_, _, [Int32 lo; Int32 med; Int32 hi; Bool isNegative; Byte scale]) -> Expression.Constant (new System.Decimal(lo, med, hi, isNegative, scale)) |> asExpr - | NegQ (_, _, [x1]) -> Expression.Negate(ConvExprToLinqInContext env x1) |> asExpr - | PlusQ _ -> transBinOp inp env false args false Expression.Add - | DivideQ _ -> transBinOp inp env false args false Expression.Divide - | MinusQ _ -> transBinOp inp env false args false Expression.Subtract - | MultiplyQ _ -> transBinOp inp env false args false Expression.Multiply - | ModuloQ _ -> transBinOp inp env false args false Expression.Modulo - - | ShiftLeftQ _ -> transBinOp inp env false args false Expression.LeftShift - | ShiftRightQ _ -> transBinOp inp env false args false Expression.RightShift - | BitwiseAndQ _ -> transBinOp inp env false args false Expression.And - | BitwiseOrQ _ -> transBinOp inp env false args false Expression.Or - | BitwiseXorQ _ -> transBinOp inp env false args false Expression.ExclusiveOr - | BitwiseNotQ (_, _, [x1]) -> Expression.Not(ConvExprToLinqInContext env x1) |> asExpr + | NegQ (_, _, [x]) -> transUnaryOp isLinqExpressionsArithmeticTypeButNotUnsignedInt inp env x Expression.Negate (methodhandleof (fun x -> LanguagePrimitives.UnaryNegationDynamic x)) + | PlusQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 false Expression.Add (methodhandleof (fun (x, y) -> LanguagePrimitives.AdditionDynamic x y)) + | MinusQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 false Expression.Subtract (methodhandleof (fun (x, y) -> LanguagePrimitives.SubtractionDynamic x y)) + | MultiplyQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 false Expression.Multiply (methodhandleof (fun (x, y) -> LanguagePrimitives.MultiplyDynamic x y)) + | DivideQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 false Expression.Divide (methodhandleof (fun (x, y) -> LanguagePrimitives.DivisionDynamic x y)) + | ModuloQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 false Expression.Modulo (methodhandleof (fun (x, y) -> LanguagePrimitives.ModulusDynamic x y)) + + | ShiftLeftQ (_, _, [x1; x2]) -> transShiftOp inp env false x1 x2 false Expression.LeftShift (methodhandleof (fun (x, y) -> LanguagePrimitives.LeftShiftDynamic x y)) + | ShiftRightQ (_, _, [x1; x2]) -> transShiftOp inp env false x1 x2 false Expression.RightShift (methodhandleof (fun (x, y) -> LanguagePrimitives.RightShiftDynamic x y)) + | BitwiseAndQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsIntegerOrBool inp env false x1 x2 false Expression.And (methodhandleof (fun (x, y) -> LanguagePrimitives.BitwiseAndDynamic x y)) + | BitwiseOrQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsIntegerOrBool inp env false x1 x2 false Expression.Or (methodhandleof (fun (x, y) -> LanguagePrimitives.BitwiseOrDynamic x y)) + | BitwiseXorQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsIntegerOrBool inp env false x1 x2 false Expression.ExclusiveOr (methodhandleof (fun (x, y) -> LanguagePrimitives.ExclusiveOrDynamic x y)) + | BitwiseNotQ (_, _, [x]) -> transUnaryOp isLinqExpressionsIntegerOrBool inp env x Expression.Not (methodhandleof (fun x -> LanguagePrimitives.LogicalNotDynamic x)) - | CheckedNeg (_, _, [x1]) -> Expression.NegateChecked(ConvExprToLinqInContext env x1) |> asExpr - | CheckedPlusQ _ -> transBinOp inp env false args false Expression.AddChecked - | CheckedMinusQ _ -> transBinOp inp env false args false Expression.SubtractChecked - | CheckedMultiplyQ _ -> transBinOp inp env false args false Expression.MultiplyChecked + | CheckedNeg (_, _, [x]) -> transUnaryOp isLinqExpressionsArithmeticTypeButNotUnsignedInt inp env x Expression.NegateChecked (methodhandleof (fun x -> LanguagePrimitives.CheckedUnaryNegationDynamic x)) + | CheckedPlusQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 false Expression.AddChecked (methodhandleof (fun (x, y) -> LanguagePrimitives.CheckedAdditionDynamic x y)) + | CheckedMinusQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 false Expression.SubtractChecked (methodhandleof (fun (x, y) -> LanguagePrimitives.CheckedSubtractionDynamic x y)) + | CheckedMultiplyQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 false Expression.MultiplyChecked (methodhandleof (fun (x, y) -> LanguagePrimitives.CheckedMultiplyDynamic x y)) - | NullablePlusQ _ -> transBinOp inp env false args true Expression.Add - | PlusNullableQ _ -> transBinOp inp env true args false Expression.Add - | NullablePlusNullableQ _ -> transBinOp inp env false args false Expression.Add + | NullablePlusQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 true Expression.Add (methodhandleof (fun (x, y) -> LanguagePrimitives.AdditionDynamic x y)) + | PlusNullableQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env true x1 x2 false Expression.Add (methodhandleof (fun (x, y) -> LanguagePrimitives.AdditionDynamic x y)) + | NullablePlusNullableQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 false Expression.Add (methodhandleof (fun (x, y) -> LanguagePrimitives.AdditionDynamic x y)) - | NullableMinusQ _ -> transBinOp inp env false args true Expression.Subtract - | MinusNullableQ _ -> transBinOp inp env true args false Expression.Subtract - | NullableMinusNullableQ _ -> transBinOp inp env false args false Expression.Subtract + | NullableMinusQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 true Expression.Subtract (methodhandleof (fun (x, y) -> LanguagePrimitives.SubtractionDynamic x y)) + | MinusNullableQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env true x1 x2 false Expression.Subtract (methodhandleof (fun (x, y) -> LanguagePrimitives.SubtractionDynamic x y)) + | NullableMinusNullableQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 false Expression.Subtract (methodhandleof (fun (x, y) -> LanguagePrimitives.SubtractionDynamic x y)) - | NullableMultiplyQ _ -> transBinOp inp env false args true Expression.Multiply - | MultiplyNullableQ _ -> transBinOp inp env true args false Expression.Multiply - | NullableMultiplyNullableQ _ -> transBinOp inp env false args false Expression.Multiply + | NullableMultiplyQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 true Expression.Multiply (methodhandleof (fun (x, y) -> LanguagePrimitives.MultiplyDynamic x y)) + | MultiplyNullableQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env true x1 x2 false Expression.Multiply (methodhandleof (fun (x, y) -> LanguagePrimitives.MultiplyDynamic x y)) + | NullableMultiplyNullableQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 false Expression.Multiply (methodhandleof (fun (x, y) -> LanguagePrimitives.MultiplyDynamic x y)) - | NullableDivideQ _ -> transBinOp inp env false args true Expression.Divide - | DivideNullableQ _ -> transBinOp inp env true args false Expression.Divide - | NullableDivideNullableQ _ -> transBinOp inp env false args false Expression.Divide + | NullableDivideQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 true Expression.Divide (methodhandleof (fun (x, y) -> LanguagePrimitives.DivisionDynamic x y)) + | DivideNullableQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env true x1 x2 false Expression.Divide (methodhandleof (fun (x, y) -> LanguagePrimitives.DivisionDynamic x y)) + | NullableDivideNullableQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 false Expression.Divide (methodhandleof (fun (x, y) -> LanguagePrimitives.DivisionDynamic x y)) - | NullableModuloQ _ -> transBinOp inp env false args true Expression.Modulo - | ModuloNullableQ _ -> transBinOp inp env true args false Expression.Modulo - | NullableModuloNullableQ _ -> transBinOp inp env false args false Expression.Modulo - - | ConvNullableCharQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableDecimalQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableFloatQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableDoubleQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableFloat32Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableSingleQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableSByteQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableInt8Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableInt16Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableInt32Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableIntQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableInt64Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableByteQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableUInt8Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableUInt16Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableUInt32Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - | ConvNullableUInt64Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - // LINQ expressions can't do native integer operations, so we don't convert these - //| ConvNullableIntPtrQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - //| ConvNullableUIntPtrQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof>) |> asExpr - - | ConvCharQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvDecimalQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvFloatQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvDoubleQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvFloat32Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvSingleQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvSByteQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvInt8Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvInt16Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvInt32Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvIntQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvInt64Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvByteQ (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvUInt8Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvUInt16Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvUInt32Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ConvUInt64Q (_, _, [x1]) -> Expression.Convert(ConvExprToLinqInContext env x1, typeof) |> asExpr - - | CheckedConvCharQ (_, _, [x1]) -> Expression.ConvertChecked(ConvExprToLinqInContext env x1, typeof) |> asExpr - | CheckedConvSByteQ (_, _, [x1]) -> Expression.ConvertChecked(ConvExprToLinqInContext env x1, typeof) |> asExpr - | CheckedConvInt8Q (_, _, [x1]) -> Expression.ConvertChecked(ConvExprToLinqInContext env x1, typeof) |> asExpr - | CheckedConvInt16Q (_, _, [x1]) -> Expression.ConvertChecked(ConvExprToLinqInContext env x1, typeof) |> asExpr - | CheckedConvInt32Q (_, _, [x1]) -> Expression.ConvertChecked(ConvExprToLinqInContext env x1, typeof) |> asExpr - | CheckedConvInt64Q (_, _, [x1]) -> Expression.ConvertChecked(ConvExprToLinqInContext env x1, typeof) |> asExpr - | CheckedConvByteQ (_, _, [x1]) -> Expression.ConvertChecked(ConvExprToLinqInContext env x1, typeof) |> asExpr - | CheckedConvUInt8Q (_, _, [x1]) -> Expression.ConvertChecked(ConvExprToLinqInContext env x1, typeof) |> asExpr - | CheckedConvUInt16Q (_, _, [x1]) -> Expression.ConvertChecked(ConvExprToLinqInContext env x1, typeof) |> asExpr - | CheckedConvUInt32Q (_, _, [x1]) -> Expression.ConvertChecked(ConvExprToLinqInContext env x1, typeof) |> asExpr - | CheckedConvUInt64Q (_, _, [x1]) -> Expression.ConvertChecked(ConvExprToLinqInContext env x1, typeof) |> asExpr - | ArrayLookupQ (_, [_; _; _], [x1; x2]) -> + | NullableModuloQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 true Expression.Modulo (methodhandleof (fun (x, y) -> LanguagePrimitives.ModulusDynamic x y)) + | ModuloNullableQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env true x1 x2 false Expression.Modulo (methodhandleof (fun (x, y) -> LanguagePrimitives.ModulusDynamic x y)) + | NullableModuloNullableQ (_, _, [x1; x2]) -> transBinOp isLinqExpressionsArithmeticType inp env false x1 x2 false Expression.Modulo (methodhandleof (fun (x, y) -> LanguagePrimitives.ModulusDynamic x y)) + + | ConvNullableCharQ (_, _, [x]) | ConvNullableDecimalQ (_, _, [x]) | ConvNullableFloatQ (_, _, [x]) | ConvNullableDoubleQ (_, _, [x]) -> transConv inp env false x + | ConvNullableFloat32Q (_, _, [x]) | ConvNullableSingleQ (_, _, [x]) | ConvNullableSByteQ (_, _, [x]) | ConvNullableInt8Q (_, _, [x]) -> transConv inp env false x + | ConvNullableInt16Q (_, _, [x]) | ConvNullableInt32Q (_, _, [x]) | ConvNullableIntQ (_, _, [x]) | ConvNullableInt64Q (_, _, [x]) -> transConv inp env false x + | ConvNullableByteQ (_, _, [x]) | ConvNullableUInt8Q (_, _, [x]) | ConvNullableUInt16Q (_, _, [x]) | ConvNullableUInt32Q (_, _, [x]) -> transConv inp env false x + | ConvNullableUInt64Q (_, _, [x]) | ConvNullableIntPtrQ (_, _, [x]) | ConvNullableUIntPtrQ (_, _, [x]) -> transConv inp env false x + + | ConvCharQ (_, _, [x]) | ConvDecimalQ (_, _, [x]) | ConvFloatQ (_, _, [x]) | ConvDoubleQ (_, _, [x]) -> transConv inp env false x + | ConvFloat32Q (_, _, [x]) | ConvSingleQ (_, _, [x]) | ConvSByteQ (_, _, [x]) | ConvInt8Q (_, _, [x]) -> transConv inp env false x + | ConvInt16Q (_, _, [x]) | ConvInt32Q (_, _, [x]) | ConvIntQ (_, _, [x]) | ConvInt64Q (_, _, [x]) -> transConv inp env false x + | ConvByteQ (_, _, [x]) | ConvUInt8Q (_, _, [x]) | ConvUInt16Q (_, _, [x]) | ConvUInt32Q (_, _, [x]) -> transConv inp env false x + | ConvUInt64Q (_, _, [x]) | ConvIntPtrQ (_, _, [x]) | ConvUIntPtrQ (_, _, [x]) -> transConv inp env false x + + | CheckedConvCharQ (_, _, [x]) | CheckedConvSByteQ (_, _, [x]) | CheckedConvInt8Q (_, _, [x]) | CheckedConvInt16Q (_, _, [x]) -> transConv inp env true x + | CheckedConvInt32Q (_, _, [x]) | CheckedConvInt64Q (_, _, [x]) | CheckedConvByteQ (_, _, [x]) | CheckedConvUInt8Q (_, _, [x]) -> transConv inp env true x + | CheckedConvUInt16Q (_, _, [x]) | CheckedConvUInt32Q (_, _, [x]) | CheckedConvUInt64Q (_, _, [x]) | CheckedConvIntPtrQ (_, _, [x]) -> transConv inp env true x + | CheckedConvUIntPtrQ (_, _, [x]) -> transConv inp env true x + + | ArrayLookupQ (_, GenericArgs [|_; _; _|], [x1; x2]) -> Expression.ArrayIndex(ConvExprToLinqInContext env x1, ConvExprToLinqInContext env x2) |> asExpr // Throw away markers inserted to satisfy C#'s design where they pass an argument // or type T to an argument expecting Expression. - | ImplicitExpressionConversionHelperQ (_, [_], [x1]) -> ConvExprToLinqInContext env x1 + | ImplicitExpressionConversionHelperQ (_, GenericArgs [|_|], [x1]) -> ConvExprToLinqInContext env x1 // Use witnesses if they are available | CallWithWitnesses (objArgOpt, _, minfo2, witnessArgs, args) -> @@ -665,15 +799,79 @@ module LeafExpressionConverter = and failConvert inp = raise (new NotSupportedException(Printf.sprintf "Could not convert the following F# Quotation to a LINQ Expression Tree\n--------\n%s\n-------------\n" (inp.ToString()))) - and transBinOp inp env addConvertLeft args addConvertRight (exprErasedConstructor : _ * _ -> _) = - match args with - | [x1; x2] -> - let e1 = ConvExprToLinqInContext env x1 - let e2 = ConvExprToLinqInContext env x2 - let e1 = if addConvertLeft then Expression.Convert(e1, typedefof>.MakeGenericType [| e1.Type |]) |> asExpr else e1 - let e2 = if addConvertRight then Expression.Convert(e2, typedefof>.MakeGenericType [| e2.Type |]) |> asExpr else e2 - exprErasedConstructor(e1, e2) |> asExpr - | _ -> failConvert inp + /// Translate a unary operator + and transUnaryOp linqExpressionsCondition inp env x (exprErasedConstructor: _ * _ -> _) fallback = + let e = ConvExprToLinqInContext env x + if linqExpressionsCondition e.Type then + exprErasedConstructor(e, null) + else + let method = Reflection.MethodInfo.GetMethodFromHandle fallback :?> Reflection.MethodInfo + exprErasedConstructor(e, method.MakeGenericMethod [| getNonNullableType x.Type; getNonNullableType inp.Type |]) + |> asExpr + + /// Translate a shift operator + and transShiftOp inp env addConvertLeft x1 x2 addConvertRight (exprErasedConstructor: _ * _ * _ -> _) fallback = + let e1 = ConvExprToLinqInContext env x1 + let e2 = ConvExprToLinqInContext env x2 + let e1 = if addConvertLeft then Expression.Convert(e1, typedefof>.MakeGenericType [| e1.Type |]) |> asExpr else e1 + let e2 = if addConvertRight then Expression.Convert(e2, typedefof>.MakeGenericType [| e2.Type |]) |> asExpr else e2 + if e1.Type = e2.Type && isLinqExpressionsSimpleShift e1.Type e2.Type then + exprErasedConstructor(e1, e2, null) + else + let method = Reflection.MethodInfo.GetMethodFromHandle fallback :?> Reflection.MethodInfo + exprErasedConstructor(e1, e2, method.MakeGenericMethod [| getNonNullableType x1.Type; getNonNullableType x2.Type; getNonNullableType inp.Type |]) + |> asExpr + + /// Translate a non-shift binary operator that does not return a boolean + and transBinOp linqExpressionsCondition inp env addConvertLeft x1 x2 addConvertRight (exprErasedConstructor: _ * _ * _ -> _) fallback = + let e1 = ConvExprToLinqInContext env x1 + let e2 = ConvExprToLinqInContext env x2 + let e1 = if addConvertLeft then Expression.Convert(e1, typedefof>.MakeGenericType [| e1.Type |]) |> asExpr else e1 + let e2 = if addConvertRight then Expression.Convert(e2, typedefof>.MakeGenericType [| e2.Type |]) |> asExpr else e2 + if e1.Type = e2.Type && linqExpressionsCondition e1.Type then + exprErasedConstructor(e1, e2, null) + else + let method = Reflection.MethodInfo.GetMethodFromHandle fallback :?> Reflection.MethodInfo + exprErasedConstructor(e1, e2, method.MakeGenericMethod [| getNonNullableType x1.Type; getNonNullableType x2.Type; getNonNullableType inp.Type |]) + |> asExpr + + // The F# boolean structural equality / comparison operators do not take witnesses and the referenced methods are callable directly + /// Translate a non-shift binary operator without witnesses that does not return a boolean + and transBoolOpNoWitness linqExpressionsCondition env addConvertLeft x1 x2 addConvertRight (exprErasedConstructor: _ * _ * _ * _ -> _) method = + let e1 = ConvExprToLinqInContext env x1 + let e2 = ConvExprToLinqInContext env x2 + let e1' = if addConvertLeft then Expression.Convert(e1, typedefof>.MakeGenericType [| e1.Type |]) |> asExpr else e1 + let e2' = if addConvertRight then Expression.Convert(e2, typedefof>.MakeGenericType [| e2.Type |]) |> asExpr else e2 + if e1'.Type = e2'.Type && linqExpressionsCondition e1.Type then + // The false for (liftToNull: bool) indicates whether equality operators return a Nullable like in VB.NET (null when either argument is null) instead of bool like in C# (nulls equate to nulls). F# follows C# here. + exprErasedConstructor(e1', e2', false, null) + else + exprErasedConstructor(e1, e2, false, method) + |> asExpr + + // But the static boolean operators do take witnesses! + /// Translate a non-shift binary operator that returns a boolean + and transBoolOp linqExpressionsCondition inp env x1 x2 (exprErasedConstructor: _ * _ * _ * _ -> _) fallback = + let e1 = ConvExprToLinqInContext env x1 + let e2 = ConvExprToLinqInContext env x2 + if e1.Type = e2.Type && linqExpressionsCondition e1.Type then + // The false for (liftToNull: bool) indicates whether equality operators return a Nullable like in VB.NET (null when either argument is null) instead of bool like in C# (nulls equate to nulls). F# follows C# here. + exprErasedConstructor(e1, e2, false, null) + else + let method = Reflection.MethodInfo.GetMethodFromHandle fallback :?> Reflection.MethodInfo + exprErasedConstructor(e1, e2, false, method.MakeGenericMethod [| getNonNullableType x1.Type; getNonNullableType x2.Type; getNonNullableType inp.Type |]) + |> asExpr + + /// Translate a conversion operator + and transConv (inp: Expr) env isChecked x = + let e = ConvExprToLinqInContext env x + let exprErasedConstructor: _ * _ * _ -> _ = if isChecked then Expression.ConvertChecked else Expression.Convert + if isLinqExpressionsConvertible e.Type inp.Type then + exprErasedConstructor(e, inp.Type, null) + else + let method = Reflection.MethodInfo.GetMethodFromHandle (if isChecked then methodhandleof (fun x -> LanguagePrimitives.CheckedExplicitDynamic x) else methodhandleof (fun x -> LanguagePrimitives.ExplicitDynamic x)) :?> Reflection.MethodInfo + exprErasedConstructor(e, inp.Type, method.MakeGenericMethod [| getNonNullableType x.Type; getNonNullableType inp.Type |]) + |> asExpr and ConvObjArg env objOpt coerceTo : Expression = match objOpt with @@ -716,6 +914,4 @@ module LeafExpressionConverter = d.DynamicInvoke [| box () |] with :? System.Reflection.TargetInvocationException as exn -> raise exn.InnerException -#endif - - +#endif \ No newline at end of file diff --git a/src/FSharp.Core/Linq.fsi b/src/FSharp.Core/Linq.fsi index cfe61b4d1eb..13f3fa4187e 100644 --- a/src/FSharp.Core/Linq.fsi +++ b/src/FSharp.Core/Linq.fsi @@ -88,4 +88,4 @@ module LeafExpressionConverter = val SubstHelperRaw: Expr * Var[] * obj[] -> Expr val internal (|SpecificCallToMethod|_|): - System.RuntimeMethodHandle -> (Expr -> (Expr option * Type list * Expr list) option) + System.RuntimeMethodHandle -> (Expr -> (Expr option * Reflection.MethodInfo * Expr list) option) diff --git a/src/FSharp.Core/Query.fs b/src/FSharp.Core/Query.fs index 2701df53b1c..ae11d3835a1 100644 --- a/src/FSharp.Core/Query.fs +++ b/src/FSharp.Core/Query.fs @@ -314,26 +314,27 @@ module Query = match prop.GetGetMethod true with | null -> None | v -> Some v + let (|GenericArgs|) (minfo: MethodInfo) = minfo.GetGenericArguments() |> Array.toList // Match 'f x' let (|SpecificCall1|_|) q = let (|CallQ|_|) = (|SpecificCallToMethod|_|) q function - | CallQ (Some builderObj, tyargs, [arg1]) -> Some(builderObj, tyargs, arg1) + | CallQ (Some builderObj, GenericArgs tyargs, [arg1]) -> Some(builderObj, tyargs, arg1) | _ -> None // Match 'f x y' or 'f (x, y)' let (|SpecificCall2|_|) q = let (|CallQ|_|) = (|SpecificCallToMethod|_|) q function - | CallQ (Some builderObj, tyargs, [arg1; arg2]) -> Some(builderObj, tyargs, arg1, arg2) + | CallQ (Some builderObj, GenericArgs tyargs, [arg1; arg2]) -> Some(builderObj, tyargs, arg1, arg2) | _ -> None // Match 'f x y z' or 'f (x, y, z)' let (|SpecificCall3|_|) q = let (|CallQ|_|) = (|SpecificCallToMethod|_|) q function - | CallQ (Some builderObj, tyargs, [arg1; arg2; arg3]) -> Some(builderObj, tyargs, arg1, arg2, arg3) + | CallQ (Some builderObj, GenericArgs tyargs, [arg1; arg2; arg3]) -> Some(builderObj, tyargs, arg1, arg2, arg3) | _ -> None /// (fun (x, y) -> z) is represented as 'fun p -> let x = p#0 let y = p#1' etc. @@ -1286,7 +1287,7 @@ module Query = // rewrite has had the custom operator translation mechanism applied. In this case, the // body of the "for" will simply contain "yield". - | CallQueryBuilderFor (_, [_; qTy; immutResElemTy; _], [immutSource; Lambda(immutSelectorVar, immutSelector) ]) -> + | CallQueryBuilderFor (_, GenericArgs [_; qTy; immutResElemTy; _], [immutSource; Lambda(immutSelectorVar, immutSelector) ]) -> let mutSource, sourceConv = TransInner CanEliminate.Yes check immutSource @@ -1467,7 +1468,7 @@ module Query = | _ -> GroupingConv (immutKeySelector.Type, immutElementSelector.Type, selectorConv) TransInnerResult.Other(MakeGroupValBy(qTyIsIQueryable qTy, mutVar1.Type, mutKeySelector.Type, mutElementSelector.Type, mutSource, mutVar2, mutKeySelector, mutVar1, mutElementSelector)), conv - | CallJoin(_, [_; qTy; _; _; _], + | CallJoin(_, GenericArgs [_; qTy; _; _; _], [ immutOuterSource immutInnerSource Lambda(immutOuterKeyVar, immutOuterKeySelector) @@ -1491,7 +1492,7 @@ module Query = TransInnerResult.Other joinExpr, elementSelectorConv | CallGroupJoin - (_, [_; qTy; _; _; _], + (_, GenericArgs [_; qTy; _; _; _], [ immutOuterSource immutInnerSource Lambda(immutOuterKeyVar, immutOuterKeySelector) @@ -1517,7 +1518,7 @@ module Query = TransInnerResult.Other joinExpr, elementSelectorConv | CallLeftOuterJoin - (_, [ _; qTy; immutInnerSourceTy; _; _], + (_, GenericArgs [ _; qTy; immutInnerSourceTy; _; _], [ immutOuterSource immutInnerSource Lambda(immutOuterKeyVar, immutOuterKeySelector) diff --git a/src/FSharp.Core/prim-types.fs b/src/FSharp.Core/prim-types.fs index 40b4941045b..1d5dcc28d05 100644 --- a/src/FSharp.Core/prim-types.fs +++ b/src/FSharp.Core/prim-types.fs @@ -2518,7 +2518,6 @@ namespace Microsoft.FSharp.Core // this condition is used whenever ^T is resolved to a nominal type when ^T : ^T = (^T : (static member Zero : ^T) ()) - let inline GenericOne< ^T when ^T : (static member One : ^T) > : ^T = GenericOneDynamic<(^T)>() when ^T : int32 = 1 @@ -2541,10 +2540,21 @@ namespace Microsoft.FSharp.Core when ^T : ^T = (^T : (static member One : ^T) ()) type Type with - + /// Gets a single static non-conversion operator or method by types member inline this.GetSingleStaticMethodByTypes(name: string, parameterTypes: Type[]) = - let staticBindingFlags = (# "" 0b111000 : BindingFlags #) // BindingFlags.Static ||| BindingFlags.Public ||| BindingFlags.NonPublic - this.GetMethod(name, staticBindingFlags, null, parameterTypes, null ) + let staticBindingFlags = (# "" 0b111000 : BindingFlags #) // BindingFlags.Static ||| BindingFlags.Public ||| BindingFlags.NonPublic + this.GetMethod(name, staticBindingFlags, null, parameterTypes, null ) + + // Logic based on https://github.com/dotnet/runtime/blob/f66b142980b2b0df738158457458e003944dc7f6/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs#L662 + /// Gets a single static conversion operator by types + member inline this.GetSingleStaticConversionOperatorByTypes(fromType : Type, toType : Type) = + let staticBindingFlags = (# "" 0b111000 : BindingFlags #) // BindingFlags.Static ||| BindingFlags.Public ||| BindingFlags.NonPublic + let mutable ret = null + for mi in this.GetMethods staticBindingFlags do + if (System.String.Equals(mi.Name, "op_Implicit") || System.String.Equals(mi.Name, "op_Explicit")) && + (let p = mi.GetParameters() in p.Length = 1 && (get p 0).ParameterType.IsEquivalentTo fromType) && mi.ReturnType.IsEquivalentTo toType then + ret <- mi + ret let UnaryDynamicImpl nm : ('T -> 'U) = let aty = typeof<'T> @@ -2567,7 +2577,14 @@ namespace Microsoft.FSharp.Core match meth with | null -> - let ameth = aty.GetSingleStaticMethodByTypes(opName, [| aty |]) + let ameth = + if System.String.Equals(opName, "op_Explicit") then + let aty2 = typeof<'U> + match aty.GetSingleStaticConversionOperatorByTypes(aty, aty2) with + | null -> aty2.GetSingleStaticConversionOperatorByTypes(aty, aty2) + | ameth -> ameth + else + aty.GetSingleStaticMethodByTypes(opName, [| aty |]) match ameth with | null -> raise (NotSupportedException (SR.GetString(SR.dyInvOpAddCoerce))) | res -> @@ -2633,6 +2650,7 @@ namespace Microsoft.FSharp.Core elif type3eq<'T1, 'T2, 'U, uint16> then convPrim<_,'U> (# "conv.u2" (# "sub" (convPrim<_,uint16> x) (convPrim<_,uint16> y) : uint32 #) : uint16 #) elif type3eq<'T1, 'T2, 'U, sbyte> then convPrim<_,'U> (# "conv.i1" (# "sub" (convPrim<_,sbyte> x) (convPrim<_,sbyte> y) : int32 #) : sbyte #) elif type3eq<'T1, 'T2, 'U, byte> then convPrim<_,'U> (# "conv.u1" (# "sub" (convPrim<_,byte> x) (convPrim<_,byte> y) : uint32 #) : byte #) + elif type3eq<'T1, 'T2, 'U, char> then convPrim<_,'U> (# "conv.u1" (# "sub" (convPrim<_,char> x) (convPrim<_,char> y) : uint32 #) : char #) elif type3eq<'T1, 'T2, 'U, decimal> then convPrim<_,'U> (Decimal.op_Subtraction(convPrim<_,decimal> x, convPrim<_,decimal> y)) else BinaryOpDynamicImplTable.Invoke "op_Subtraction" x y @@ -2715,7 +2733,7 @@ namespace Microsoft.FSharp.Core elif type3eq<'T1, 'T2, 'U, unativeint> then convPrim<_,'U> (# "add.ovf.un" (convPrim<_,unativeint> x) (convPrim<_,unativeint> y) : unativeint #) elif type3eq<'T1, 'T2, 'U, int16> then convPrim<_,'U> (# "conv.ovf.i2" (# "add.ovf" (convPrim<_,int16> x) (convPrim<_,int16> y) : int32 #) : int16 #) elif type3eq<'T1, 'T2, 'U, uint16> then convPrim<_,'U> (# "conv.ovf.u2.un" (# "add.ovf.un" (convPrim<_,uint16> x) (convPrim<_,uint16> y) : uint32 #) : uint16 #) - elif type3eq<'T1, 'T2, 'U, char> then convPrim<_,'U> (# "conv.ovf.u2.un" (# "add.ovf.un" (convPrim<_,char> x) (convPrim<_,char> y) : uint32 #) : uint16 #) + elif type3eq<'T1, 'T2, 'U, char> then convPrim<_,'U> (# "conv.ovf.u2.un" (# "add.ovf.un" (convPrim<_,char> x) (convPrim<_,char> y) : uint32 #) : char #) elif type3eq<'T1, 'T2, 'U, sbyte> then convPrim<_,'U> (# "conv.ovf.i1" (# "add.ovf" (convPrim<_,sbyte> x) (convPrim<_,sbyte> y) : int32 #) : sbyte #) elif type3eq<'T1, 'T2, 'U, byte> then convPrim<_,'U> (# "conv.ovf.u1.un" (# "add.ovf.un" (convPrim<_,byte> x) (convPrim<_,byte> y) : uint32 #) : byte #) elif type3eq<'T1, 'T2, 'U, string> then convPrim<_,'U> (String.Concat(convPrim<_,string> x, convPrim<_,string> y)) @@ -2735,6 +2753,7 @@ namespace Microsoft.FSharp.Core elif type3eq<'T1, 'T2, 'U, unativeint> then convPrim<_,'U> (# "sub.ovf.un" (convPrim<_,unativeint> x) (convPrim<_,unativeint> y) : unativeint #) elif type3eq<'T1, 'T2, 'U, int16> then convPrim<_,'U> (# "conv.ovf.i2" (# "sub.ovf" (convPrim<_,int16> x) (convPrim<_,int16> y) : int32 #) : int16 #) elif type3eq<'T1, 'T2, 'U, uint16> then convPrim<_,'U> (# "conv.ovf.u2.un" (# "sub.ovf.un" (convPrim<_,uint16> x) (convPrim<_,uint16> y) : uint32 #) : uint16 #) + elif type3eq<'T1, 'T2, 'U, char> then convPrim<_,'U> (# "conv.ovf.u2.un" (# "sub.ovf.un" (convPrim<_,char> x) (convPrim<_,char> y) : uint32 #) : char #) elif type3eq<'T1, 'T2, 'U, sbyte> then convPrim<_,'U> (# "conv.ovf.i1" (# "sub.ovf" (convPrim<_,sbyte> x) (convPrim<_,sbyte> y) : int32 #) : sbyte #) elif type3eq<'T1, 'T2, 'U, byte> then convPrim<_,'U> (# "conv.ovf.u1.un" (# "sub.ovf.un" (convPrim<_,byte> x) (convPrim<_,byte> y) : uint32 #) : byte #) elif type3eq<'T1, 'T2, 'U, decimal> then convPrim<_,'U> (Decimal.op_Subtraction(convPrim<_,decimal> x, convPrim<_,decimal> y)) @@ -2866,7 +2885,7 @@ namespace Microsoft.FSharp.Core let ExplicitDynamic<'T, 'U> (value: 'T) : 'U = if typeeq<'U, byte> then if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.u1" (convPrim<_,sbyte> value) : byte #) - elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.u1" (convPrim<_,byte> value) : byte #) + elif typeeq<'T, byte> then convPrim<_,'U> value elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.u1" (convPrim<_,int16> value) : byte #) elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.u1" (convPrim<_,uint16> value) : byte #) elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.u1" (convPrim<_,int32> value) : byte #) @@ -2881,7 +2900,7 @@ namespace Microsoft.FSharp.Core elif typeeq<'T, string> then convPrim<_,'U> (ParseByte (convPrim<_,string> value)) else UnaryOpDynamicImplTable.Invoke "op_Explicit" value elif typeeq<'U, sbyte> then - if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.i1" (convPrim<_,sbyte> value) : sbyte #) + if typeeq<'T, sbyte> then convPrim<_,'U> value elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.i1" (convPrim<_,byte> value) : sbyte #) elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.i1" (convPrim<_,int16> value) : sbyte #) elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.i1" (convPrim<_,uint16> value) : sbyte #) @@ -2900,7 +2919,7 @@ namespace Microsoft.FSharp.Core if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.u2" (convPrim<_,sbyte> value) : uint16 #) elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.u2" (convPrim<_,byte> value) : uint16 #) elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.u2" (convPrim<_,int16> value) : uint16 #) - elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.u2" (convPrim<_,uint16> value) : uint16 #) + elif typeeq<'T, uint16> then convPrim<_,'U> value elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.u2" (convPrim<_,int32> value) : uint16 #) elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.u2" (convPrim<_,uint32> value) : uint16 #) elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.u2" (convPrim<_,int64> value) : uint16 #) @@ -2909,13 +2928,13 @@ namespace Microsoft.FSharp.Core elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.u2" (convPrim<_,unativeint> value) : uint16 #) elif typeeq<'T, float> then convPrim<_,'U> (# "conv.u2" (convPrim<_,float> value) : uint16 #) elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.u2" (convPrim<_,float32> value) : uint16 #) - elif typeeq<'T, char> then convPrim<_,'U> (# "conv.u2" (convPrim<_,char> value) : uint16 #) + elif typeeq<'T, char> then convPrim<_,'U> (# "" (convPrim<_,char> value) : uint16 #) elif typeeq<'T, string> then convPrim<_,'U> (ParseUInt16 (convPrim<_,string> value)) else UnaryOpDynamicImplTable.Invoke "op_Explicit" value elif typeeq<'U, int16> then if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.i2" (convPrim<_,sbyte> value) : int16 #) elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.i2" (convPrim<_,byte> value) : int16 #) - elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.i2" (convPrim<_,int16> value) : int16 #) + elif typeeq<'T, int16> then convPrim<_,'U> value elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.i2" (convPrim<_,uint16> value) : int16 #) elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.i2" (convPrim<_,int32> value) : int16 #) elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.i2" (convPrim<_,uint32> value) : int16 #) @@ -2934,7 +2953,7 @@ namespace Microsoft.FSharp.Core elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.u4" (convPrim<_,int16> value) : uint32 #) elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.u4" (convPrim<_,uint16> value) : uint32 #) elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.u4" (convPrim<_,int32> value) : uint32 #) - elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.u4" (convPrim<_,uint32> value) : uint32 #) + elif typeeq<'T, uint32> then convPrim<_,'U> value elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.u4" (convPrim<_,int64> value) : uint32 #) elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.u4" (convPrim<_,uint64> value) : uint32 #) elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.u4" (convPrim<_,nativeint> value) : uint32 #) @@ -2949,8 +2968,8 @@ namespace Microsoft.FSharp.Core elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.i4" (convPrim<_,byte> value) : int32 #) elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.i4" (convPrim<_,int16> value) : int32 #) elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.i4" (convPrim<_,uint16> value) : int32 #) - elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.i4" (convPrim<_,int32> value) : int32 #) - elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.i4" (convPrim<_,uint32> value) : int32 #) + elif typeeq<'T, int32> then convPrim<_,'U> value + elif typeeq<'T, uint32> then convPrim<_,'U> (# "" (convPrim<_,uint32> value) : int32 #) elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.i4" (convPrim<_,int64> value) : int32 #) elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.i4" (convPrim<_,uint64> value) : int32 #) elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.i4" (convPrim<_,nativeint> value) : int32 #) @@ -2968,7 +2987,7 @@ namespace Microsoft.FSharp.Core elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.i8" (convPrim<_,int32> value) : uint64 #) elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.u8" (convPrim<_,uint32> value) : uint64 #) elif typeeq<'T, int64> then convPrim<_,'U> (# "" (convPrim<_,int64> value) : uint64 #) - elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.i8" (convPrim<_,uint64> value) : uint64 #) + elif typeeq<'T, uint64> then convPrim<_,'U> value elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.i8" (convPrim<_,nativeint> value) : uint64 #) elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.u8" (convPrim<_,unativeint> value) : uint64 #) elif typeeq<'T, float> then convPrim<_,'U> (# "conv.u8" (convPrim<_,float> value) : uint64 #) @@ -2983,12 +3002,12 @@ namespace Microsoft.FSharp.Core elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.u8" (convPrim<_,uint16> value) : int64 #) elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.i8" (convPrim<_,int32> value) : int64 #) elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.u8" (convPrim<_,uint32> value) : int64 #) - elif typeeq<'T, int64> then convPrim<_,'U> (convPrim<_,int64> value) + elif typeeq<'T, int64> then convPrim<_,'U> value elif typeeq<'T, uint64> then convPrim<_,'U> (# "" (convPrim<_,uint64> value) : int64 #) elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.i8" (convPrim<_,nativeint> value) : int64 #) elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.u8" (convPrim<_,unativeint> value) : int64 #) - elif typeeq<'T, float> then convPrim<_,'U> (# "conv.u8" (convPrim<_,float> value) : int64 #) - elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.u8" (convPrim<_,float32> value) : int64 #) + elif typeeq<'T, float> then convPrim<_,'U> (# "conv.i8" (convPrim<_,float> value) : int64 #) + elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.i8" (convPrim<_,float32> value) : int64 #) elif typeeq<'T, char> then convPrim<_,'U> (# "conv.u8" (convPrim<_,char> value) : int64 #) elif typeeq<'T, string> then convPrim<_,'U> (ParseInt64 (convPrim<_,string> value)) else UnaryOpDynamicImplTable.Invoke "op_Explicit" value @@ -3004,6 +3023,7 @@ namespace Microsoft.FSharp.Core elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.r4" (convPrim<_,nativeint> value) : float32 #) elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.r.un conv.r4" (convPrim<_,unativeint> value) : float32 #) elif typeeq<'T, float> then convPrim<_,'U> (# "conv.r4" (convPrim<_,float> value) : float32 #) + // NOTE: float32 should convert its argument to 32-bit float even when applied to a higher precision float stored in a register. See devdiv2#49888. elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.r4" (convPrim<_,float32> value) : float32 #) elif typeeq<'T, char> then convPrim<_,'U> (# "conv.r.un conv.r4" (convPrim<_,char> value) : float32 #) elif typeeq<'T, string> then convPrim<_,'U> (ParseSingle (convPrim<_,string> value)) @@ -3019,6 +3039,7 @@ namespace Microsoft.FSharp.Core elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.r.un conv.r8" (convPrim<_,uint64> value) : float #) elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.r8" (convPrim<_,nativeint> value) : float #) elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.r.un conv.r8" (convPrim<_,unativeint> value) : float #) + // NOTE: float should convert its argument to 64-bit float even when applied to a higher precision float stored in a register. See devdiv2#49888. elif typeeq<'T, float> then convPrim<_,'U> (# "conv.r8" (convPrim<_,float> value) : float #) elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.r8" (convPrim<_,float32> value) : float #) elif typeeq<'T, char> then convPrim<_,'U> (# "conv.r.un conv.r8" (convPrim<_,char> value) : float #) @@ -3035,10 +3056,11 @@ namespace Microsoft.FSharp.Core elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.i" (convPrim<_,int64> value) : unativeint #) elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.u" (convPrim<_,uint64> value) : unativeint #) elif typeeq<'T, nativeint> then convPrim<_,'U> (# "" (convPrim<_,nativeint> value) : unativeint #) - elif typeeq<'T, unativeint> then convPrim<_,'U> (# "" (convPrim<_,unativeint> value) : unativeint #) + elif typeeq<'T, unativeint> then convPrim<_,'U> value elif typeeq<'T, float> then convPrim<_,'U> (# "conv.u" (convPrim<_,float> value) : unativeint #) elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.u" (convPrim<_,float32> value) : unativeint #) elif typeeq<'T, char> then convPrim<_,'U> (# "conv.u" (convPrim<_,char> value) : unativeint #) + elif typeeq<'T, decimal> then convPrim<_,'U> (# "conv.u" (Decimal.op_Explicit (convPrim<_,decimal> value) : uint64) : unativeint #) elif typeeq<'T, string> then convPrim<_,'U> (ParseUIntPtr (convPrim<_,string> value)) else UnaryOpDynamicImplTable.Invoke "op_Explicit" value elif typeeq<'U, nativeint> then @@ -3050,11 +3072,12 @@ namespace Microsoft.FSharp.Core elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.u" (convPrim<_,uint32> value) : nativeint #) elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.i" (convPrim<_,int64> value) : nativeint #) elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.u" (convPrim<_,uint64> value) : nativeint #) - elif typeeq<'T, nativeint> then convPrim<_,'U> (# "" (convPrim<_,nativeint> value) : nativeint #) + elif typeeq<'T, nativeint> then convPrim<_,'U> value elif typeeq<'T, unativeint> then convPrim<_,'U> (# "" (convPrim<_,unativeint> value) : nativeint #) elif typeeq<'T, float> then convPrim<_,'U> (# "conv.i" (convPrim<_,float> value) : nativeint #) elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.i" (convPrim<_,float32> value) : nativeint #) elif typeeq<'T, char> then convPrim<_,'U> (# "conv.u" (convPrim<_,char> value) : nativeint #) + elif typeeq<'T, decimal> then convPrim<_,'U> (# "conv.i" (Decimal.op_Explicit (convPrim<_,decimal> value) : int64) : nativeint #) elif typeeq<'T, string> then convPrim<_,'U> (ParseIntPtr (convPrim<_,string> value)) else UnaryOpDynamicImplTable.Invoke "op_Explicit" value elif typeeq<'U, char> then @@ -3070,7 +3093,8 @@ namespace Microsoft.FSharp.Core elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.u2" (convPrim<_,unativeint> value) : char #) elif typeeq<'T, float> then convPrim<_,'U> (# "conv.u2" (convPrim<_,float> value) : char #) elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.u2" (convPrim<_,float32> value) : char #) - elif typeeq<'T, char> then convPrim<_,'U> (# "conv.u2" (convPrim<_,char> value) : char #) + elif typeeq<'T, char> then convPrim<_,'U> value + elif typeeq<'T, decimal> then convPrim<_,'U> (Decimal.op_Explicit (convPrim<_,decimal> value) : char) elif typeeq<'T, string> then convPrim<_,'U> (Char.Parse (convPrim<_,string> value)) else UnaryOpDynamicImplTable.Invoke "op_Explicit" value elif typeeq<'U, decimal> then @@ -3086,7 +3110,240 @@ namespace Microsoft.FSharp.Core elif typeeq<'T, unativeint> then convPrim<_,'U> (Convert.ToDecimal (# "conv.u8" (convPrim<_,unativeint> value) : uint64 #)) elif typeeq<'T, float> then convPrim<_,'U> (Convert.ToDecimal (convPrim<_,float> value)) elif typeeq<'T, float32> then convPrim<_,'U> (Convert.ToDecimal (convPrim<_,float32> value)) - elif typeeq<'T, char> then convPrim<_,'U> (Convert.ToDecimal (convPrim<_,char> value)) + elif typeeq<'T, char> then convPrim<_,'U> (Convert.ToDecimal (# "" (convPrim<_,char> value) : uint16 #)) + elif typeeq<'T, decimal> then convPrim<_,'U> value + elif typeeq<'T, string> then convPrim<_,'U> (Decimal.Parse(convPrim<_,string> value, NumberStyles.Float,CultureInfo.InvariantCulture)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + else + UnaryOpDynamicImplTable.Invoke "op_Explicit" value + + let CheckedExplicitDynamic<'T, 'U> (value: 'T) : 'U = + if typeeq<'U, byte> then + if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.ovf.u1" (convPrim<_,sbyte> value) : byte #) + elif typeeq<'T, byte> then convPrim<_,'U> value + elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.ovf.u1" (convPrim<_,int16> value) : byte #) + elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.ovf.u1.un" (convPrim<_,uint16> value) : byte #) + elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.ovf.u1" (convPrim<_,int32> value) : byte #) + elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.ovf.u1.un" (convPrim<_,uint32> value) : byte #) + elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.ovf.u1" (convPrim<_,int64> value) : byte #) + elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.ovf.u1.un" (convPrim<_,uint64> value) : byte #) + elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.ovf.u1" (convPrim<_,nativeint> value) : byte #) + elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.ovf.u1.un" (convPrim<_,unativeint> value) : byte #) + elif typeeq<'T, float> then convPrim<_,'U> (# "conv.ovf.u1" (convPrim<_,float> value) : byte #) + elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.ovf.u1" (convPrim<_,float32> value) : byte #) + elif typeeq<'T, char> then convPrim<_,'U> (# "conv.ovf.u1.un" (convPrim<_,char> value) : byte #) + elif typeeq<'T, string> then convPrim<_,'U> (ParseByte (convPrim<_,string> value)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + elif typeeq<'U, sbyte> then + if typeeq<'T, sbyte> then convPrim<_,'U> value + elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.ovf.i1.un" (convPrim<_,byte> value) : sbyte #) + elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.ovf.i1" (convPrim<_,int16> value) : sbyte #) + elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.ovf.i1.un" (convPrim<_,uint16> value) : sbyte #) + elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.ovf.i1" (convPrim<_,int32> value) : sbyte #) + elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.ovf.i1.un" (convPrim<_,uint32> value) : sbyte #) + elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.ovf.i1" (convPrim<_,int64> value) : sbyte #) + elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.ovf.i1.un" (convPrim<_,uint64> value) : sbyte #) + elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.ovf.i1" (convPrim<_,nativeint> value) : sbyte #) + elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.ovf.i1.un" (convPrim<_,unativeint> value) : sbyte #) + elif typeeq<'T, float> then convPrim<_,'U> (# "conv.ovf.i1" (convPrim<_,float> value) : sbyte #) + elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.ovf.i1" (convPrim<_,float32> value) : sbyte #) + elif typeeq<'T, char> then convPrim<_,'U> (# "conv.ovf.i1.un" (convPrim<_,char> value) : sbyte #) + elif typeeq<'T, string> then convPrim<_,'U> (ParseSByte (convPrim<_,string> value)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + elif typeeq<'U, uint16> then + if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,sbyte> value) : uint16 #) + elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.ovf.u2.un" (convPrim<_,byte> value) : uint16 #) + elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,int16> value) : uint16 #) + elif typeeq<'T, uint16> then convPrim<_,'U> value + elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,int32> value) : uint16 #) + elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.ovf.u2.un" (convPrim<_,uint32> value) : uint16 #) + elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,int64> value) : uint16 #) + elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.ovf.u2.un" (convPrim<_,uint64> value) : uint16 #) + elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,nativeint> value) : uint16 #) + elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.ovf.u2.un" (convPrim<_,unativeint> value) : uint16 #) + elif typeeq<'T, float> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,float> value) : uint16 #) + elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,float32> value) : uint16 #) + elif typeeq<'T, char> then convPrim<_,'U> (# "" (convPrim<_,char> value) : uint16 #) + elif typeeq<'T, string> then convPrim<_,'U> (ParseUInt16 (convPrim<_,string> value)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + elif typeeq<'U, int16> then + if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.ovf.i2" (convPrim<_,sbyte> value) : int16 #) + elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.ovf.i2.un" (convPrim<_,byte> value) : int16 #) + elif typeeq<'T, int16> then convPrim<_,'U> value + elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.ovf.i2.un" (convPrim<_,uint16> value) : int16 #) + elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.ovf.i2" (convPrim<_,int32> value) : int16 #) + elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.ovf.i2.un" (convPrim<_,uint32> value) : int16 #) + elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.ovf.i2" (convPrim<_,int64> value) : int16 #) + elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.ovf.i2.un" (convPrim<_,uint64> value) : int16 #) + elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.ovf.i2" (convPrim<_,nativeint> value) : int16 #) + elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.ovf.i2.un" (convPrim<_,unativeint> value) : int16 #) + elif typeeq<'T, float> then convPrim<_,'U> (# "conv.ovf.i2" (convPrim<_,float> value) : int16 #) + elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.ovf.i2" (convPrim<_,float32> value) : int16 #) + elif typeeq<'T, char> then convPrim<_,'U> (# "conv.ovf.i2.un" (convPrim<_,char> value) : int16 #) + elif typeeq<'T, string> then convPrim<_,'U> (ParseInt16 (convPrim<_,string> value)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + elif typeeq<'U, uint32> then + if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.ovf.u4" (convPrim<_,sbyte> value) : uint32 #) + elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.ovf.u4.un" (convPrim<_,byte> value) : uint32 #) + elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.ovf.u4" (convPrim<_,int16> value) : uint32 #) + elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.ovf.u4.un" (convPrim<_,uint16> value) : uint32 #) + elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.ovf.u4" (convPrim<_,int32> value) : uint32 #) + elif typeeq<'T, uint32> then convPrim<_,'U> value + elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.ovf.u4" (convPrim<_,int64> value) : uint32 #) + elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.ovf.u4.un" (convPrim<_,uint64> value) : uint32 #) + elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.ovf.u4" (convPrim<_,nativeint> value) : uint32 #) + elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.ovf.u4.un" (convPrim<_,unativeint> value) : uint32 #) + elif typeeq<'T, float> then convPrim<_,'U> (# "conv.ovf.u4" (convPrim<_,float> value) : uint32 #) + elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.ovf.u4" (convPrim<_,float32> value) : uint32 #) + elif typeeq<'T, char> then convPrim<_,'U> (# "conv.ovf.u4.un" (convPrim<_,char> value) : uint32 #) + elif typeeq<'T, string> then convPrim<_,'U> (ParseUInt32 (convPrim<_,string> value)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + elif typeeq<'U, int32> then + if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.ovf.i4" (convPrim<_,sbyte> value) : int32 #) + elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.ovf.i4.un" (convPrim<_,byte> value) : int32 #) + elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.ovf.i4" (convPrim<_,int16> value) : int32 #) + elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.ovf.i4.un" (convPrim<_,uint16> value) : int32 #) + elif typeeq<'T, int32> then convPrim<_,'U> value + elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.ovf.i4.un" (convPrim<_,uint32> value) : int32 #) + elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.ovf.i4" (convPrim<_,int64> value) : int32 #) + elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.ovf.i4.un" (convPrim<_,uint64> value) : int32 #) + elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.ovf.i4" (convPrim<_,nativeint> value) : int32 #) + elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.ovf.i4.un" (convPrim<_,unativeint> value) : int32 #) + elif typeeq<'T, float> then convPrim<_,'U> (# "conv.ovf.i4" (convPrim<_,float> value) : int32 #) + elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.ovf.i4" (convPrim<_,float32> value) : int32 #) + elif typeeq<'T, char> then convPrim<_,'U> (# "conv.ovf.i4.un" (convPrim<_,char> value) : int32 #) + elif typeeq<'T, string> then convPrim<_,'U> (ParseInt32 (convPrim<_,string> value)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + elif typeeq<'U, uint64> then + if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.ovf.u8" (convPrim<_,sbyte> value) : uint64 #) + elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.ovf.u8.un" (convPrim<_,byte> value) : uint64 #) + elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.ovf.u8" (convPrim<_,int16> value) : uint64 #) + elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.ovf.u8.un" (convPrim<_,uint16> value) : uint64 #) + elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.ovf.u8" (convPrim<_,int32> value) : uint64 #) + elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.ovf.u8.un" (convPrim<_,uint32> value) : uint64 #) + elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.ovf.u8" (convPrim<_,int64> value) : uint64 #) + elif typeeq<'T, uint64> then convPrim<_,'U> value + elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.ovf.u8" (convPrim<_,nativeint> value) : uint64 #) + elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.ovf.u8.un" (convPrim<_,unativeint> value) : uint64 #) + elif typeeq<'T, float> then convPrim<_,'U> (# "conv.ovf.u8" (convPrim<_,float> value) : uint64 #) + elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.ovf.u8" (convPrim<_,float32> value) : uint64 #) + elif typeeq<'T, char> then convPrim<_,'U> (# "conv.ovf.u8.un" (convPrim<_,char> value) : uint64 #) + elif typeeq<'T, string> then convPrim<_,'U> (ParseUInt64 (convPrim<_,string> value)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + elif typeeq<'U, int64> then + if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.ovf.i8" (convPrim<_,sbyte> value) : int64 #) + elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.ovf.i8.un" (convPrim<_,byte> value) : int64 #) + elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.ovf.i8" (convPrim<_,int16> value) : int64 #) + elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.ovf.i8.un" (convPrim<_,uint16> value) : int64 #) + elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.ovf.i8" (convPrim<_,int32> value) : int64 #) + elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.ovf.i8.un" (convPrim<_,uint32> value) : int64 #) + elif typeeq<'T, int64> then convPrim<_,'U> value + elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.ovf.i8.un" (convPrim<_,uint64> value) : int64 #) + elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.ovf.i8" (convPrim<_,nativeint> value) : int64 #) + elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.ovf.i8.un" (convPrim<_,unativeint> value) : int64 #) + elif typeeq<'T, float> then convPrim<_,'U> (# "conv.ovf.i8" (convPrim<_,float> value) : int64 #) + elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.ovf.i8" (convPrim<_,float32> value) : int64 #) + elif typeeq<'T, char> then convPrim<_,'U> (# "conv.ovf.i8.un" (convPrim<_,char> value) : int64 #) + elif typeeq<'T, string> then convPrim<_,'U> (ParseInt64 (convPrim<_,string> value)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + elif typeeq<'U, float32> then + if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.r4" (convPrim<_,sbyte> value) : float32 #) + elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.r.un conv.r4" (convPrim<_,byte> value) : float32 #) + elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.r4" (convPrim<_,int16> value) : float32 #) + elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.r.un conv.r4" (convPrim<_,uint16> value) : float32 #) + elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.r4" (convPrim<_,int32> value) : float32 #) + elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.r.un conv.r4" (convPrim<_,uint32> value) : float32 #) + elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.r4" (convPrim<_,int64> value) : float32 #) + elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.r.un conv.r4" (convPrim<_,uint64> value) : float32 #) + elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.r4" (convPrim<_,nativeint> value) : float32 #) + elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.r.un conv.r4" (convPrim<_,unativeint> value) : float32 #) + elif typeeq<'T, float> then convPrim<_,'U> (# "conv.r4" (convPrim<_,float> value) : float32 #) + elif typeeq<'T, float32> then convPrim<_,'U> value + elif typeeq<'T, char> then convPrim<_,'U> (# "conv.r.un conv.r4" (convPrim<_,char> value) : float32 #) + elif typeeq<'T, string> then convPrim<_,'U> (ParseSingle (convPrim<_,string> value)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + elif typeeq<'U, float> then + if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.r8" (convPrim<_,sbyte> value) : float #) + elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.r.un conv.r8" (convPrim<_,byte> value) : float #) + elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.r8" (convPrim<_,int16> value) : float #) + elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.r.un conv.r8" (convPrim<_,uint16> value) : float #) + elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.r8" (convPrim<_,int32> value) : float #) + elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.r.un conv.r8" (convPrim<_,uint32> value) : float #) + elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.r8" (convPrim<_,int64> value) : float #) + elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.r.un conv.r8" (convPrim<_,uint64> value) : float #) + elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.r8" (convPrim<_,nativeint> value) : float #) + elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.r.un conv.r8" (convPrim<_,unativeint> value) : float #) + elif typeeq<'T, float> then convPrim<_,'U> value + elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.r8" (convPrim<_,float32> value) : float #) + elif typeeq<'T, char> then convPrim<_,'U> (# "conv.r.un conv.r8" (convPrim<_,char> value) : float #) + elif typeeq<'T, decimal> then convPrim<_,'U> (Convert.ToDouble(convPrim<_,decimal> value)) + elif typeeq<'T, string> then convPrim<_,'U> (ParseDouble (convPrim<_,string> value)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + elif typeeq<'U, unativeint> then + if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.ovf.u" (convPrim<_,sbyte> value) : unativeint #) + elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.ovf.u.un" (convPrim<_,byte> value) : unativeint #) + elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.ovf.u" (convPrim<_,int16> value) : unativeint #) + elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.ovf.u.un" (convPrim<_,uint16> value) : unativeint #) + elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.ovf.u" (convPrim<_,int32> value) : unativeint #) + elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.ovf.u.un" (convPrim<_,uint32> value) : unativeint #) + elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.ovf.u" (convPrim<_,int64> value) : unativeint #) + elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.ovf.u.un" (convPrim<_,uint64> value) : unativeint #) + elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.ovf.u" (convPrim<_,nativeint> value) : unativeint #) + elif typeeq<'T, unativeint> then convPrim<_,'U> value + elif typeeq<'T, float> then convPrim<_,'U> (# "conv.ovf.u" (convPrim<_,float> value) : unativeint #) + elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.ovf.u" (convPrim<_,float32> value) : unativeint #) + elif typeeq<'T, char> then convPrim<_,'U> (# "conv.ovf.u.un" (convPrim<_,char> value) : unativeint #) + elif typeeq<'T, decimal> then convPrim<_,'U> (# "conv.ovf.u" (Decimal.op_Explicit (convPrim<_,decimal> value) : uint64) : unativeint #) + elif typeeq<'T, string> then convPrim<_,'U> (ParseUIntPtr (convPrim<_,string> value)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + elif typeeq<'U, nativeint> then + if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.ovf.i" (convPrim<_,sbyte> value) : nativeint #) + elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.ovf.i.un" (convPrim<_,byte> value) : nativeint #) + elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.ovf.i" (convPrim<_,int16> value) : nativeint #) + elif typeeq<'T, uint16> then convPrim<_,'U> (# "conv.ovf.i.un" (convPrim<_,uint16> value) : nativeint #) + elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.ovf.i" (convPrim<_,int32> value) : nativeint #) + elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.ovf.i.un" (convPrim<_,uint32> value) : nativeint #) + elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.ovf.i" (convPrim<_,int64> value) : nativeint #) + elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.ovf.i.un" (convPrim<_,uint64> value) : nativeint #) + elif typeeq<'T, nativeint> then convPrim<_,'U> value + elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.ovf.i.un" (convPrim<_,unativeint> value) : nativeint #) + elif typeeq<'T, float> then convPrim<_,'U> (# "conv.ovf.i" (convPrim<_,float> value) : nativeint #) + elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.ovf.i" (convPrim<_,float32> value) : nativeint #) + elif typeeq<'T, char> then convPrim<_,'U> (# "conv.ovf.i.un" (convPrim<_,char> value) : nativeint #) + elif typeeq<'T, decimal> then convPrim<_,'U> (# "conv.ovf.i" (Decimal.op_Explicit (convPrim<_,decimal> value) : int64) : nativeint #) + elif typeeq<'T, string> then convPrim<_,'U> (ParseIntPtr (convPrim<_,string> value)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + elif typeeq<'U, char> then + if typeeq<'T, sbyte> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,sbyte> value) : char #) + elif typeeq<'T, byte> then convPrim<_,'U> (# "conv.ovf.u2.un" (convPrim<_,byte> value) : char #) + elif typeeq<'T, int16> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,int16> value) : char #) + elif typeeq<'T, uint16> then convPrim<_,'U> (# "" (convPrim<_,uint16> value) : char #) + elif typeeq<'T, int32> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,int32> value) : char #) + elif typeeq<'T, uint32> then convPrim<_,'U> (# "conv.ovf.u2.un" (convPrim<_,uint32> value) : char #) + elif typeeq<'T, int64> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,int64> value) : char #) + elif typeeq<'T, uint64> then convPrim<_,'U> (# "conv.ovf.u2.un" (convPrim<_,uint64> value) : char #) + elif typeeq<'T, nativeint> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,nativeint> value) : char #) + elif typeeq<'T, unativeint> then convPrim<_,'U> (# "conv.ovf.u2.un" (convPrim<_,unativeint> value) : char #) + elif typeeq<'T, float> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,float> value) : char #) + elif typeeq<'T, float32> then convPrim<_,'U> (# "conv.ovf.u2" (convPrim<_,float32> value) : char #) + elif typeeq<'T, char> then convPrim<_,'U> value + elif typeeq<'T, decimal> then convPrim<_,'U> (Decimal.op_Explicit (convPrim<_,decimal> value) : char) + elif typeeq<'T, string> then convPrim<_,'U> (System.Char.Parse (convPrim<_,string> value)) + else UnaryOpDynamicImplTable.Invoke "op_Explicit" value + elif typeeq<'U, decimal> then + if typeeq<'T, sbyte> then convPrim<_,'U> (Convert.ToDecimal (convPrim<_,sbyte> value)) + elif typeeq<'T, byte> then convPrim<_,'U> (Convert.ToDecimal (convPrim<_,byte> value)) + elif typeeq<'T, int16> then convPrim<_,'U> (Convert.ToDecimal (convPrim<_,int16> value)) + elif typeeq<'T, uint16> then convPrim<_,'U> (Convert.ToDecimal (convPrim<_,uint16> value)) + elif typeeq<'T, int32> then convPrim<_,'U> (Convert.ToDecimal (convPrim<_,int32> value)) + elif typeeq<'T, uint32> then convPrim<_,'U> (Convert.ToDecimal (convPrim<_,uint32> value)) + elif typeeq<'T, int64> then convPrim<_,'U> (Convert.ToDecimal (convPrim<_,int64> value)) + elif typeeq<'T, uint64> then convPrim<_,'U> (Convert.ToDecimal (convPrim<_,uint64> value)) + elif typeeq<'T, nativeint> then convPrim<_,'U> (Convert.ToDecimal (# "conv.i8" (convPrim<_,nativeint> value) : int64 #)) + elif typeeq<'T, unativeint> then convPrim<_,'U> (Convert.ToDecimal (# "conv.u8" (convPrim<_,unativeint> value) : uint64 #)) + elif typeeq<'T, float> then convPrim<_,'U> (Convert.ToDecimal (convPrim<_,float> value)) + elif typeeq<'T, float32> then convPrim<_,'U> (Convert.ToDecimal (convPrim<_,float32> value)) + elif typeeq<'T, char> then convPrim<_,'U> (Convert.ToDecimal (# "" (convPrim<_,char> value) : uint16 #)) elif typeeq<'T, decimal> then convPrim<'T,'U> value elif typeeq<'T, string> then convPrim<_,'U> (Decimal.Parse(convPrim<_,string> value, NumberStyles.Float,CultureInfo.InvariantCulture)) else UnaryOpDynamicImplTable.Invoke "op_Explicit" value @@ -3211,7 +3468,7 @@ namespace Microsoft.FSharp.Core elif type2eq<'T1, 'T2, char> && typeeq<'U, bool> then convPrim<_,'U> (not (# "ceq" (convPrim<_,char> x) (convPrim<_,char> y) : bool #)) elif type2eq<'T1, 'T2, decimal> && typeeq<'U, bool> then convPrim<_,'U> (Decimal.op_Inequality (convPrim<_,decimal> x, convPrim<_,decimal> y)) elif type2eq<'T1, 'T2, string> && typeeq<'U, bool> then convPrim<_,'U> (not (String.Equals (convPrim<_,string> x, convPrim<_,string> y))) - else BinaryOpDynamicImplTable.Invoke "op_Inequality" x y + else BinaryOpDynamicImplTable.Invoke "op_Inequality" x y type DivideByIntInfo = class end @@ -4054,6 +4311,7 @@ namespace Microsoft.FSharp.Core when ^T : unativeint and ^U : unativeint = (# "sub" x y : unativeint #) when ^T : int16 and ^U : int16 = (# "conv.i2" (# "sub" x y : int32 #) : int16 #) when ^T : uint16 and ^U : uint16 = (# "conv.u2" (# "sub" x y : uint32 #) : uint16 #) + when ^T : char and ^U : char = (# "conv.u2" (# "sub" x y : uint32 #) : char #) when ^T : sbyte and ^U : sbyte = (# "conv.i1" (# "sub" x y : int32 #) : sbyte #) when ^T : byte and ^U : byte = (# "conv.u1" (# "sub" x y : uint32 #) : byte #) when ^T : decimal and ^U : decimal = (# "" (Decimal.op_Subtraction((# "" x : decimal #),(# "" y : decimal #))) : ^V #) @@ -4283,7 +4541,7 @@ namespace Microsoft.FSharp.Core when ^T : uint16 = (# "conv.u1" value : byte #) when ^T : char = (# "conv.u1" value : byte #) when ^T : unativeint = (# "conv.u1" value : byte #) - when ^T : byte = (# "conv.u1" value : byte #) + when ^T : byte = (# "" value : byte #) // According to the somewhat subtle rules of static optimizations, // this condition is used whenever ^T is resolved to a nominal type or witnesses are available when ^T : ^T = (^T : (static member op_Explicit: ^T -> byte) (value)) @@ -4299,11 +4557,11 @@ namespace Microsoft.FSharp.Core when ^T : int32 = (# "conv.i1" value : sbyte #) when ^T : int16 = (# "conv.i1" value : sbyte #) when ^T : nativeint = (# "conv.i1" value : sbyte #) - when ^T : sbyte = (# "conv.i1" value : sbyte #) - when ^T : uint64 = (# "conv.i1" value : sbyte #) - when ^T : uint32 = (# "conv.i1" value : sbyte #) - when ^T : uint16 = (# "conv.i1" value : sbyte #) - when ^T : char = (# "conv.i1" value : sbyte #) + when ^T : sbyte = (# "" value : sbyte #) + when ^T : uint64 = (# "conv.i1" value : sbyte #) + when ^T : uint32 = (# "conv.i1" value : sbyte #) + when ^T : uint16 = (# "conv.i1" value : sbyte #) + when ^T : char = (# "conv.i1" value : sbyte #) when ^T : unativeint = (# "conv.i1" value : sbyte #) when ^T : byte = (# "conv.i1" value : sbyte #) // According to the somewhat subtle rules of static optimizations, @@ -4322,10 +4580,10 @@ namespace Microsoft.FSharp.Core when ^T : int16 = (# "conv.u2" value : uint16 #) when ^T : nativeint = (# "conv.u2" value : uint16 #) when ^T : sbyte = (# "conv.u2" value : uint16 #) - when ^T : uint64 = (# "conv.u2" value : uint16 #) - when ^T : uint32 = (# "conv.u2" value : uint16 #) - when ^T : uint16 = (# "conv.u2" value : uint16 #) - when ^T : char = (# "conv.u2" value : uint16 #) + when ^T : uint64 = (# "conv.u2" value : uint16 #) + when ^T : uint32 = (# "conv.u2" value : uint16 #) + when ^T : uint16 = (# "" value : uint16 #) + when ^T : char = (# "" value : uint16 #) when ^T : unativeint = (# "conv.u2" value : uint16 #) when ^T : byte = (# "conv.u2" value : uint16 #) // According to the somewhat subtle rules of static optimizations, @@ -4341,7 +4599,7 @@ namespace Microsoft.FSharp.Core when ^T : float32 = (# "conv.i2" value : int16 #) when ^T : int64 = (# "conv.i2" value : int16 #) when ^T : int32 = (# "conv.i2" value : int16 #) - when ^T : int16 = (# "conv.i2" value : int16 #) + when ^T : int16 = (# "" value : int16 #) when ^T : nativeint = (# "conv.i2" value : int16 #) when ^T : sbyte = (# "conv.i2" value : int16 #) when ^T : uint64 = (# "conv.i2" value : int16 #) @@ -4368,10 +4626,10 @@ namespace Microsoft.FSharp.Core when ^T : int32 = (# "" value : uint32 #) when ^T : int16 = (# "" value : uint32 #) when ^T : sbyte = (# "" value : uint32 #) - when ^T : uint64 = (# "conv.u4" value : uint32 #) - when ^T : uint32 = (# "conv.u4" value : uint32 #) - when ^T : uint16 = (# "conv.u4" value : uint32 #) - when ^T : char = (# "conv.u4" value : uint32 #) + when ^T : uint64 = (# "conv.u4" value : uint32 #) + when ^T : uint32 = (# "" value : uint32 #) + when ^T : uint16 = (# "conv.u4" value : uint32 #) + when ^T : char = (# "conv.u4" value : uint32 #) when ^T : unativeint = (# "conv.u4" value : uint32 #) when ^T : byte = (# "conv.u4" value : uint32 #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> uint32) (value)) @@ -4453,7 +4711,7 @@ namespace Microsoft.FSharp.Core when ^T : string = ParseInt64 (castToString value) when ^T : float = (# "conv.i8" value : int64 #) when ^T : float32 = (# "conv.i8" value : int64 #) - when ^T : int64 = (# "conv.i8" value : int64 #) + when ^T : int64 = (# "" value : int64 #) when ^T : int32 = (# "conv.i8" value : int64 #) when ^T : int16 = (# "conv.i8" value : int64 #) when ^T : nativeint = (# "conv.i8" value : int64 #) @@ -4517,18 +4775,19 @@ namespace Microsoft.FSharp.Core let inline decimal (value: ^T) = ExplicitDynamic<(^T), decimal> value when ^T : string = (Decimal.Parse(castToString value,NumberStyles.Float,CultureInfo.InvariantCulture)) - when ^T : float = (Convert.ToDecimal((# "" value : float #))) - when ^T : float32 = (Convert.ToDecimal((# "" value : float32 #))) - when ^T : int64 = (Convert.ToDecimal((# "" value : int64 #))) - when ^T : int32 = (Convert.ToDecimal((# "" value : int32 #))) - when ^T : int16 = (Convert.ToDecimal((# "" value : int16 #))) - when ^T : nativeint = (Convert.ToDecimal(int64 (# "" value : nativeint #))) - when ^T : sbyte = (Convert.ToDecimal((# "" value : sbyte #))) - when ^T : uint64 = (Convert.ToDecimal((# "" value : uint64 #))) - when ^T : uint32 = (Convert.ToDecimal((# "" value : uint32 #))) - when ^T : uint16 = (Convert.ToDecimal((# "" value : uint16 #))) - when ^T : unativeint = (Convert.ToDecimal(uint64 (# "" value : unativeint #))) - when ^T : byte = (Convert.ToDecimal((# "" value : byte #))) + when ^T : float = (Convert.ToDecimal((# "" value : float #))) + when ^T : float32 = (Convert.ToDecimal((# "" value : float32 #))) + when ^T : int64 = (Convert.ToDecimal((# "" value : int64 #))) + when ^T : int32 = (Convert.ToDecimal((# "" value : int32 #))) + when ^T : int16 = (Convert.ToDecimal((# "" value : int16 #))) + when ^T : nativeint = (Convert.ToDecimal(int64 (# "" value : nativeint #))) + when ^T : sbyte = (Convert.ToDecimal((# "" value : sbyte #))) + when ^T : uint64 = (Convert.ToDecimal((# "" value : uint64 #))) + when ^T : uint32 = (Convert.ToDecimal((# "" value : uint32 #))) + when ^T : uint16 = (Convert.ToDecimal((# "" value : uint16 #))) + when ^T : unativeint = (Convert.ToDecimal(uint64 (# "" value : unativeint #))) + when ^T : byte = (Convert.ToDecimal((# "" value : byte #))) + when ^T : char = (Convert.ToDecimal((# "" value : uint16 #))) // Don't use the char overload which unconditionally raises an exception when ^T : decimal = (# "" value : decimal #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> decimal) (value)) @@ -4553,7 +4812,8 @@ namespace Microsoft.FSharp.Core when ^T : uint16 = (# "conv.u" value : unativeint #) when ^T : char = (# "conv.u" value : unativeint #) when ^T : unativeint = (# "" value : unativeint #) - when ^T : byte = (# "conv.u" value : unativeint #) + when ^T : byte = (# "conv.u" value : unativeint #) + when ^T : decimal = (# "conv.u" (uint64 (# "" value : decimal #)) : unativeint #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> unativeint) (value)) [] @@ -4566,7 +4826,7 @@ namespace Microsoft.FSharp.Core when ^T : int64 = (# "conv.i" value : nativeint #) when ^T : int32 = (# "conv.i" value : nativeint #) when ^T : int16 = (# "conv.i" value : nativeint #) - when ^T : nativeint = (# "conv.i" value : nativeint #) + when ^T : nativeint = (# "" value : nativeint #) when ^T : sbyte = (# "conv.i" value : nativeint #) // Narrower unsigned types we zero-extend. // Same length unsigned types we leave as such (so unsigned MaxValue (all-bits-set) gets reinterpreted as -1). @@ -4578,6 +4838,7 @@ namespace Microsoft.FSharp.Core when ^T : char = (# "conv.u" value : nativeint #) when ^T : unativeint = (# "" value : nativeint #) when ^T : byte = (# "conv.i" value : nativeint #) + when ^T : decimal = (# "conv.i" (int64 (# "" value : decimal #)) : unativeint #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> nativeint) (value)) [] @@ -4651,8 +4912,8 @@ namespace Microsoft.FSharp.Core when ^T : sbyte = (# "conv.u2" value : char #) when ^T : uint64 = (# "conv.u2" value : char #) when ^T : uint32 = (# "conv.u2" value : char #) - when ^T : uint16 = (# "conv.u2" value : char #) - when ^T : char = (# "conv.u2" value : char #) + when ^T : uint16 = (# "" value : char #) + when ^T : char = (# "" value : char #) when ^T : unativeint = (# "conv.u2" value : char #) when ^T : byte = (# "conv.u2" value : char #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> char) (value)) @@ -4980,11 +5241,12 @@ namespace Microsoft.FSharp.Core when ^T : uint32 and ^U : uint32 = (# "sub.ovf.un" x y : uint32 #) when ^T : nativeint and ^U : nativeint = (# "sub.ovf" x y : nativeint #) when ^T : unativeint and ^U : unativeint = (# "sub.ovf.un" x y : unativeint #) - when ^T : int16 and ^U : int16 = (# "conv.ovf.i2" (# "sub.ovf" x y : int32 #) : int16 #) - when ^T : uint16 and ^U : uint16 = (# "conv.ovf.u2.un" (# "sub.ovf.un" x y : uint32 #) : uint16 #) - when ^T : sbyte and ^U : sbyte = (# "conv.ovf.i1" (# "sub.ovf" x y : int32 #) : sbyte #) - when ^T : byte and ^U : byte = (# "conv.ovf.u1.un" (# "sub.ovf.un" x y : uint32 #) : byte #) - when ^T : decimal and ^U : decimal = (# "" (Decimal.op_Subtraction((# "" x : decimal #),(# "" y : decimal #))) : ^V #) + when ^T : int16 and ^U : int16 = (# "conv.ovf.i2" (# "sub.ovf" x y : int32 #) : int16 #) + when ^T : uint16 and ^U : uint16 = (# "conv.ovf.u2.un" (# "sub.ovf.un" x y : uint32 #) : uint16 #) + when ^T : char and ^U : char = (# "conv.ovf.u2.un" (# "sub.ovf.un" x y : uint32 #) : char #) + when ^T : sbyte and ^U : sbyte = (# "conv.ovf.i1" (# "sub.ovf" x y : int32 #) : sbyte #) + when ^T : byte and ^U : byte = (# "conv.ovf.u1.un" (# "sub.ovf.un" x y : uint32 #) : byte #) + when ^T : decimal and ^U : decimal = (# "" (Decimal.op_Subtraction((# "" x : decimal #),(# "" y : decimal #))) : ^V #) when ^T : ^T = ((^T or ^U): (static member (-) : ^T * ^U -> ^V) (x,y)) [] @@ -5023,47 +5285,47 @@ namespace Microsoft.FSharp.Core [] [] let inline byte (value: ^T) = - ExplicitDynamic<(^T),byte> value - when ^T : string = ParseByte (castToString value) - when ^T : float = (# "conv.ovf.u1" value : byte #) - when ^T : float32 = (# "conv.ovf.u1" value : byte #) - when ^T : int64 = (# "conv.ovf.u1" value : byte #) - when ^T : int32 = (# "conv.ovf.u1" value : byte #) - when ^T : int16 = (# "conv.ovf.u1" value : byte #) - when ^T : nativeint = (# "conv.ovf.u1" value : byte #) - when ^T : sbyte = (# "conv.ovf.u1" value : byte #) - when ^T : uint64 = (# "conv.ovf.u1.un" value : byte #) - when ^T : uint32 = (# "conv.ovf.u1.un" value : byte #) - when ^T : uint16 = (# "conv.ovf.u1.un" value : byte #) - when ^T : char = (# "conv.ovf.u1.un" value : byte #) + CheckedExplicitDynamic<(^T),byte> value + when ^T : string = ParseByte (castToString value) + when ^T : float = (# "conv.ovf.u1" value : byte #) + when ^T : float32 = (# "conv.ovf.u1" value : byte #) + when ^T : int64 = (# "conv.ovf.u1" value : byte #) + when ^T : int32 = (# "conv.ovf.u1" value : byte #) + when ^T : int16 = (# "conv.ovf.u1" value : byte #) + when ^T : nativeint = (# "conv.ovf.u1" value : byte #) + when ^T : sbyte = (# "conv.ovf.u1" value : byte #) + when ^T : uint64 = (# "conv.ovf.u1.un" value : byte #) + when ^T : uint32 = (# "conv.ovf.u1.un" value : byte #) + when ^T : uint16 = (# "conv.ovf.u1.un" value : byte #) + when ^T : char = (# "conv.ovf.u1.un" value : byte #) when ^T : unativeint = (# "conv.ovf.u1.un" value : byte #) - when ^T : byte = (# "conv.ovf.u1.un" value : byte #) + when ^T : byte = (# "" value : byte #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> byte) (value)) [] [] let inline sbyte (value: ^T) = - ExplicitDynamic<(^T),sbyte> value - when ^T : string = ParseSByte (castToString value) - when ^T : float = (# "conv.ovf.i1" value : sbyte #) - when ^T : float32 = (# "conv.ovf.i1" value : sbyte #) - when ^T : int64 = (# "conv.ovf.i1" value : sbyte #) - when ^T : int32 = (# "conv.ovf.i1" value : sbyte #) - when ^T : int16 = (# "conv.ovf.i1" value : sbyte #) - when ^T : nativeint = (# "conv.ovf.i1" value : sbyte #) - when ^T : sbyte = (# "conv.ovf.i1" value : sbyte #) - when ^T : uint64 = (# "conv.ovf.i1.un" value : sbyte #) - when ^T : uint32 = (# "conv.ovf.i1.un" value : sbyte #) - when ^T : uint16 = (# "conv.ovf.i1.un" value : sbyte #) - when ^T : char = (# "conv.ovf.i1.un" value : sbyte #) + CheckedExplicitDynamic<(^T),sbyte> value + when ^T : string = ParseSByte (castToString value) + when ^T : float = (# "conv.ovf.i1" value : sbyte #) + when ^T : float32 = (# "conv.ovf.i1" value : sbyte #) + when ^T : int64 = (# "conv.ovf.i1" value : sbyte #) + when ^T : int32 = (# "conv.ovf.i1" value : sbyte #) + when ^T : int16 = (# "conv.ovf.i1" value : sbyte #) + when ^T : nativeint = (# "conv.ovf.i1" value : sbyte #) + when ^T : sbyte = (# "" value : sbyte #) + when ^T : uint64 = (# "conv.ovf.i1.un" value : sbyte #) + when ^T : uint32 = (# "conv.ovf.i1.un" value : sbyte #) + when ^T : uint16 = (# "conv.ovf.i1.un" value : sbyte #) + when ^T : char = (# "conv.ovf.i1.un" value : sbyte #) when ^T : unativeint = (# "conv.ovf.i1.un" value : sbyte #) - when ^T : byte = (# "conv.ovf.i1.un" value : sbyte #) + when ^T : byte = (# "conv.ovf.i1.un" value : sbyte #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> sbyte) (value)) [] [] let inline uint16 (value: ^T) = - ExplicitDynamic<(^T),uint16> value + CheckedExplicitDynamic<(^T),uint16> value when ^T : string = ParseUInt16 (castToString value) when ^T : float = (# "conv.ovf.u2" value : uint16 #) when ^T : float32 = (# "conv.ovf.u2" value : uint16 #) @@ -5074,8 +5336,8 @@ namespace Microsoft.FSharp.Core when ^T : sbyte = (# "conv.ovf.u2" value : uint16 #) when ^T : uint64 = (# "conv.ovf.u2.un" value : uint16 #) when ^T : uint32 = (# "conv.ovf.u2.un" value : uint16 #) - when ^T : uint16 = (# "conv.ovf.u2.un" value : uint16 #) - when ^T : char = (# "conv.ovf.u2.un" value : uint16 #) + when ^T : uint16 = (# "" value : uint16 #) + when ^T : char = (# "" value : uint16 #) when ^T : unativeint = (# "conv.ovf.u2.un" value : uint16 #) when ^T : byte = (# "conv.ovf.u2.un" value : uint16 #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> uint16) (value)) @@ -5083,7 +5345,7 @@ namespace Microsoft.FSharp.Core [] [] let inline char (value: ^T) = - ExplicitDynamic<(^T), char> value + CheckedExplicitDynamic<(^T), char> value when ^T : string = (Char.Parse(castToString value)) when ^T : float = (# "conv.ovf.u2" value : char #) when ^T : float32 = (# "conv.ovf.u2" value : char #) @@ -5094,8 +5356,8 @@ namespace Microsoft.FSharp.Core when ^T : sbyte = (# "conv.ovf.u2" value : char #) when ^T : uint64 = (# "conv.ovf.u2.un" value : char #) when ^T : uint32 = (# "conv.ovf.u2.un" value : char #) - when ^T : uint16 = (# "conv.ovf.u2.un" value : char #) - when ^T : char = (# "conv.ovf.u2.un" value : char #) + when ^T : uint16 = (# "" value : char #) + when ^T : char = (# "" value : char #) when ^T : unativeint = (# "conv.ovf.u2.un" value : char #) when ^T : byte = (# "conv.ovf.u2.un" value : char #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> char) (value)) @@ -5103,61 +5365,61 @@ namespace Microsoft.FSharp.Core [] [] let inline int16 (value: ^T) = - ExplicitDynamic<(^T), int16> value - when ^T : string = ParseInt16 (castToString value) - when ^T : float = (# "conv.ovf.i2" value : int16 #) - when ^T : float32 = (# "conv.ovf.i2" value : int16 #) - when ^T : int64 = (# "conv.ovf.i2" value : int16 #) - when ^T : int32 = (# "conv.ovf.i2" value : int16 #) - when ^T : int16 = (# "conv.ovf.i2" value : int16 #) - when ^T : nativeint = (# "conv.ovf.i2" value : int16 #) - when ^T : sbyte = (# "conv.ovf.i2" value : int16 #) - when ^T : uint64 = (# "conv.ovf.i2.un" value : int16 #) - when ^T : uint32 = (# "conv.ovf.i2.un" value : int16 #) - when ^T : uint16 = (# "conv.ovf.i2.un" value : int16 #) - when ^T : char = (# "conv.ovf.i2.un" value : int16 #) + CheckedExplicitDynamic<(^T), int16> value + when ^T : string = ParseInt16 (castToString value) + when ^T : float = (# "conv.ovf.i2" value : int16 #) + when ^T : float32 = (# "conv.ovf.i2" value : int16 #) + when ^T : int64 = (# "conv.ovf.i2" value : int16 #) + when ^T : int32 = (# "conv.ovf.i2" value : int16 #) + when ^T : int16 = (# "" value : int16 #) + when ^T : nativeint = (# "conv.ovf.i2" value : int16 #) + when ^T : sbyte = (# "conv.ovf.i2" value : int16 #) + when ^T : uint64 = (# "conv.ovf.i2.un" value : int16 #) + when ^T : uint32 = (# "conv.ovf.i2.un" value : int16 #) + when ^T : uint16 = (# "conv.ovf.i2.un" value : int16 #) + when ^T : char = (# "conv.ovf.i2.un" value : int16 #) when ^T : unativeint = (# "conv.ovf.i2.un" value : int16 #) - when ^T : byte = (# "conv.ovf.i2.un" value : int16 #) + when ^T : byte = (# "conv.ovf.i2.un" value : int16 #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> int16) (value)) [] [] let inline uint32 (value: ^T) = - ExplicitDynamic<(^T), uint32> value - when ^T : string = ParseUInt32 (castToString value) - when ^T : float = (# "conv.ovf.u4" value : uint32 #) - when ^T : float32 = (# "conv.ovf.u4" value : uint32 #) - when ^T : int64 = (# "conv.ovf.u4" value : uint32 #) - when ^T : int32 = (# "conv.ovf.u4" value : uint32 #) - when ^T : int16 = (# "conv.ovf.u4" value : uint32 #) - when ^T : nativeint = (# "conv.ovf.u4" value : uint32 #) - when ^T : sbyte = (# "conv.ovf.u4" value : uint32 #) - when ^T : uint64 = (# "conv.ovf.u4.un" value : uint32 #) - when ^T : uint32 = (# "conv.ovf.u4.un" value : uint32 #) - when ^T : uint16 = (# "conv.ovf.u4.un" value : uint32 #) - when ^T : char = (# "conv.ovf.u4.un" value : uint32 #) + CheckedExplicitDynamic<(^T), uint32> value + when ^T : string = ParseUInt32 (castToString value) + when ^T : float = (# "conv.ovf.u4" value : uint32 #) + when ^T : float32 = (# "conv.ovf.u4" value : uint32 #) + when ^T : int64 = (# "conv.ovf.u4" value : uint32 #) + when ^T : int32 = (# "conv.ovf.u4" value : uint32 #) + when ^T : int16 = (# "conv.ovf.u4" value : uint32 #) + when ^T : nativeint = (# "conv.ovf.u4" value : uint32 #) + when ^T : sbyte = (# "conv.ovf.u4" value : uint32 #) + when ^T : uint64 = (# "conv.ovf.u4.un" value : uint32 #) + when ^T : uint32 = (# "" value : uint32 #) + when ^T : uint16 = (# "conv.ovf.u4.un" value : uint32 #) + when ^T : char = (# "conv.ovf.u4.un" value : uint32 #) when ^T : unativeint = (# "conv.ovf.u4.un" value : uint32 #) - when ^T : byte = (# "conv.ovf.u4.un" value : uint32 #) + when ^T : byte = (# "conv.ovf.u4.un" value : uint32 #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> uint32) (value)) [] [] let inline int32 (value: ^T) = - ExplicitDynamic<(^T), int32> value - when ^T : string = ParseInt32 (castToString value) - when ^T : float = (# "conv.ovf.i4" value : int32 #) - when ^T : float32 = (# "conv.ovf.i4" value : int32 #) - when ^T : int64 = (# "conv.ovf.i4" value : int32 #) - when ^T : int32 = (# "conv.ovf.i4" value : int32 #) - when ^T : int16 = (# "conv.ovf.i4" value : int32 #) - when ^T : nativeint = (# "conv.ovf.i4" value : int32 #) - when ^T : sbyte = (# "conv.ovf.i4" value : int32 #) - when ^T : uint64 = (# "conv.ovf.i4.un" value : int32 #) - when ^T : uint32 = (# "conv.ovf.i4.un" value : int32 #) - when ^T : uint16 = (# "conv.ovf.i4.un" value : int32 #) - when ^T : char = (# "conv.ovf.i4.un" value : int32 #) + CheckedExplicitDynamic<(^T), int32> value + when ^T : string = ParseInt32 (castToString value) + when ^T : float = (# "conv.ovf.i4" value : int32 #) + when ^T : float32 = (# "conv.ovf.i4" value : int32 #) + when ^T : int64 = (# "conv.ovf.i4" value : int32 #) + when ^T : int32 = (# "" value : int32 #) + when ^T : int16 = (# "conv.ovf.i4" value : int32 #) + when ^T : nativeint = (# "conv.ovf.i4" value : int32 #) + when ^T : sbyte = (# "conv.ovf.i4" value : int32 #) + when ^T : uint64 = (# "conv.ovf.i4.un" value : int32 #) + when ^T : uint32 = (# "conv.ovf.i4.un" value : int32 #) + when ^T : uint16 = (# "conv.ovf.i4.un" value : int32 #) + when ^T : char = (# "conv.ovf.i4.un" value : int32 #) when ^T : unativeint = (# "conv.ovf.i4.un" value : int32 #) - when ^T : byte = (# "conv.ovf.i4.un" value : int32 #) + when ^T : byte = (# "conv.ovf.i4.un" value : int32 #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> int32) (value)) [] @@ -5166,81 +5428,83 @@ namespace Microsoft.FSharp.Core [] [] let inline uint64 (value: ^T) = - ExplicitDynamic<(^T), uint64> value - when ^T : string = ParseUInt64 (castToString value) - when ^T : float = (# "conv.ovf.u8" value : uint64 #) - when ^T : float32 = (# "conv.ovf.u8" value : uint64 #) - when ^T : int64 = (# "conv.ovf.u8" value : uint64 #) - when ^T : int32 = (# "conv.ovf.u8" value : uint64 #) - when ^T : int16 = (# "conv.ovf.u8" value : uint64 #) - when ^T : nativeint = (# "conv.ovf.u8" value : uint64 #) - when ^T : sbyte = (# "conv.ovf.u8" value : uint64 #) - when ^T : uint64 = (# "conv.ovf.u8.un" value : uint64 #) - when ^T : uint32 = (# "conv.ovf.u8.un" value : uint64 #) - when ^T : uint16 = (# "conv.ovf.u8.un" value : uint64 #) - when ^T : char = (# "conv.ovf.u8.un" value : uint64 #) + CheckedExplicitDynamic<(^T), uint64> value + when ^T : string = ParseUInt64 (castToString value) + when ^T : float = (# "conv.ovf.u8" value : uint64 #) + when ^T : float32 = (# "conv.ovf.u8" value : uint64 #) + when ^T : int64 = (# "conv.ovf.u8" value : uint64 #) + when ^T : int32 = (# "conv.ovf.u8" value : uint64 #) + when ^T : int16 = (# "conv.ovf.u8" value : uint64 #) + when ^T : nativeint = (# "conv.ovf.u8" value : uint64 #) + when ^T : sbyte = (# "conv.ovf.u8" value : uint64 #) + when ^T : uint64 = (# "" value : uint64 #) + when ^T : uint32 = (# "conv.ovf.u8.un" value : uint64 #) + when ^T : uint16 = (# "conv.ovf.u8.un" value : uint64 #) + when ^T : char = (# "conv.ovf.u8.un" value : uint64 #) when ^T : unativeint = (# "conv.ovf.u8.un" value : uint64 #) - when ^T : byte = (# "conv.ovf.u8.un" value : uint64 #) + when ^T : byte = (# "conv.ovf.u8.un" value : uint64 #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> uint64) (value)) [] [] let inline int64 (value: ^T) = - ExplicitDynamic<(^T), int64> value - when ^T : string = ParseInt64 (castToString value) - when ^T : float = (# "conv.ovf.i8" value : int64 #) - when ^T : float32 = (# "conv.ovf.i8" value : int64 #) - when ^T : int64 = (# "conv.ovf.i8" value : int64 #) - when ^T : int32 = (# "conv.ovf.i8" value : int64 #) - when ^T : int16 = (# "conv.ovf.i8" value : int64 #) - when ^T : nativeint = (# "conv.ovf.i8" value : int64 #) - when ^T : sbyte = (# "conv.ovf.i8" value : int64 #) - when ^T : uint64 = (# "conv.ovf.i8.un" value : int64 #) - when ^T : uint32 = (# "conv.ovf.i8.un" value : int64 #) - when ^T : uint16 = (# "conv.ovf.i8.un" value : int64 #) - when ^T : char = (# "conv.ovf.i8.un" value : int64 #) + CheckedExplicitDynamic<(^T), int64> value + when ^T : string = ParseInt64 (castToString value) + when ^T : float = (# "conv.ovf.i8" value : int64 #) + when ^T : float32 = (# "conv.ovf.i8" value : int64 #) + when ^T : int64 = (# "" value : int64 #) + when ^T : int32 = (# "conv.ovf.i8" value : int64 #) + when ^T : int16 = (# "conv.ovf.i8" value : int64 #) + when ^T : nativeint = (# "conv.ovf.i8" value : int64 #) + when ^T : sbyte = (# "conv.ovf.i8" value : int64 #) + when ^T : uint64 = (# "conv.ovf.i8.un" value : int64 #) + when ^T : uint32 = (# "conv.ovf.i8.un" value : int64 #) + when ^T : uint16 = (# "conv.ovf.i8.un" value : int64 #) + when ^T : char = (# "conv.ovf.i8.un" value : int64 #) when ^T : unativeint = (# "conv.ovf.i8.un" value : int64 #) - when ^T : byte = (# "conv.ovf.i8.un" value : int64 #) + when ^T : byte = (# "conv.ovf.i8.un" value : int64 #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> int64) (value)) [] [] let inline unativeint (value: ^T) = - ExplicitDynamic<(^T), unativeint> value - when ^T : string = ParseUIntPtr (castToString value) - when ^T : float = (# "conv.ovf.u" value : unativeint #) - when ^T : float32 = (# "conv.ovf.u" value : unativeint #) - when ^T : int64 = (# "conv.ovf.u" value : unativeint #) - when ^T : int32 = (# "conv.ovf.u" value : unativeint #) - when ^T : int16 = (# "conv.ovf.u" value : unativeint #) - when ^T : nativeint = (# "conv.ovf.u" value : unativeint #) - when ^T : sbyte = (# "conv.ovf.u" value : unativeint #) - when ^T : uint64 = (# "conv.ovf.u.un" value : unativeint #) - when ^T : uint32 = (# "conv.ovf.u.un" value : unativeint #) - when ^T : uint16 = (# "conv.ovf.u.un" value : unativeint #) - when ^T : char = (# "conv.ovf.u.un" value : unativeint #) - when ^T : unativeint = (# "conv.ovf.u.un" value : unativeint #) - when ^T : byte = (# "conv.ovf.u.un" value : unativeint #) + CheckedExplicitDynamic<(^T), unativeint> value + when ^T : string = ParseUIntPtr (castToString value) + when ^T : float = (# "conv.ovf.u" value : unativeint #) + when ^T : float32 = (# "conv.ovf.u" value : unativeint #) + when ^T : int64 = (# "conv.ovf.u" value : unativeint #) + when ^T : int32 = (# "conv.ovf.u" value : unativeint #) + when ^T : int16 = (# "conv.ovf.u" value : unativeint #) + when ^T : nativeint = (# "conv.ovf.u" value : unativeint #) + when ^T : sbyte = (# "conv.ovf.u" value : unativeint #) + when ^T : uint64 = (# "conv.ovf.u.un" value : unativeint #) + when ^T : uint32 = (# "conv.ovf.u.un" value : unativeint #) + when ^T : uint16 = (# "conv.ovf.u.un" value : unativeint #) + when ^T : char = (# "conv.ovf.u.un" value : unativeint #) + when ^T : unativeint = (# "" value : unativeint #) + when ^T : byte = (# "conv.ovf.u.un" value : unativeint #) + when ^T : decimal = (# "conv.ovf.u.un" (uint64 (# "" value : decimal #)) : unativeint #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> unativeint) (value)) [] [] let inline nativeint (value: ^T) = - ExplicitDynamic<(^T), nativeint> value - when ^T : string = ParseIntPtr (castToString value) - when ^T : float = (# "conv.ovf.i" value : nativeint #) - when ^T : float32 = (# "conv.ovf.i" value : nativeint #) - when ^T : int64 = (# "conv.ovf.i" value : nativeint #) - when ^T : int32 = (# "conv.ovf.i" value : nativeint #) - when ^T : int16 = (# "conv.ovf.i" value : nativeint #) - when ^T : nativeint = (# "conv.ovf.i" value : nativeint #) - when ^T : sbyte = (# "conv.ovf.i" value : nativeint #) - when ^T : uint64 = (# "conv.ovf.i.un" value : nativeint #) - when ^T : uint32 = (# "conv.ovf.i.un" value : nativeint #) - when ^T : uint16 = (# "conv.ovf.i.un" value : nativeint #) - when ^T : char = (# "conv.ovf.i.un" value : nativeint #) + CheckedExplicitDynamic<(^T), nativeint> value + when ^T : string = ParseIntPtr (castToString value) + when ^T : float = (# "conv.ovf.i" value : nativeint #) + when ^T : float32 = (# "conv.ovf.i" value : nativeint #) + when ^T : int64 = (# "conv.ovf.i" value : nativeint #) + when ^T : int32 = (# "conv.ovf.i" value : nativeint #) + when ^T : int16 = (# "conv.ovf.i" value : nativeint #) + when ^T : nativeint = (# "" value : nativeint #) + when ^T : sbyte = (# "conv.ovf.i" value : nativeint #) + when ^T : uint64 = (# "conv.ovf.i.un" value : nativeint #) + when ^T : uint32 = (# "conv.ovf.i.un" value : nativeint #) + when ^T : uint16 = (# "conv.ovf.i.un" value : nativeint #) + when ^T : char = (# "conv.ovf.i.un" value : nativeint #) when ^T : unativeint = (# "conv.ovf.i.un" value : nativeint #) - when ^T : byte = (# "conv.ovf.i.un" value : nativeint #) + when ^T : byte = (# "conv.ovf.i.un" value : nativeint #) + when ^T : decimal = (# "conv.ovf.i" (int64 (# "" value : decimal #)) : nativeint #) when ^T : ^T = (^T : (static member op_Explicit: ^T -> nativeint) (value)) module OperatorIntrinsics = diff --git a/src/FSharp.Core/prim-types.fsi b/src/FSharp.Core/prim-types.fsi index 70ee63e0c2d..a2c03fa1025 100644 --- a/src/FSharp.Core/prim-types.fsi +++ b/src/FSharp.Core/prim-types.fsi @@ -1542,6 +1542,10 @@ namespace Microsoft.FSharp.Core [] val ExplicitDynamic: value: 'T -> 'U + /// A compiler intrinsic that implements dynamic invocations related to checked conversion operators. + [] + val CheckedExplicitDynamic : value:'T -> 'U + /// A compiler intrinsic that implements dynamic invocations related to the '<' operator. [] val LessThanDynamic: x: 'T1 -> y: 'T2 -> 'U diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj index 42a431f2c27..9c0017aaed1 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj +++ b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj @@ -42,6 +42,7 @@ + diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs index 62db48e2ec9..a7672d9925f 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule1.fs @@ -246,10 +246,10 @@ type OperatorsModule1() = Assert.AreEqual(1, intbox) // string value - let stringlbox = Operators.box "string" - Assert.AreEqual("string", stringlbox) + let stringbox = Operators.box "string" + Assert.AreEqual("string", stringbox) - // null value + // null value let nullbox = Operators.box null CheckThrowsNullRefException(fun () -> nullbox.ToString() |> ignore) @@ -275,6 +275,14 @@ type OperatorsModule1() = let result = Operators.byte Int64.MinValue Assert.AreEqual(0uy, result) + // Overflow + let result = Operators.byte Single.MinValue + Assert.AreEqual(0uy, result) + + // Overflow + let result = Operators.byte Single.MaxValue + Assert.AreEqual(0uy, result) + // Overflow let result = Operators.byte Double.MinValue Assert.AreEqual(0uy, result) @@ -292,7 +300,7 @@ type OperatorsModule1() = Assert.AreEqual(4uy, result) // OverflowException, from decimal is always checked - CheckThrowsOverflowException(fun() -> Operators.byte Decimal.MinValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.byte Decimal.MinValue |> ignore) [] member _.ceil() = @@ -301,18 +309,44 @@ type OperatorsModule1() = Assert.AreEqual(1.0, minceil) // normal value - let normalceil = Operators.ceil 100.0 - Assert.AreEqual(100.0, normalceil) + let normalceil = Operators.ceil 100.1 + Assert.AreEqual(101.0, normalceil) // max value let maxceil = Operators.ceil 1.7E+308 Assert.AreEqual(1.7E+308, maxceil) + // float32 value + let float32ceil = Operators.ceil 100.1f + Assert.AreEqual(101f, float32ceil) + + // decimal value + let decimalceil = Operators.ceil 100.1m + Assert.AreEqual(101m, decimalceil) + [] member _.char() = // int type - let intchar = Operators.char 48 - Assert.AreEqual('0', intchar) + Assert.AreEqual('0', Operators.char 48) + Assert.AreEqual('0', Operators.char 48u) + Assert.AreEqual('0', Operators.char 48s) + Assert.AreEqual('0', Operators.char 48us) + Assert.AreEqual('0', Operators.char 48y) + Assert.AreEqual('0', Operators.char 48uy) + Assert.AreEqual('0', Operators.char 48L) + Assert.AreEqual('0', Operators.char 48uL) + Assert.AreEqual('0', Operators.char 48n) + Assert.AreEqual('0', Operators.char 48un) + Assert.AreEqual('0', Operators.char 48f) + Assert.AreEqual('0', Operators.char 48.) + Assert.AreEqual('0', Operators.char 48m) + + // Overflow + Assert.AreEqual('\000', Operators.char Single.MinValue) + Assert.AreEqual('\000', Operators.char Double.MinValue) + Assert.AreEqual('\000', Operators.char Single.MaxValue) + Assert.AreEqual('\000', Operators.char Double.MaxValue) + CheckThrowsOverflowException(fun () -> Operators.char Decimal.MinValue |> ignore) // string type let stringchar = Operators.char " " @@ -366,12 +400,24 @@ type OperatorsModule1() = member _.decimal () = // int value - let mindecimal = Operators.decimal (1) - Assert.AreEqual(1M, mindecimal) + let intdecimal = Operators.decimal (1) + Assert.AreEqual(1M, intdecimal) + + // nativeint value + let nativeintdecimal = Operators.decimal 1n + Assert.AreEqual(1M, nativeintdecimal) + + // unativeint value + let unativeintdecimal = Operators.decimal 1un + Assert.AreEqual(1M, unativeintdecimal) + + // char value + let chardecimal = Operators.decimal '\001' + Assert.AreEqual(1M, chardecimal) - // float value - let maxdecimal = Operators.decimal (1.0) - Assert.AreEqual(1M, maxdecimal) + // float value + let floatdecimal = Operators.decimal (1.0) + Assert.AreEqual(1M, floatdecimal) [] member _.decr() = @@ -416,6 +462,10 @@ type OperatorsModule1() = // char type let chardouble = Operators.float '0' Assert.AreEqual(48.0, chardouble) + + // decimal type + let decimaldouble = Operators.float 100m + Assert.AreEqual(100.0, decimaldouble) [] member _.enum() = @@ -424,7 +474,7 @@ type OperatorsModule1() = let intenum = Operators.enum intarg Assert.AreEqual(System.ConsoleColor.Black, intenum) - // big number + // big number let bigarg : int32 = 15 let charenum = Operators.enum bigarg Assert.AreEqual(System.ConsoleColor.White, charenum) @@ -488,6 +538,10 @@ type OperatorsModule1() = let charfloat = Operators.float '0' Assert.AreEqual((float)48, charfloat) + // decimal type + let intfloat = Operators.float 100m + Assert.AreEqual((float)100, intfloat) + [] member _.float32() = // int type @@ -497,16 +551,24 @@ type OperatorsModule1() = // char type let charfloat32 = Operators.float32 '0' Assert.AreEqual((float32)48, charfloat32) + + // decimal type + let intfloat32 = Operators.float32 100m + Assert.AreEqual((float32)100, intfloat32) [] member _.floor() = // float type - let intfloor = Operators.floor 100.9 - Assert.AreEqual(100.0, intfloor) + let floatfloor = Operators.floor 100.9 + Assert.AreEqual(100.0, floatfloor) // float32 type - let charfloor = Operators.floor ((float32)100.9) - Assert.AreEqual(100.0f, charfloor) + let float32floor = Operators.floor 100.9f + Assert.AreEqual(100.0f, float32floor) + + // decimal type + let decimalfloor = Operators.floor 100.9m + Assert.AreEqual(100m, decimalfloor) [] member _.fst() = diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs index 3abdeee4121..d4197529ea6 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs @@ -51,6 +51,14 @@ type OperatorsModule2() = let result = Operators.int 0 Assert.AreEqual(0, result) + // Overflow. + let result = Operators.int Single.MaxValue + Assert.AreEqual(Int32.MinValue, result) + + // Overflow + let result = Operators.int Single.MinValue + Assert.AreEqual(Int32.MinValue, result) + // Overflow let result = Operators.int Double.MaxValue Assert.AreEqual(Int32.MinValue, result) @@ -72,7 +80,7 @@ type OperatorsModule2() = Assert.AreEqual(Int32.MinValue, result) // OverflowException, from decimal is always checked - CheckThrowsOverflowException(fun() -> Operators.int Decimal.MinValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.int Decimal.MinValue |> ignore) [] member _.int16() = @@ -96,6 +104,14 @@ type OperatorsModule2() = let result = Operators.int16 "10" Assert.AreEqual(10s, result) + // Overflow. + let result = Operators.int16 Single.MaxValue + Assert.AreEqual(0s, result) + + // Overflow + let result = Operators.int16 Single.MinValue + Assert.AreEqual(0s, result) + // Overflow let result = Operators.int16 Double.MaxValue Assert.AreEqual(0s, result) @@ -116,7 +132,7 @@ type OperatorsModule2() = Assert.AreEqual(Int16.MinValue, result) // OverflowException, from decimal is always checked - CheckThrowsOverflowException(fun() -> Operators.int16 Decimal.MinValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.int16 Decimal.MinValue |> ignore) [] member _.int32() = @@ -140,6 +156,14 @@ type OperatorsModule2() = let result = Operators.int32 "10" Assert.AreEqual(10, result) + // Overflow. + let result = Operators.int32 Single.MaxValue + Assert.AreEqual(Int32.MinValue, result) + + // Overflow + let result = Operators.int32 Single.MinValue + Assert.AreEqual(Int32.MinValue, result) + // Overflow let result = Operators.int32 Double.MaxValue Assert.AreEqual(Int32.MinValue, result) @@ -161,7 +185,7 @@ type OperatorsModule2() = Assert.AreEqual(Int32.MinValue + 4, result) // OverflowException, from decimal is always checked - CheckThrowsOverflowException(fun() -> Operators.int32 Decimal.MinValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.int32 Decimal.MinValue |> ignore) [] member _.int64() = @@ -185,6 +209,14 @@ type OperatorsModule2() = let result = Operators.int64 "10" Assert.AreEqual(10L, result) + // Overflow. + let result = Operators.int64 Single.MaxValue + Assert.AreEqual(Int64.MinValue, result) + + // Overflow + let result = Operators.int64 Single.MinValue + Assert.AreEqual(Int64.MinValue, result) + // Overflow. let result = Operators.int64 Double.MaxValue Assert.AreEqual(Int64.MinValue, result) @@ -202,11 +234,11 @@ type OperatorsModule2() = Assert.AreEqual(9223372036854775807L, Int64.MaxValue) // OverflowException, from decimal is always checked - CheckThrowsOverflowException(fun() -> Operators.int64 Decimal.MinValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.int64 Decimal.MinValue |> ignore) [] member _.invalidArg() = - CheckThrowsArgumentException(fun() -> Operators.invalidArg "A" "B" |>ignore ) + CheckThrowsArgumentException(fun () -> Operators.invalidArg "A" "B" |>ignore ) [] @@ -328,6 +360,22 @@ type OperatorsModule2() = let result = Operators.nativeint 0 Assert.AreEqual(0n, result) + // Overflow Single.MaxValue is equal on 32 bits and 64 bits runtimes + let result = Operators.nativeint Single.MaxValue + if Info.isX86Runtime then + Assert.AreEqual(-2147483648n, result) + else + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) + + // Overflow (depends on pointer size) + let result = Operators.nativeint Single.MinValue + if Info.isX86Runtime then + Assert.AreEqual(-2147483648n, result) + else + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) + // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.nativeint Double.MaxValue if Info.isX86Runtime then @@ -396,7 +444,7 @@ type OperatorsModule2() = [] member _.nullArg() = - CheckThrowsArgumentNullException(fun() -> Operators.nullArg "A" |> ignore) + CheckThrowsArgumentNullException(fun () -> Operators.nullArg "A" |> ignore) [] @@ -429,11 +477,11 @@ type OperatorsModule2() = let result = Operators.pown System.Double.MaxValue System.Int32.MaxValue Assert.AreEqual(Double.PositiveInfinity, result) - CheckThrowsOverflowException(fun() -> Operators.pown System.Int32.MaxValue System.Int32.MaxValue |>ignore) + CheckThrowsOverflowException(fun () -> Operators.pown System.Int32.MaxValue System.Int32.MaxValue |>ignore) [] member _.raise() = - CheckThrowsArgumentException(fun()-> Operators.raise <| new ArgumentException("Invalid Argument ") |> ignore) + CheckThrowsArgumentException(fun () -> Operators.raise <| new ArgumentException("Invalid Argument ") |> ignore) [] @@ -559,7 +607,7 @@ type OperatorsModule2() = Assert.AreEqual(-128y, result) // OverflowException, from decimal is always checked - CheckThrowsOverflowException(fun() -> Operators.sbyte Decimal.MinValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.sbyte Decimal.MinValue |> ignore) [] member _.sign() = @@ -694,6 +742,10 @@ type OperatorsModule2() = let result = Operators.sizeof Assert.AreEqual(8, result) + // custom struct + let result = Operators.sizeof + Assert.AreEqual(12, result) + // reference type should have the same size as the IntPtr let result = Operators.sizeof Assert.AreEqual(IntPtr.Size, result) @@ -899,9 +951,25 @@ type OperatorsModule2() = // decimal let result = Operators.uint16 100M Assert.AreEqual(100us, result) + + // Overflow + let result = Operators.uint16 Single.MaxValue + Assert.AreEqual(0us, result) + + // Overflow + let result = Operators.uint16 Single.MinValue + Assert.AreEqual(0us, result) + + // Overflow + let result = Operators.uint16 Double.MaxValue + Assert.AreEqual(0us, result) + + // Overflow + let result = Operators.uint16 Double.MinValue + Assert.AreEqual(0us, result) // OverflowException, from decimal is always checked - CheckThrowsOverflowException(fun() -> Operators.uint16 Decimal.MinValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.uint16 Decimal.MinValue |> ignore) [] member _.uint32() = @@ -917,6 +985,14 @@ type OperatorsModule2() = let result = Operators.uint32 100M Assert.AreEqual(100u, result) + // Overflow + let result = Operators.uint32 Single.MaxValue + Assert.AreEqual(0u, result) + + // Overflow + let result = Operators.uint32 Single.MinValue + Assert.AreEqual(0u, result) + // Overflow let result = Operators.uint32 Double.MaxValue Assert.AreEqual(0u, result) @@ -943,7 +1019,7 @@ type OperatorsModule2() = Assert.AreEqual(84ul, result) // OverflowException, from decimal is always checked - CheckThrowsOverflowException(fun() -> Operators.uint32 Decimal.MinValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.uint32 Decimal.MinValue |> ignore) [] member _.uint64() = @@ -959,6 +1035,14 @@ type OperatorsModule2() = let result = Operators.uint64 100M Assert.AreEqual(100UL, result) + // Overflow + let result = Operators.uint64 Single.MaxValue + Assert.AreEqual(0UL, result) + + // Overflow + let result = Operators.uint64 Single.MinValue + Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + // Overflow let result = Operators.uint64 Double.MaxValue Assert.AreEqual(0UL, result) @@ -980,7 +1064,7 @@ type OperatorsModule2() = Assert.AreEqual(4UL, result) // OverflowException, from decimal is always checked - CheckThrowsOverflowException(fun() -> Operators.uint64 Decimal.MinValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.uint64 Decimal.MinValue |> ignore) [] member _.unativeint() = @@ -993,6 +1077,17 @@ type OperatorsModule2() = let result = Operators.unativeint 100.0 Assert.AreEqual(100un, result) + // Overflow Single.MaxValue is equal on 32 bits and 64 bits runtimes + let result = Operators.unativeint Single.MaxValue + Assert.AreEqual(0un, result) + + // Overflow (depends on pointer size) + let result = Operators.unativeint Single.MinValue + if Info.isX86Runtime then + Assert.AreEqual(0un, result) + else + Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes let result = Operators.unativeint Double.MaxValue Assert.AreEqual(0un, result) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleChecked.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleChecked.fs index bcd16f54e27..54da228aca6 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleChecked.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleChecked.fs @@ -21,12 +21,14 @@ type OperatorsModuleChecked() = let charByte = Operators.Checked.byte '0' Assert.AreEqual(48uy, charByte) - // boundary value + // boundary value let boundByte = Operators.Checked.byte 255.0 Assert.AreEqual(255uy, boundByte) // overflow exception CheckThrowsOverflowException(fun () -> Operators.Checked.byte 256 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.byte 256f |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.byte 256. |> ignore) // overflow exception CheckThrowsOverflowException(fun () -> 255uy + 1uy |> ignore) @@ -51,6 +53,8 @@ type OperatorsModuleChecked() = // overflow exception CheckThrowsOverflowException(fun () -> Operators.Checked.char (int64 Char.MaxValue + 1L) |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.char Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.char Double.MaxValue |> ignore) // overflow exception CheckThrowsOverflowException(fun () -> '\uFFFF' + '\u0001' |> ignore) @@ -72,7 +76,9 @@ type OperatorsModuleChecked() = Assert.AreEqual(32767, boundInt) // overflow exception - CheckThrowsOverflowException(fun() -> Operators.Checked.int 2147483648.0 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int 2147483648.0 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int Double.MaxValue |> ignore) // overflow exception CheckThrowsOverflowException(fun () -> Int32.MaxValue + 1 |> ignore) @@ -97,6 +103,8 @@ type OperatorsModuleChecked() = // overflow exception CheckThrowsOverflowException(fun () -> Operators.Checked.int16 32768.0 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int16 Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int16 Double.MaxValue |> ignore) // overflow exception CheckThrowsOverflowException(fun () -> Int16.MaxValue + 1s |> ignore) @@ -121,6 +129,8 @@ type OperatorsModuleChecked() = // overflow exception CheckThrowsOverflowException(fun () -> Operators.Checked.int32 2147483648.0 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int32 Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int32 Double.MaxValue |> ignore) // overflow exception CheckThrowsOverflowException(fun () -> Int32.MaxValue + 1 |> ignore) @@ -150,7 +160,9 @@ type OperatorsModuleChecked() = Assert.AreEqual(-9223372036854775808L, boundInt64) // overflow exception - CheckThrowsOverflowException(fun() -> Operators.Checked.int64 (float Int64.MaxValue + 1.0) |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int64 (float Int64.MaxValue + 1.0) |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int64 Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int64 Double.MaxValue |> ignore) // overflow exception CheckThrowsOverflowException(fun () -> Int64.MaxValue + 1L |> ignore) @@ -179,6 +191,8 @@ type OperatorsModuleChecked() = Operators.Checked.nativeint 2147483648.0 |> ignore else Operators.Checked.nativeint 9223372036854775808.0 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.nativeint Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.nativeint Double.MaxValue |> ignore) [] @@ -198,6 +212,8 @@ type OperatorsModuleChecked() = // overflow exception CheckThrowsOverflowException(fun () -> Operators.Checked.sbyte -256 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.sbyte Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.sbyte Double.MaxValue |> ignore) // overflow exception CheckThrowsOverflowException(fun () -> SByte.MaxValue + 1y |> ignore) @@ -220,7 +236,9 @@ type OperatorsModuleChecked() = let bounduint16 = Operators.Checked.uint16 65535.0 Assert.AreEqual(65535us, bounduint16) - CheckThrowsOverflowException(fun() -> Operators.Checked.uint16 65536.0 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint16 65536.0 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint16 Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint16 Double.MaxValue |> ignore) // overflow exception CheckThrowsOverflowException(fun () -> UInt16.MaxValue + 1us |> ignore) @@ -244,7 +262,9 @@ type OperatorsModuleChecked() = Assert.AreEqual(429496729u, bounduint32) // overflow exception - CheckThrowsOverflowException(fun () -> Operators.Checked.uint32(float UInt32.MaxValue + 1.0) |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint32 (float UInt32.MaxValue + 1.0) |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint32 Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint32 Double.MaxValue |> ignore) // overflow exception CheckThrowsOverflowException(fun () -> UInt32.MaxValue + 1u |> ignore) @@ -269,6 +289,8 @@ type OperatorsModuleChecked() = // overflow exception CheckThrowsOverflowException(fun () -> Operators.Checked.uint64 (float System.UInt64.MaxValue + 1.0) |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint64 Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint64 Double.MaxValue |> ignore) // overflow exception CheckThrowsOverflowException(fun () -> UInt64.MaxValue + 1UL |> ignore) @@ -302,5 +324,7 @@ type OperatorsModuleChecked() = else Operators.Checked.unativeint (float UInt64.MaxValue + 1.0) |> ignore ) + CheckThrowsOverflowException(fun () -> Operators.Checked.unativeint Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.unativeint Double.MaxValue |> ignore) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs new file mode 100644 index 00000000000..9af581dca52 --- /dev/null +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModuleDynamic.fs @@ -0,0 +1,1105 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +// Sync test content with OperatorsModule1.fs, OperatorsModule2.fs, and OperatorsModuleDynamic.fs + +namespace FSharp.Core.UnitTests.Operators + +open System +open Xunit + +#nowarn "1204" // CompilerMessage: This function is for use by dynamic invocations of F# code and should not be used directly +module OperatorsModuleDynamic = + + /// Check that the lambda throws an exception of the given type. Otherwise + /// calls Assert.Fail() + // Sync implementation with FSharp.Core.UnitTests.LibraryTestFx.CheckThrowsExn + let CheckThrowsExn<'a when 'a :> exn> (f : unit -> unit) = + try + let _ = f () + sprintf "Expected %O exception, got no exception" typeof<'a> |> Assert.Fail + with + | :? 'a -> () + | :? Reflection.TargetInvocationException as r when (r.InnerException :? 'a) -> () + | e -> sprintf "Expected %O or TargetInvocationException containing it, got: %O" typeof<'a> e |> Assert.Fail + let CheckThrowsOverflowException = CheckThrowsExn + + module Operators = + let byte<'T> = LanguagePrimitives.ExplicitDynamic<'T, byte> + let char<'T> = LanguagePrimitives.ExplicitDynamic<'T, char> + let double<'T> = LanguagePrimitives.ExplicitDynamic<'T, double> + let decimal<'T> = LanguagePrimitives.ExplicitDynamic<'T, decimal> + let float<'T> = LanguagePrimitives.ExplicitDynamic<'T, float> + let float32<'T> = LanguagePrimitives.ExplicitDynamic<'T, float32> + let nativeint<'T> = LanguagePrimitives.ExplicitDynamic<'T, nativeint> + let int<'T> = LanguagePrimitives.ExplicitDynamic<'T, int> + let int8<'T> = LanguagePrimitives.ExplicitDynamic<'T, int8> + let int16<'T> = LanguagePrimitives.ExplicitDynamic<'T, int16> + let int32<'T> = LanguagePrimitives.ExplicitDynamic<'T, int32> + let int64<'T> = LanguagePrimitives.ExplicitDynamic<'T, int64> + let sbyte<'T> = LanguagePrimitives.ExplicitDynamic<'T, sbyte> + let single<'T> = LanguagePrimitives.ExplicitDynamic<'T, single> + let uint<'T> = LanguagePrimitives.ExplicitDynamic<'T, uint> + let uint8<'T> = LanguagePrimitives.ExplicitDynamic<'T, uint8> + let uint16<'T> = LanguagePrimitives.ExplicitDynamic<'T, uint16> + let uint32<'T> = LanguagePrimitives.ExplicitDynamic<'T, uint32> + let uint64<'T> = LanguagePrimitives.ExplicitDynamic<'T, uint64> + let unativeint<'T> = LanguagePrimitives.ExplicitDynamic<'T, unativeint> + module Checked = + let byte<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, byte> + let char<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, char> + let double<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, double> + let decimal<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, decimal> + let float<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, float> + let float32<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, float32> + let nativeint<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, nativeint> + let int<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, int> + let int8<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, int8> + let int16<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, int16> + let int32<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, int32> + let int64<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, int64> + let sbyte<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, sbyte> + let single<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, single> + let uint<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, uint> + let uint8<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, uint8> + let uint16<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, uint16> + let uint32<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, uint32> + let uint64<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, uint64> + let unativeint<'T> = LanguagePrimitives.CheckedExplicitDynamic<'T, unativeint> + + [] + let byte() = + // int type + let intByte = Operators.byte 100 + Assert.AreEqual(100uy, intByte) + + // char type + let charByte = Operators.byte '0' + Assert.AreEqual(48uy, charByte) + + // boundary value + let boundByte = Operators.byte 255.0 + Assert.AreEqual(255uy, boundByte) + + // Overflow + let result = Operators.byte Int64.MaxValue + Assert.AreEqual(Byte.MaxValue, result) + + // Overflow + let result = Operators.byte Int64.MinValue + Assert.AreEqual(0uy, result) + + // Overflow + let result = Operators.byte Single.MinValue + Assert.AreEqual(0uy, result) + + // Overflow + let result = Operators.byte Single.MaxValue + Assert.AreEqual(0uy, result) + + // Overflow + let result = Operators.byte Double.MinValue + Assert.AreEqual(0uy, result) + + // Overflow + let result = Operators.byte Double.MaxValue + Assert.AreEqual(0uy, result) + + // Overflow + let result = Operators.byte (Int64.MaxValue * 8L) + Assert.AreEqual(248uy, result) // bit-complement + + // Overflow + let result = 255uy + 5uy + Assert.AreEqual(4uy, result) + + // OverflowException, from decimal is always checked + CheckThrowsOverflowException(fun () -> Operators.byte Decimal.MinValue |> ignore) + + [] + let char() = + // int type + Assert.AreEqual('0', Operators.char 48) + Assert.AreEqual('0', Operators.char 48u) + Assert.AreEqual('0', Operators.char 48s) + Assert.AreEqual('0', Operators.char 48us) + Assert.AreEqual('0', Operators.char 48y) + Assert.AreEqual('0', Operators.char 48uy) + Assert.AreEqual('0', Operators.char 48L) + Assert.AreEqual('0', Operators.char 48uL) + Assert.AreEqual('0', Operators.char 48n) + Assert.AreEqual('0', Operators.char 48un) + Assert.AreEqual('0', Operators.char 48f) + Assert.AreEqual('0', Operators.char 48.) + Assert.AreEqual('0', Operators.char 48m) + + // Overflow + Assert.AreEqual('\000', Operators.char Single.MinValue) + Assert.AreEqual('\000', Operators.char Double.MinValue) + Assert.AreEqual('\000', Operators.char Single.MaxValue) + Assert.AreEqual('\000', Operators.char Double.MaxValue) + CheckThrowsOverflowException(fun () -> Operators.char Decimal.MinValue |> ignore) + + // string type + let stringchar = Operators.char " " + Assert.AreEqual(' ', stringchar) + + + [] + let decimal () = + + // int value + let intdecimal = Operators.decimal (1) + Assert.AreEqual(1M, intdecimal) + + // nativeint value + let nativeintdecimal = Operators.decimal 1n + Assert.AreEqual(1M, nativeintdecimal) + + // unativeint value + let unativeintdecimal = Operators.decimal 1un + Assert.AreEqual(1M, unativeintdecimal) + + // char value + let chardecimal = Operators.decimal '\001' + Assert.AreEqual(1M, chardecimal) + + // float value + let floatdecimal = Operators.decimal (1.0) + Assert.AreEqual(1M, floatdecimal) + + [] + let double() = + // int type + let intdouble = Operators.float 100 + Assert.AreEqual(100.0, intdouble) + + // char type + let chardouble = Operators.float '0' + Assert.AreEqual(48.0, chardouble) + + // decimal type + let decimaldouble = Operators.float 100m + Assert.AreEqual(100.0, decimaldouble) + + [] + let float() = + // int type + let intfloat = Operators.float 100 + Assert.AreEqual((float)100, intfloat) + + // char type + let charfloat = Operators.float '0' + Assert.AreEqual((float)48, charfloat) + + // decimal type + let intfloat = Operators.float 100m + Assert.AreEqual((float)100, intfloat) + + [] + let float32() = + // int type + let intfloat32 = Operators.float32 100 + Assert.AreEqual((float32)100, intfloat32) + + // char type + let charfloat32 = Operators.float32 '0' + Assert.AreEqual((float32)48, charfloat32) + + // decimal type + let intfloat32 = Operators.float32 100m + Assert.AreEqual((float32)100, intfloat32) + + [] + let int() = + // int + let result = Operators.int 10 + Assert.AreEqual(10, result) + + // string + let result = Operators.int "10" + Assert.AreEqual(10, result) + + // double + let result = Operators.int 10.0 + Assert.AreEqual(10, result) + + // negative + let result = Operators.int -10 + Assert.AreEqual(-10, result) + + // zero + let result = Operators.int 0 + Assert.AreEqual(0, result) + + // Overflow + let result = Operators.int Single.MaxValue + Assert.AreEqual(Int32.MinValue, result) + + // Overflow + let result = Operators.int Single.MinValue + Assert.AreEqual(Int32.MinValue, result) + + // Overflow + let result = Operators.int Double.MaxValue + Assert.AreEqual(Int32.MinValue, result) + + // Overflow + let result = Operators.int Double.MinValue + Assert.AreEqual(Int32.MinValue, result) + + // Overflow + let result = Operators.int Int64.MaxValue + Assert.AreEqual(-1, result) + + // Overflow + let result = Operators.int Int64.MinValue + Assert.AreEqual(0, result) + + // Overflow + let result = Int32.MaxValue + 1 + Assert.AreEqual(Int32.MinValue, result) + + // OverflowException, from decimal is always checked + CheckThrowsOverflowException(fun () -> Operators.int Decimal.MinValue |> ignore) + + [] + let int16() = + // int + let result = Operators.int16 10 + Assert.AreEqual(10s, result) + + // double + let result = Operators.int16 10.0 + Assert.AreEqual(10s, result) + + // negative + let result = Operators.int16 -10 + Assert.AreEqual(-10s, result) + + // zero + let result = Operators.int16 0 + Assert.AreEqual(0s, result) + + // string + let result = Operators.int16 "10" + Assert.AreEqual(10s, result) + + // Overflow + let result = Operators.int16 Single.MaxValue + Assert.AreEqual(0s, result) + + // Overflow + let result = Operators.int16 Single.MinValue + Assert.AreEqual(0s, result) + + // Overflow + let result = Operators.int16 Double.MaxValue + Assert.AreEqual(0s, result) + + // Overflow + let result = Operators.int16 Double.MinValue + Assert.AreEqual(0s, result) + + let result = Operators.int16 Int64.MaxValue + Assert.AreEqual(-1s, result) + + // Overflow + let result = Operators.int16 Int64.MinValue + Assert.AreEqual(0s, result) + + // Overflow + let result = Int16.MaxValue + 1s + Assert.AreEqual(Int16.MinValue, result) + + // OverflowException, from decimal is always checked + CheckThrowsOverflowException(fun () -> Operators.int16 Decimal.MinValue |> ignore) + + [] + let int32() = + // int + let result = Operators.int32 10 + Assert.AreEqual(10, result) + + // double + let result = Operators.int32 10.0 + Assert.AreEqual(10, result) + + // negative + let result = Operators.int32 -10 + Assert.AreEqual(-10, result) + + // zero + let result = Operators.int32 0 + Assert.AreEqual(0, result) + + // string + let result = Operators.int32 "10" + Assert.AreEqual(10, result) + + // Overflow + let result = Operators.int32 Single.MaxValue + Assert.AreEqual(Int32.MinValue, result) + + // Overflow + let result = Operators.int32 Single.MinValue + Assert.AreEqual(Int32.MinValue, result) + + // Overflow + let result = Operators.int32 Double.MaxValue + Assert.AreEqual(Int32.MinValue, result) + + // Overflow + let result = Operators.int32 Double.MinValue + Assert.AreEqual(Int32.MinValue, result) + + // Overflow + let result = Operators.int32 Int64.MaxValue + Assert.AreEqual(-1, result) + + // Overflow + let result = Operators.int32 Int64.MinValue + Assert.AreEqual(0, result) + + // Overflow + let result = Int32.MaxValue + 5 + Assert.AreEqual(Int32.MinValue + 4, result) + + // OverflowException, from decimal is always checked + CheckThrowsOverflowException(fun () -> Operators.int32 Decimal.MinValue |> ignore) + + [] + let int64() = + // int + let result = Operators.int64 10 + Assert.AreEqual(10L, result) + + // double + let result = Operators.int64 10.0 + Assert.AreEqual(10L, result) + + // negative + let result = Operators.int64 -10 + Assert.AreEqual(-10L, result) + + // zero + let result = Operators.int64 0 + Assert.AreEqual(0L, result) + + // string + let result = Operators.int64 "10" + Assert.AreEqual(10L, result) + + // Overflow. + let result = Operators.int64 Single.MaxValue + Assert.AreEqual(Int64.MinValue, result) + + // Overflow + let result = Operators.int64 Single.MinValue + Assert.AreEqual(Int64.MinValue, result) + + // Overflow. + let result = Operators.int64 Double.MaxValue + Assert.AreEqual(Int64.MinValue, result) + + // Overflow + let result = Operators.int64 Double.MinValue + Assert.AreEqual(Int64.MinValue, result) + + // Overflow + let result = Operators.int64 UInt64.MaxValue + Assert.AreEqual(-1L, result) + + // max and min value as literals (this breaks compilation if the lexer fails) + Assert.AreEqual(-9223372036854775808L, Int64.MinValue) + Assert.AreEqual(9223372036854775807L, Int64.MaxValue) + + // OverflowException, from decimal is always checked + CheckThrowsOverflowException(fun () -> Operators.int64 Decimal.MinValue |> ignore) + + + [] + let nativeint() = + // int + let result = Operators.nativeint 10 + Assert.AreEqual(10n, result) + + // double + let result = Operators.nativeint 10.0 + Assert.AreEqual(10n, result) + + // int64 + let result = Operators.nativeint 10L + Assert.AreEqual(10n, result) + + // negative + let result = Operators.nativeint -10 + Assert.AreEqual(-10n, result) + + // zero + let result = Operators.nativeint 0 + Assert.AreEqual(0n, result) + + // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes + let result = Operators.nativeint Single.MaxValue + if Info.isX86Runtime then + Assert.AreEqual(-2147483648n, result) + else + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) + + // Overflow (depends on pointer size) + let result = Operators.nativeint Single.MinValue + if Info.isX86Runtime then + Assert.AreEqual(-2147483648n, result) + else + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) + + // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes + let result = Operators.nativeint Double.MaxValue + if Info.isX86Runtime then + Assert.AreEqual(-2147483648n, result) + else + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) + + // Overflow (depends on pointer size) + let result = Operators.nativeint Double.MinValue + if Info.isX86Runtime then + Assert.AreEqual(-2147483648n, result) + else + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) + + // Overflow (depends on pointer size) + let result = Operators.nativeint Int64.MinValue + if Info.isX86Runtime then + Assert.AreEqual(0n, result) + else + // Cannot use -9223372036854775808, compiler doesn't allow it, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual(-9223372036854775807n - 1n, result) + + // Overflow (depends on pointer size) + if Info.isX86Runtime then + let result = nativeint Int32.MaxValue + 5n + Assert.AreEqual(-2147483644n, result) + else + let result = nativeint Int64.MaxValue + 5n + Assert.AreEqual(-9223372036854775804n, result) + + // Overflow (depends on pointer size) + let result = Operators.nativeint System.Double.MaxValue + if Info.isX86Runtime then + Assert.AreEqual(-2147483648n, result) + else + // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual("-9223372036854775808", string result) + + let result = Operators.nativeint System.Double.MinValue + if Info.isX86Runtime then + Assert.AreEqual(-2147483648n, result) + else + // Cannot express this as a literal, see https://github.com/dotnet/fsharp/issues/9524 + Assert.AreEqual("-9223372036854775808", string result) + + // Max and min value as literals (this breaks compilation if the lexer fails). + // The following tests ensure that the proper value is parsed, which is similar to `nativeint Int64.MaxValue` etc. + if Info.isX86Runtime then + Assert.AreEqual("0", string -9223372036854775808n) // same as int32 -9223372036854775808L + Assert.AreEqual("-1", string 9223372036854775807n) // same as int32 9223372036854775807L + else + Assert.AreEqual("-9223372036854775808", string -9223372036854775808n) + Assert.AreEqual("9223372036854775807", string 9223372036854775807n) + + + [] + let sbyte() = + // int + let result = Operators.sbyte 10 + Assert.AreEqual(10y, result) + + // double + let result = Operators.sbyte 10.0 + Assert.AreEqual(10y, result) + + // negative + let result = Operators.sbyte -10 + Assert.AreEqual(-10y, result) + + // zero + let result = Operators.sbyte 0 + Assert.AreEqual(0y, result) + + // Overflow + let result = Operators.sbyte Int64.MaxValue + Assert.AreEqual(-1y, result) + + // Overflow + let result = Operators.sbyte Int64.MinValue + Assert.AreEqual(0y, result) + + // Overflow + let result = Operators.sbyte Single.MinValue + Assert.AreEqual(0y, result) + + // Overflow + let result = Operators.sbyte Single.MaxValue + Assert.AreEqual(0y, result) + + // Overflow + let result = Operators.sbyte Double.MinValue + Assert.AreEqual(0y, result) + + // Overflow + let result = Operators.sbyte Double.MaxValue + Assert.AreEqual(0y, result) + + // Overflow + let result = Operators.sbyte (Int64.MaxValue * 8L) + Assert.AreEqual(-8y, result) // bit-complement + + // Overflow + let result = 127y + 1y + Assert.AreEqual(-128y, result) + + // OverflowException, from decimal is always checked + CheckThrowsOverflowException(fun () -> Operators.sbyte Decimal.MinValue |> ignore) + + [] + let single() = + // int + let result = Operators.float32 10 + Assert.AreEqual(10f, result) + + // double + let result = Operators.float32 10.0 + Assert.AreEqual(10f, result) + + // string + let result = Operators.float32 "10" + Assert.AreEqual(10f, result) + + + [] + let uint16() = + // int + let result = Operators.uint16 100 + Assert.AreEqual(100us, result) + + // double + let result = Operators.uint16 (100.0:double) + Assert.AreEqual(100us, result) + + // decimal + let result = Operators.uint16 100M + Assert.AreEqual(100us, result) + + // Overflow + let result = Operators.uint16 Single.MaxValue + Assert.AreEqual(0us, result) + + // Overflow + let result = Operators.uint16 Single.MinValue + Assert.AreEqual(0us, result) + + // Overflow + let result = Operators.uint16 Double.MaxValue + Assert.AreEqual(0us, result) + + // Overflow + let result = Operators.uint16 Double.MinValue + Assert.AreEqual(0us, result) + + // OverflowException, from decimal is always checked + CheckThrowsOverflowException(fun () -> Operators.uint16 Decimal.MinValue |> ignore) + + [] + let uint32() = + // int + let result = Operators.uint32 100 + Assert.AreEqual(100u, result) + + // double + let result = Operators.uint32 (100.0:double) + Assert.AreEqual(100u, result) + + // decimal + let result = Operators.uint32 100M + Assert.AreEqual(100u, result) + + // Overflow + let result = Operators.uint32 Single.MaxValue + Assert.AreEqual(0u, result) + + // Overflow + let result = Operators.uint32 Single.MinValue + Assert.AreEqual(0u, result) + + // Overflow + let result = Operators.uint32 Double.MaxValue + Assert.AreEqual(0u, result) + + // Overflow + let result = Operators.uint32 Double.MinValue + Assert.AreEqual(0u, result) + + // Overflow + let result = Operators.uint32 Int64.MaxValue + Assert.AreEqual(UInt32.MaxValue, result) + + // Overflow + let result = Operators.uint32 Int64.MinValue + Assert.AreEqual(0u, result) + + // Overflow + let result = UInt32.MaxValue + 5u + Assert.AreEqual(4u, result) + + // both 'u' and 'ul' are valid numeric suffixes for UInt32 + let result = 42u + 42ul + Assert.AreEqual(84u, result) + Assert.AreEqual(84ul, result) + + // OverflowException, from decimal is always checked + CheckThrowsOverflowException(fun () -> Operators.uint32 Decimal.MinValue |> ignore) + + [] + let uint64() = + // int + let result = Operators.uint64 100 + Assert.AreEqual(100UL, result) + + // double + let result = Operators.uint64 100.0 + Assert.AreEqual(100UL, result) + + // decimal + let result = Operators.uint64 100M + Assert.AreEqual(100UL, result) + + // Overflow + let result = Operators.uint64 Single.MaxValue + Assert.AreEqual(0UL, result) + + // Overflow + let result = Operators.uint64 Single.MinValue + Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + + // Overflow + let result = Operators.uint64 Double.MaxValue + Assert.AreEqual(0UL, result) + + // Overflow + let result = Operators.uint64 Double.MinValue + Assert.AreEqual(9223372036854775808UL, result) // surprising, but true, 2^63 + 1 + + // Overflow + let result = Operators.uint64 Int64.MinValue + Assert.AreEqual(9223372036854775808UL, result) + + // Overflow + let result = Operators.uint64 SByte.MinValue + Assert.AreEqual(UInt64.MaxValue - 127UL, result) + + // Overflow + let result = UInt64.MaxValue + 5UL + Assert.AreEqual(4UL, result) + + // OverflowException, from decimal is always checked + CheckThrowsOverflowException(fun () -> Operators.uint64 Decimal.MinValue |> ignore) + + [] + let unativeint() = + // int + let result = Operators.unativeint 100 + let x: unativeint = 12un + Assert.AreEqual(100un, result) + + // double + let result = Operators.unativeint 100.0 + Assert.AreEqual(100un, result) + + // Overflow Single.MaxValue is equal on 32 bits and 64 bits runtimes + let result = Operators.unativeint Single.MaxValue + Assert.AreEqual(0un, result) + + // Overflow (depends on pointer size) + let result = Operators.unativeint Single.MinValue + if Info.isX86Runtime then + Assert.AreEqual(0un, result) + else + Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + + // Overflow Double.MaxValue is equal on 32 bits and 64 bits runtimes + let result = Operators.unativeint Double.MaxValue + Assert.AreEqual(0un, result) + + // Overflow (depends on pointer size) + let result = Operators.unativeint Double.MinValue + if Info.isX86Runtime then + Assert.AreEqual(0un, result) + else + Assert.AreEqual(9223372036854775808un, result) // surprising, but true, 2^63 + 1 + + // Overflow (depends on pointer size) + let result = Operators.unativeint Int64.MinValue + if Info.isX86Runtime then + Assert.AreEqual(0un, result) + else + Assert.AreEqual(9223372036854775808un, result) + + // Overflow (depends on pointer size) + let result = 0un - 1un + if Info.isX86Runtime then + Assert.AreEqual(4294967295un, result) + else + Assert.AreEqual(18446744073709551615un, result) + + open Operators.Checked + + [] + let Checkedbyte() = + // int type + let intByte = Operators.Checked.byte 100 + Assert.AreEqual(100uy, intByte) + + // char type + let charByte = Operators.Checked.byte '0' + Assert.AreEqual(48uy, charByte) + + // boundary value + let boundByte = Operators.Checked.byte 255.0 + Assert.AreEqual(255uy, boundByte) + + // overflow exception + CheckThrowsOverflowException(fun () -> Operators.Checked.byte 256 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.byte 256f |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.byte 256. |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> 255uy + 1uy |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> 0uy - 1uy |> ignore) + + [] + let Checkedchar() = + + // number + let numberChar = Operators.Checked.char 48 + Assert.AreEqual('0', numberChar) + + // letter + let letterChar = Operators.Checked.char 65 + Assert.AreEqual('A', letterChar) + + // boundary value + let boundchar = Operators.Checked.char 126 + Assert.AreEqual('~', boundchar) + + // overflow exception + CheckThrowsOverflowException(fun () -> Operators.Checked.char (int64 Char.MaxValue + 1L) |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.char Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.char Double.MaxValue |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> '\uFFFF' + '\u0001' |> ignore) + + + [] + let CheckedInt() = + + // char + let charInt = Operators.Checked.int '0' + Assert.AreEqual(48, charInt) + + // float + let floatInt = Operators.Checked.int 10.0 + Assert.AreEqual(10, floatInt) + + // boundary value + let boundInt = Operators.Checked.int 32767.0 + Assert.AreEqual(32767, boundInt) + + // overflow exception + CheckThrowsOverflowException(fun () -> Operators.Checked.int 2147483648.0 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int Double.MaxValue |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> Int32.MaxValue + 1 |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> Int32.MinValue - 1 |> ignore) + + [] + let CheckedInt16() = + + // char + let charInt16 = Operators.Checked.int16 '0' + Assert.AreEqual(48s, charInt16) + + // float + let floatInt16 = Operators.Checked.int16 10.0 + Assert.AreEqual(10s, floatInt16) + + // boundary value + let boundInt16 = Operators.Checked.int16 32767.0 + Assert.AreEqual(32767s, boundInt16) + + // overflow exception + CheckThrowsOverflowException(fun () -> Operators.Checked.int16 32768.0 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int16 Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int16 Double.MaxValue |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> Int16.MaxValue + 1s |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> Int16.MinValue - 1s |> ignore) + + [] + let CheckedInt32() = + + // char + let charInt32 = Operators.Checked.int32 '0' + Assert.AreEqual(48, charInt32) + + // float + let floatInt32 = Operators.Checked.int32 10.0 + Assert.AreEqual(10, floatInt32) + + // boundary value + let boundInt32 = Operators.Checked.int32 2147483647.0 + Assert.AreEqual(2147483647, boundInt32) + + // overflow exception + CheckThrowsOverflowException(fun () -> Operators.Checked.int32 2147483648.0 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int32 Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int32 Double.MaxValue |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> Int32.MaxValue + 1 |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> Int32.MinValue - 1 |> ignore) + + [] + let CheckedInt64() = + + // char + let charInt64 = Operators.Checked.int64 '0' + Assert.AreEqual(48L, charInt64) + + // float + let floatInt64 = Operators.Checked.int64 10.0 + Assert.AreEqual(10L, floatInt64) + + // boundary value + let boundInt64 = Operators.Checked.int64 9223372036854775807I + let _ = 9223372036854775807L + Assert.AreEqual(9223372036854775807L, boundInt64) + + // boundary value + let boundInt64 = Operators.Checked.int64 -9223372036854775808I + let _ = -9223372036854775808L + Assert.AreEqual(-9223372036854775808L, boundInt64) + + // overflow exception + CheckThrowsOverflowException(fun () -> Operators.Checked.int64 (float Int64.MaxValue + 1.0) |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int64 Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.int64 Double.MaxValue |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> Int64.MaxValue + 1L |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> Int64.MinValue - 1L |> ignore) + + [] + let CheckedNativeint() = + + // char + let charnativeint = Operators.Checked.nativeint '0' + Assert.AreEqual(48n, charnativeint) + + // float + let floatnativeint = Operators.Checked.nativeint 10.0 + Assert.AreEqual(10n, floatnativeint) + + // boundary value + let boundnativeint = Operators.Checked.nativeint 32767.0 + Assert.AreEqual(32767n, boundnativeint) + + // overflow exception (depends on pointer size) + CheckThrowsOverflowException(fun () -> + if Info.isX86Runtime then + Operators.Checked.nativeint 2147483648.0 |> ignore + else + Operators.Checked.nativeint 9223372036854775808.0 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.nativeint Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.nativeint Double.MaxValue |> ignore) + + + [] + let Checkedsbyte() = + + // char + let charsbyte = Operators.Checked.sbyte '0' + Assert.AreEqual(48y, charsbyte) + + // float + let floatsbyte = Operators.Checked.sbyte -10.0 + Assert.AreEqual(-10y, floatsbyte) + + // boundary value + let boundsbyte = Operators.Checked.sbyte -127.0 + Assert.AreEqual(-127y, boundsbyte) + + // overflow exception + CheckThrowsOverflowException(fun () -> Operators.Checked.sbyte -256 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.sbyte Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.sbyte Double.MaxValue |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> SByte.MaxValue + 1y |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> SByte.MinValue - 1y |> ignore) + + [] + let Checkeduint16() = + + // char + let charuint16 = Operators.Checked.uint16 '0' + Assert.AreEqual(48us, charuint16) + + // float + let floatuint16 = Operators.Checked.uint16 10.0 + Assert.AreEqual(10us, floatuint16) + + // boundary value + let bounduint16 = Operators.Checked.uint16 65535.0 + Assert.AreEqual(65535us, bounduint16) + + CheckThrowsOverflowException(fun () -> Operators.Checked.uint16 65536.0 |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint16 Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint16 Double.MaxValue |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> UInt16.MaxValue + 1us |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> UInt16.MinValue - 1us |> ignore) + + [] + let Checkeduint32() = + + // char + let charuint32 = Operators.Checked.uint32 '0' + Assert.AreEqual(48u, charuint32) + + // float + let floatuint32 = Operators.Checked.uint32 10.0 + Assert.AreEqual(10u, floatuint32) + + // boundary value + let bounduint32 = Operators.Checked.uint32 429496729.0 + Assert.AreEqual(429496729u, bounduint32) + + // overflow exception + CheckThrowsOverflowException(fun () -> Operators.Checked.uint32 (float UInt32.MaxValue + 1.0) |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint32 Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint32 Double.MaxValue |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> UInt32.MaxValue + 1u |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> UInt32.MinValue - 1u |> ignore) + + [] + let Checkeduint64() = + + // char + let charuint64 = Operators.Checked.uint64 '0' + Assert.AreEqual(48UL, charuint64) + + // float + let floatuint64 = Operators.Checked.uint64 10.0 + Assert.AreEqual(10UL, floatuint64) + + // boundary value + let bounduint64 = Operators.Checked.uint64 429496729.0 + Assert.AreEqual(429496729UL, bounduint64) + + // overflow exception + CheckThrowsOverflowException(fun () -> Operators.Checked.uint64 (float System.UInt64.MaxValue + 1.0) |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint64 Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.uint64 Double.MaxValue |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> UInt64.MaxValue + 1UL |> ignore) + + // overflow exception + CheckThrowsOverflowException(fun () -> UInt64.MinValue - 1UL |> ignore) + + [] + let Checkedunativeint() = + + // char + let charunativeint = Operators.Checked.unativeint '0' + Assert.AreEqual(48un, charunativeint) + + // float + let floatunativeint = Operators.Checked.unativeint 10.0 + Assert.AreEqual(10un, floatunativeint) + + // boundary value (dependent on pointer size) + if Info.isX86Runtime then + let boundunativeint = Operators.Checked.unativeint 4294967295.0 + Assert.AreEqual(4294967295un, boundunativeint) + else + let boundnativeint = Operators.Checked.unativeint 1.84467440737095505E+19 // 64 bit max value cannot be expressed exactly as double + Assert.AreEqual(18446744073709549568un, boundnativeint) + + // overflow exception (depends on pointer size) + CheckThrowsOverflowException(fun () -> + if Info.isX86Runtime then + Operators.Checked.unativeint (float UInt32.MaxValue + 1.0) |> ignore + else + Operators.Checked.unativeint (float UInt64.MaxValue + 1.0) |> ignore + ) + CheckThrowsOverflowException(fun () -> Operators.Checked.unativeint Single.MaxValue |> ignore) + CheckThrowsOverflowException(fun () -> Operators.Checked.unativeint Double.MaxValue |> ignore) + + type A = A + type B() = + static member op_Equality(_: B, _: B) = false + static member op_Inequality(_: B, _: B) = true + type [] C = + static member op_Equality(_: C, _: C) = true + static member op_Inequality(_: C, _: C) = true + static member op_Explicit(_: A) = C() // Explicit from another type + static member op_Explicit(_: C) = B() // Explicit to another type + static member op_Implicit(_: D) = C() // Duplicated implicit conversion + static member op_Explicit(_: C) = { D = 0 } // Duplicated explicit conversion + and D = { D : int } with + static member op_Implicit(_: A) = { D = 0 } // Implicit from another type + static member op_Implicit(_: D) = B() // Implicit to another type + static member op_Implicit(_: D) = C() // Duplicated implicit conversion + static member op_Explicit(_: C) = { D = 0 } // Duplicated explicit conversion + let [] Equality_ExplicitDynamicTests() = + Assert.False(LanguagePrimitives.EqualityDynamic(B())(B()) : bool) + Assert.True(LanguagePrimitives.InequalityDynamic(B())(B()) : bool) + Assert.True(LanguagePrimitives.EqualityDynamic(C())(C()) : bool) + Assert.True(LanguagePrimitives.InequalityDynamic(C())(C()) : bool) + Assert.NotNull(LanguagePrimitives.ExplicitDynamic(A) : C) + Assert.NotNull(LanguagePrimitives.ExplicitDynamic(A) : C) // Explicit from another type + Assert.NotNull(LanguagePrimitives.ExplicitDynamic(C()) : B) // Explicit to another type + Assert.NotNull(LanguagePrimitives.ExplicitDynamic({ D = 0 }) : C) // Duplicated implicit conversion + Assert.NotNull(LanguagePrimitives.ExplicitDynamic(C()) : D) // Duplicated explicit conversion + Assert.NotNull(LanguagePrimitives.ExplicitDynamic(A) : D) // Implicit from another type + Assert.NotNull(LanguagePrimitives.ExplicitDynamic({ D = 0 }) : B) // Implicit to another type + Assert.NotNull(LanguagePrimitives.ExplicitDynamic({ D = 0 }) : C) // Duplicated implicit conversion + Assert.NotNull(LanguagePrimitives.ExplicitDynamic(C()) : D) // Duplicated explicit conversion \ No newline at end of file diff --git a/tests/FSharp.Core.UnitTests/SurfaceArea.fs b/tests/FSharp.Core.UnitTests/SurfaceArea.fs index 31d2fa41d15..c214e76daf7 100644 --- a/tests/FSharp.Core.UnitTests/SurfaceArea.fs +++ b/tests/FSharp.Core.UnitTests/SurfaceArea.fs @@ -1486,6 +1486,7 @@ Microsoft.FSharp.Core.LanguagePrimitives: TResult AdditionDynamic[T1,T2,TResult] Microsoft.FSharp.Core.LanguagePrimitives: TResult BitwiseAndDynamic[T1,T2,TResult](T1, T2) Microsoft.FSharp.Core.LanguagePrimitives: TResult BitwiseOrDynamic[T1,T2,TResult](T1, T2) Microsoft.FSharp.Core.LanguagePrimitives: TResult CheckedAdditionDynamic[T1,T2,TResult](T1, T2) +Microsoft.FSharp.Core.LanguagePrimitives: TResult CheckedExplicitDynamic[T,TResult](T) Microsoft.FSharp.Core.LanguagePrimitives: TResult CheckedMultiplyDynamic[T1,T2,TResult](T1, T2) Microsoft.FSharp.Core.LanguagePrimitives: TResult CheckedSubtractionDynamic[T1,T2,TResult](T1, T2) Microsoft.FSharp.Core.LanguagePrimitives: TResult CheckedUnaryNegationDynamic[T,TResult](T) diff --git a/tests/fsharp/core/libtest/test.fsx b/tests/fsharp/core/libtest/test.fsx index bf58ea27d08..a2cdb2fd60f 100644 --- a/tests/fsharp/core/libtest/test.fsx +++ b/tests/fsharp/core/libtest/test.fsx @@ -3657,6 +3657,46 @@ module Optimiations = begin let _ = check "opt.oi20c77tb" (0x8000000000000000L >>> 63) (0xFFFFFFFFFFFFFFFFL) let _ = check "opt.oi20c77yb" (0x8000000000000000L >>> 64) (0x8000000000000000L) + let _ = check "opt.oi20c77qc" ('a' + '\025') ('z') + let _ = check "opt.oi20c77wc" ('z' - '\025') ('a') + let _ = check "opt.oi20c77ec" (nativeint -3m) (-3n) + let _ = check "opt.oi20c77rc" (nativeint 3m) (3n) + let _ = check "opt.oi20c77tc" (unativeint 3m) (3un) + let _ = check "opt.oi20c77yc" (char 65535m) ('\uFFFF') + let _ = check "opt.oi20c77uc" (decimal '\uFFFF') (65535m) + let _ = check "opt.oi20c77ic" (nativeint "3") (3n) + let _ = check "opt.oi20c77oc" (nativeint "-3") (-3n) + let _ = check "opt.oi20c77pc" (unativeint "3") (3un) + let _ = check "opt.oi20c77ac" (Checked.(+) 'a' '\025') ('z') + let _ = check "opt.oi20c77sc" (Checked.(-) 'z' '\025') ('a') + let _ = check "opt.oi20c77dc" (Checked.nativeint -3m) (-3n) + let _ = check "opt.oi20c77fc" (Checked.nativeint 3m) (3n) + let _ = check "opt.oi20c77gc" (Checked.unativeint 3m) (3un) + let _ = check "opt.oi20c77hc" (Checked.char 65535m) ('\uFFFF') + let _ = check "opt.oi20c77jc" (Checked.nativeint "3") (3n) + let _ = check "opt.oi20c77kc" (Checked.nativeint "-3") (-3n) + let _ = check "opt.oi20c77lc" (Checked.unativeint "3") (3un) + let _ = check "opt.oi20c77zc" (int8 3.9m) (3y) + let _ = check "opt.oi20c77xc" (uint8 3.9m) (3uy) + let _ = check "opt.oi20c77cc" (int16 3.9m) (3s) + let _ = check "opt.oi20c77vc" (uint16 3.9m) (3us) + let _ = check "opt.oi20c77bc" (int32 3.9m) (3l) + let _ = check "opt.oi20c77nc" (uint32 3.9m) (3ul) + let _ = check "opt.oi20c77mc" (int64 3.9m) (3L) + let _ = check "opt.oi20c77,c" (uint64 3.9m) (3uL) + let _ = check "opt.oi20c77.c" (nativeint 3.9m) (3n) + let _ = check "opt.oi20c77/c" (unativeint 3.9m) (3un) + let _ = check "opt.oi20c77zc'" (Checked.int8 3.9m) (3y) + let _ = check "opt.oi20c77xc'" (Checked.uint8 3.9m) (3uy) + let _ = check "opt.oi20c77cc'" (Checked.int16 3.9m) (3s) + let _ = check "opt.oi20c77vc'" (Checked.uint16 3.9m) (3us) + let _ = check "opt.oi20c77bc'" (Checked.int32 3.9m) (3l) + let _ = check "opt.oi20c77nc'" (Checked.uint32 3.9m) (3ul) + let _ = check "opt.oi20c77mc'" (Checked.int64 3.9m) (3L) + let _ = check "opt.oi20c77,c'" (Checked.uint64 3.9m) (3uL) + let _ = check "opt.oi20c77.c'" (Checked.nativeint 3.9m) (3n) + let _ = check "opt.oi20c77/c'" (Checked.unativeint 3.9m) (3un) + end diff --git a/tests/fsharp/core/quotes/test.fsx b/tests/fsharp/core/quotes/test.fsx index e394597f052..cc85cf23ad6 100644 --- a/tests/fsharp/core/quotes/test.fsx +++ b/tests/fsharp/core/quotes/test.fsx @@ -1543,7 +1543,7 @@ module MoreQuotationsTests = [Coerce (enumerator, Object)])), Dispose, []), Value ()))))""" - let t9() = <@@ try failwith "test" with Failure _ -> 0 @@> + let t9() = <@@ try failwith "test" with Failure _ -> 0 @@> checkStrings "vwewvwewe9" (sprintf "%A" (t9())) """TryWith (Call (None, FailWith, [Value ("test")]), matchValue, Let (activePatternResult1557, Call (None, FailurePattern, [matchValue]), @@ -3257,9 +3257,11 @@ module TestMatchBang = module WitnessTests = open FSharp.Data.UnitSystems.SI.UnitSymbols + open FSharp.Linq + open FSharp.Linq.NullableOperators test "check CallWithWitness" - (<@ 1 + 1 @> + (<@ 1 + 1 @> |> function | CallWithWitnesses(None, minfo1, minfo2, witnessArgs, args) -> minfo1.Name = "op_Addition" && @@ -3380,287 +3382,2045 @@ module WitnessTests = false | _ -> false) - test "check CallWithWitnesses all operators)" + test "check CallWithWitnesses all operators" (let tests = - [ <@@ sin 1.0 @@>, true - <@@ sin 1.0f @@>, true - <@@ sign 1.0f @@>, true - <@@ sqrt 1.0f @@>, true - <@@ 2.0f ** 2.0f @@>, true - <@@ atan2 3.0 4.0 @@>, true - <@@ 1.0f + 4.0f @@>, true - <@@ 1.0f - 4.0f @@>, true - <@@ 1.0f * 4.0f @@>, true - <@@ 1.0M * 4.0M @@>, true - <@@ 1.0f / 4.0f @@>, true - <@@ 1 % 4 @@>, true - <@@ -(4.0M) @@>, true - - <@@ 1y <<< 3 @@>, true - <@@ 1uy <<< 3 @@>, true - <@@ 1s <<< 3 @@>, true - <@@ 1us <<< 3 @@>, true - <@@ 1 <<< 3 @@>, true - <@@ 1u <<< 3 @@>, true - <@@ 1L <<< 3 @@>, true - <@@ 1UL <<< 3 @@>, true - <@@ LanguagePrimitives.GenericOne <<< 3 @@>, false - <@@ LanguagePrimitives.GenericOne <<< 3 @@>, false - - <@@ 1y >>> 3 @@>, true - <@@ 1uy >>> 3 @@>, true - <@@ 1s >>> 3 @@>, true - <@@ 1us >>> 3 @@>, true - <@@ 1 >>> 3 @@>, true - <@@ 1u >>> 3 @@>, true - <@@ 1L >>> 3 @@>, true - <@@ 1UL >>> 3 @@>, true - <@@ LanguagePrimitives.GenericOne >>> 3 @@>, false - <@@ LanguagePrimitives.GenericOne >>> 3 @@>, false + [|<@@ sin 1.0 @@>, box 0x3FEAED548F090CEELF // Around 0.841470984807897 + <@@ sin 1.0f @@>, box 0x3F576AA4lf // = 0.841471f + <@@ sign 1.0f @@>, box 1 + <@@ sqrt 1.0f @@>, box 1f + <@@ atan2 3.0 4.0 @@>, box 0x3FE4978FA3269EE1LF // Around 0.643501108793284 + <@@ atan2 3.0 4.0 @@>, box 0x3FE4978FA3269EE1LF // Around 0.643501108793284 - <@@ 1y &&& 3y @@>, true - <@@ 1uy &&& 3uy @@>, true - <@@ 1s &&& 3s @@>, true - <@@ 1us &&& 3us @@>, true - <@@ 1 &&& 3 @@>, true - <@@ 1u &&& 3u @@>, true - <@@ 1L &&& 3L @@>, true - <@@ 1UL &&& 3UL @@>, true - <@@ LanguagePrimitives.GenericOne &&& LanguagePrimitives.GenericOne @@>, false - <@@ LanguagePrimitives.GenericOne &&& LanguagePrimitives.GenericOne @@>, false - - <@@ 1y ||| 3y @@>, true - <@@ 1uy ||| 3uy @@>, true - <@@ 1s ||| 3s @@>, true - <@@ 1us ||| 3us @@>, true - <@@ 1 ||| 3 @@>, true - <@@ 1u ||| 3u @@>, true - <@@ 1L ||| 3L @@>, true - <@@ 1UL ||| 3UL @@>, true - <@@ LanguagePrimitives.GenericOne ||| LanguagePrimitives.GenericOne @@>, false - <@@ LanguagePrimitives.GenericOne ||| LanguagePrimitives.GenericOne @@>, false - - <@@ 1y ^^^ 3y @@>, true - <@@ 1uy ^^^ 3uy @@>, true - <@@ 1s ^^^ 3s @@>, true - <@@ 1us ^^^ 3us @@>, true - <@@ 1 ^^^ 3 @@>, true - <@@ 1u ^^^ 3u @@>, true - <@@ 1L ^^^ 3L @@>, true - <@@ 1UL ^^^ 3UL @@>, true - <@@ LanguagePrimitives.GenericOne ^^^ LanguagePrimitives.GenericOne @@>, false - <@@ LanguagePrimitives.GenericOne ^^^ LanguagePrimitives.GenericOne @@>, false - - <@@ ~~~3y @@>, true - <@@ ~~~3uy @@>, true - <@@ ~~~3s @@>, true - <@@ ~~~3us @@>, true - <@@ ~~~3 @@>, true - <@@ ~~~3u @@>, true - <@@ ~~~3L @@>, true - <@@ ~~~3UL @@>, true - <@@ ~~~LanguagePrimitives.GenericOne @@>, false - <@@ ~~~LanguagePrimitives.GenericOne @@>, false - - <@@ byte 3uy @@>, true - <@@ byte 3y @@>, true - <@@ byte 3s @@>, true - <@@ byte 3us @@>, true - <@@ byte 3 @@>, true - <@@ byte 3u @@>, true - <@@ byte 3L @@>, true - <@@ byte 3UL @@>, true - <@@ byte 3.0f @@>, true - <@@ byte 3.0 @@>, true - <@@ byte LanguagePrimitives.GenericOne @@>, false - <@@ byte LanguagePrimitives.GenericOne @@>, false - <@@ byte 3.0M @@>, true - <@@ byte "3" @@>, false - - <@@ sbyte 3uy @@>, true - <@@ sbyte 3y @@>, true - <@@ sbyte 3s @@>, true - <@@ sbyte 3us @@>, true - <@@ sbyte 3 @@>, true - <@@ sbyte 3u @@>, true - <@@ sbyte 3L @@>, true - <@@ sbyte 3UL @@>, true - <@@ sbyte 3.0f @@>, true - <@@ sbyte 3.0 @@>, true - <@@ sbyte LanguagePrimitives.GenericOne @@>, false - <@@ sbyte LanguagePrimitives.GenericOne @@>, false - <@@ sbyte 3.0M @@>, true - <@@ sbyte "3" @@>, false - - <@@ int16 3uy @@>, true - <@@ int16 3y @@>, true - <@@ int16 3s @@>, true - <@@ int16 3us @@>, true - <@@ int16 3 @@>, true - <@@ int16 3u @@>, true - <@@ int16 3L @@>, true - <@@ int16 3UL @@>, true - <@@ int16 3.0f @@>, true - <@@ int16 3.0 @@>, true - <@@ int16 LanguagePrimitives.GenericOne @@>, false - <@@ int16 LanguagePrimitives.GenericOne @@>, false - <@@ int16 3.0M @@>, true - <@@ int16 "3" @@>, false - - <@@ uint16 3uy @@>, true - <@@ uint16 3y @@>, true - <@@ uint16 3s @@>, true - <@@ uint16 3us @@>, true - <@@ uint16 3 @@>, true - <@@ uint16 3u @@>, true - <@@ uint16 3L @@>, true - <@@ uint16 3UL @@>, true - <@@ uint16 3.0f @@>, true - <@@ uint16 3.0 @@>, true - <@@ uint16 LanguagePrimitives.GenericOne @@>, false - <@@ uint16 LanguagePrimitives.GenericOne @@>, false - <@@ uint16 3.0M @@>, true - <@@ uint16 "3" @@>, false - - <@@ int32 3uy @@>, true - <@@ int32 3y @@>, true - <@@ int32 3s @@>, true - <@@ int32 3us @@>, true - <@@ int32 3 @@>, true - <@@ int32 3u @@>, true - <@@ int32 3L @@>, true - <@@ int32 3UL @@>, true - <@@ int32 3.0f @@>, true - <@@ int32 3.0 @@>, true - <@@ int32 LanguagePrimitives.GenericOne @@>, false - <@@ int32 LanguagePrimitives.GenericOne @@>, false - <@@ int32 3.0M @@>, true - <@@ int32 "3" @@>, false - - <@@ uint32 3uy @@>, true - <@@ uint32 3y @@>, true - <@@ uint32 3s @@>, true - <@@ uint32 3us @@>, true - <@@ uint32 3 @@>, true - <@@ uint32 3u @@>, true - <@@ uint32 3L @@>, true - <@@ uint32 3UL @@>, true - <@@ uint32 3.0f @@>, true - <@@ uint32 3.0 @@>, true - <@@ uint32 LanguagePrimitives.GenericOne @@>, false - <@@ uint32 LanguagePrimitives.GenericOne @@>, false - <@@ uint32 3.0M @@>, true - <@@ uint32 "3" @@>, false - - <@@ int64 3uy @@>, true - <@@ int64 3y @@>, true - <@@ int64 3s @@>, true - <@@ int64 3us @@>, true - <@@ int64 3 @@>, true - <@@ int64 3u @@>, true - <@@ int64 3L @@>, true - <@@ int64 3UL @@>, true - <@@ int64 3.0f @@>, true - <@@ int64 3.0 @@>, true - <@@ int64 LanguagePrimitives.GenericOne @@>, false - <@@ int64 LanguagePrimitives.GenericOne @@>, false - <@@ int64 3.0M @@>, true - <@@ int64 "3" @@>, false + <@@ 1y + 4y @@>, box 5y + <@@ 1uy + 4uy @@>, box 5uy + <@@ 1s + 4s @@>, box 5s + <@@ 1us + 4us @@>, box 5us + <@@ 1 + 4 @@>, box 5 + <@@ 1u + 4u @@>, box 5u + <@@ 1L + 4L @@>, box 5L + <@@ 1uL + 4uL @@>, box 5uL + <@@ 1.0f + 4.0f @@>, box 5f + <@@ 1.0 + 4.0 @@>, box 5. + <@@ 1m + 4m @@>, box 5m + <@@ 1m + 4m @@>, box 5m + <@@ 1I + 4I @@>, box 5I + <@@ '1' + '\004' @@>, box '5' + <@@ "abc" + "def" @@>, box "abcdef" + <@@ LanguagePrimitives.GenericOne + LanguagePrimitives.GenericOne @@>, box 2n + <@@ LanguagePrimitives.GenericOne + LanguagePrimitives.GenericOne @@>, box 2un + <@@ Checked.(+) 1y 4y @@>, box 5y + <@@ Checked.(+) 1uy 4uy @@>, box 5uy + <@@ Checked.(+) 1s 4s @@>, box 5s + <@@ Checked.(+) 1us 4us @@>, box 5us + <@@ Checked.(+) 1 4 @@>, box 5 + <@@ Checked.(+) 1u 4u @@>, box 5u + <@@ Checked.(+) 1L 4L @@>, box 5L + <@@ Checked.(+) 1uL 4uL @@>, box 5uL + <@@ Checked.(+) 1.0f 4.0f @@>, box 5f + <@@ Checked.(+) 1.0 4.0 @@>, box 5. + <@@ Checked.(+) 1m 4m @@>, box 5m + <@@ Checked.(+) 1m 4m @@>, box 5m + <@@ Checked.(+) 1I 4I @@>, box 5I + <@@ Checked.(+) '1' '\004' @@>, box '5' + <@@ Checked.(+) "abc" "def" @@>, box "abcdef" + <@@ Checked.(+) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box 2n + <@@ Checked.(+) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box 2un + + <@@ 4y - 1y @@>, box 3y + <@@ 4uy - 1uy @@>, box 3uy + <@@ 4s - 1s @@>, box 3s + <@@ 4us - 1us @@>, box 3us + <@@ 4 - 1 @@>, box 3 + <@@ 4u - 1u @@>, box 3u + <@@ 4L - 1L @@>, box 3L + <@@ 4uL - 1uL @@>, box 3uL + <@@ 4.0f - 1.0f @@>, box 3f + <@@ 4.0 - 1.0 @@>, box 3. + <@@ 4m - 1m @@>, box 3m + <@@ 4m - 1m @@>, box 3m + <@@ 4I - 1I @@>, box 3I + <@@ '4' - '\001' @@>, box '3' + <@@ LanguagePrimitives.GenericOne - LanguagePrimitives.GenericOne @@>, box 0n + <@@ LanguagePrimitives.GenericOne - LanguagePrimitives.GenericOne @@>, box 0un + <@@ Checked.(-) 4y 1y @@>, box 3y + <@@ Checked.(-) 4uy 1uy @@>, box 3uy + <@@ Checked.(-) 4s 1s @@>, box 3s + <@@ Checked.(-) 4us 1us @@>, box 3us + <@@ Checked.(-) 4 1 @@>, box 3 + <@@ Checked.(-) 4u 1u @@>, box 3u + <@@ Checked.(-) 4L 1L @@>, box 3L + <@@ Checked.(-) 4uL 1uL @@>, box 3uL + <@@ Checked.(-) 4.0f 1.0f @@>, box 3f + <@@ Checked.(-) 4.0 1.0 @@>, box 3. + <@@ Checked.(-) 4m 1m @@>, box 3m + <@@ Checked.(-) 4m 1m @@>, box 3m + <@@ Checked.(-) 4I 1I @@>, box 3I + <@@ Checked.(-) '4' '\001' @@>, box '3' + <@@ Checked.(-) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box 0n + <@@ Checked.(-) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box 0un + + <@@ 2y * 4y @@>, box 8y + <@@ 2uy * 4uy @@>, box 8uy + <@@ 2s * 4s @@>, box 8s + <@@ 2us * 4us @@>, box 8us + <@@ 2 * 4 @@>, box 8 + <@@ 2u * 4u @@>, box 8u + <@@ 2L * 4L @@>, box 8L + <@@ 2uL * 4uL @@>, box 8uL + <@@ 2.0f * 4.0f @@>, box 8f + <@@ 2.0 * 4.0 @@>, box 8. + <@@ 2m * 4m @@>, box 8m + <@@ 2m * 4m @@>, box 8m + <@@ 2I * 4I @@>, box 8I + <@@ LanguagePrimitives.GenericOne * LanguagePrimitives.GenericOne @@>, box 1n + <@@ LanguagePrimitives.GenericOne * LanguagePrimitives.GenericOne @@>, box 1un + <@@ Checked.(*) 2y 4y @@>, box 8y + <@@ Checked.(*) 2uy 4uy @@>, box 8uy + <@@ Checked.(*) 2s 4s @@>, box 8s + <@@ Checked.(*) 2us 4us @@>, box 8us + <@@ Checked.(*) 2 4 @@>, box 8 + <@@ Checked.(*) 2u 4u @@>, box 8u + <@@ Checked.(*) 2L 4L @@>, box 8L + <@@ Checked.(*) 2uL 4uL @@>, box 8uL + <@@ Checked.(*) 2.0f 4.0f @@>, box 8f + <@@ Checked.(*) 2.0 4.0 @@>, box 8. + <@@ Checked.(*) 2m 4m @@>, box 8m + <@@ Checked.(*) 2m 4m @@>, box 8m + <@@ Checked.(*) 2I 4I @@>, box 8I + <@@ Checked.(*) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box 1n + <@@ Checked.(*) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box 1un + + <@@ 6y / 3y @@>, box 2y + <@@ 6uy / 3uy @@>, box 2uy + <@@ 6s / 3s @@>, box 2s + <@@ 6us / 3us @@>, box 2us + <@@ 6 / 3 @@>, box 2 + <@@ 6u / 3u @@>, box 2u + <@@ 6L / 3L @@>, box 2L + <@@ 6uL / 3uL @@>, box 2uL + <@@ 6.0f / 3.0f @@>, box 2f + <@@ 6.0 / 3.0 @@>, box 2. + <@@ 6m / 3m @@>, box 2m + <@@ 6m / 3m @@>, box 2m + <@@ 6I / 3I @@>, box 2I + <@@ LanguagePrimitives.GenericOne / LanguagePrimitives.GenericOne @@>, box 1n + <@@ LanguagePrimitives.GenericOne / LanguagePrimitives.GenericOne @@>, box 1un + + <@@ 9y % 4y @@>, box 1y + <@@ 9uy % 4uy @@>, box 1uy + <@@ 9s % 4s @@>, box 1s + <@@ 9us % 4us @@>, box 1us + <@@ 9 % 4 @@>, box 1 + <@@ 9u % 4u @@>, box 1u + <@@ 9L % 4L @@>, box 1L + <@@ 9uL % 4uL @@>, box 1uL + <@@ 9.0f % 4.0f @@>, box 1f + <@@ 9.0 % 4.0 @@>, box 1. + <@@ 9m % 4m @@>, box 1m + <@@ 9m % 4m @@>, box 1m + <@@ 9I % 4I @@>, box 1I + <@@ LanguagePrimitives.GenericOne % LanguagePrimitives.GenericOne @@>, box 0n + <@@ LanguagePrimitives.GenericOne % LanguagePrimitives.GenericOne @@>, box 0un + + <@@ +(1y) @@>, box 1y + <@@ +(1uy) @@>, box 1uy + <@@ +(1s) @@>, box 1s + <@@ +(1us) @@>, box 1us + <@@ +(1) @@>, box 1 + <@@ +(1u) @@>, box 1u + <@@ +(1L) @@>, box 1L + <@@ +(1uL) @@>, box 1uL + <@@ +(1f) @@>, box 1f + <@@ +(1.) @@>, box 1. + <@@ +(1m) @@>, box 1m + <@@ +(1m) @@>, box 1m + <@@ +(1I) @@>, box 1I + <@@ +(LanguagePrimitives.GenericOne) @@>, box 1n + <@@ +(LanguagePrimitives.GenericOne) @@>, box 1un + + <@@ -(1y) @@>, box -1y + <@@ -(1s) @@>, box -1s + <@@ -(1) @@>, box -1 + <@@ -(1L) @@>, box -1L + <@@ -(1f) @@>, box -1f + <@@ -(1.) @@>, box -1. + <@@ -(1m) @@>, box -1m + <@@ -(1m) @@>, box -1m + <@@ -(1I) @@>, box -1I + <@@ -(LanguagePrimitives.GenericOne) @@>, box -1n + <@@ Checked.(~-) (1y) @@>, box -1y + <@@ Checked.(~-) (1s) @@>, box -1s + <@@ Checked.(~-) (1) @@>, box -1 + <@@ Checked.(~-) (1L) @@>, box -1L + <@@ Checked.(~-) (1f) @@>, box -1f + <@@ Checked.(~-) (1.) @@>, box -1. + <@@ Checked.(~-) (1m) @@>, box -1m + <@@ Checked.(~-) (1m) @@>, box -1m + <@@ Checked.(~-) (1I) @@>, box -1I + <@@ Checked.(~-) (LanguagePrimitives.GenericOne) @@>, box -1n + + <@@ 4f ** 3f @@>, box 64f + <@@ 4. ** 3. @@>, box 64. + <@@ 4I ** 3 @@>, box 64I + + <@@ 1y <<< 3 @@>, box 8y + <@@ 1uy <<< 3 @@>, box 8uy + <@@ 1s <<< 3 @@>, box 8s + <@@ 1us <<< 3 @@>, box 8us + <@@ 1 <<< 3 @@>, box 8 + <@@ 1u <<< 3 @@>, box 8u + <@@ 1L <<< 3 @@>, box 8L + <@@ 1UL <<< 3 @@>, box 8UL + <@@ 1I <<< 3 @@>, box 8I + <@@ LanguagePrimitives.GenericOne <<< 3 @@>, box 8n + <@@ LanguagePrimitives.GenericOne <<< 3 @@>, box 8un + + <@@ 1y >>> 3 @@>, box 0y + <@@ 1uy >>> 3 @@>, box 0uy + <@@ 1s >>> 3 @@>, box 0s + <@@ 1us >>> 3 @@>, box 0us + <@@ 1 >>> 3 @@>, box 0 + <@@ 1u >>> 3 @@>, box 0u + <@@ 1L >>> 3 @@>, box 0L + <@@ 1UL >>> 3 @@>, box 0UL + <@@ 1I >>> 3 @@>, box 0I + <@@ LanguagePrimitives.GenericOne >>> 3 @@>, box 0n + <@@ LanguagePrimitives.GenericOne >>> 3 @@>, box 0un - <@@ uint64 3uy @@>, true - <@@ uint64 3y @@>, true - <@@ uint64 3s @@>, true - <@@ uint64 3us @@>, true - <@@ uint64 3 @@>, true - <@@ uint64 3u @@>, true - <@@ uint64 3L @@>, true - <@@ uint64 3UL @@>, true - <@@ uint64 3.0f @@>, true - <@@ uint64 3.0 @@>, true - <@@ uint64 LanguagePrimitives.GenericOne @@>, false - <@@ uint64 LanguagePrimitives.GenericOne @@>, false - <@@ uint64 3.0M @@>, true - <@@ uint64 "3" @@>, false - - <@@ nativeint 3uy @@>, true - <@@ nativeint 3y @@>, true - <@@ nativeint 3s @@>, true - <@@ nativeint 3us @@>, true - <@@ nativeint 3 @@>, true - <@@ nativeint 3u @@>, true - <@@ nativeint 3L @@>, true - <@@ nativeint 3UL @@>, true - <@@ nativeint 3.0f @@>, true - <@@ nativeint 3.0 @@>, true - <@@ nativeint LanguagePrimitives.GenericOne @@>, false - <@@ nativeint LanguagePrimitives.GenericOne @@>, false - //<@@ nativeint 3.0M @@>, false - //<@@ nativeint "3" @@>, false - - <@@ unativeint 3uy @@>, true - <@@ unativeint 3y @@>, true - <@@ unativeint 3s @@>, true - <@@ unativeint 3us @@>, true - <@@ unativeint 3 @@>, true - <@@ unativeint 3u @@>, true - <@@ unativeint 3L @@>, true - <@@ unativeint 3UL @@>, true - <@@ unativeint 3.0f @@>, true - <@@ unativeint 3.0 @@>, true - <@@ unativeint LanguagePrimitives.GenericOne @@>, false - <@@ unativeint LanguagePrimitives.GenericOne @@>, false - //<@@ unativeint 3.0M @@>, true - //<@@ unativeint "3" @@>, true - - <@@ LanguagePrimitives.GenericZero @@>, true - <@@ LanguagePrimitives.GenericZero @@>, true - <@@ LanguagePrimitives.GenericZero @@>, true - <@@ LanguagePrimitives.GenericZero @@>, true - <@@ LanguagePrimitives.GenericZero @@>, true - <@@ LanguagePrimitives.GenericZero @@>, true - <@@ LanguagePrimitives.GenericOne @@>, true - <@@ LanguagePrimitives.GenericOne @@>, true - <@@ LanguagePrimitives.GenericOne @@>, true - <@@ LanguagePrimitives.GenericOne @@>, true - <@@ LanguagePrimitives.GenericOne @@>, true - <@@ LanguagePrimitives.GenericOne @@>, true - <@@ List.sum [ 1; 2 ] @@>, true - <@@ List.sum [ 1.0f; 2.0f ] @@>, true - <@@ List.sum [ 1.0; 2.0 ] @@>, true - <@@ List.sum [ 1.0M; 2.0M ] @@>, true - <@@ List.average [ 1.0; 2.0 ] @@>, true - <@@ List.average [ 1.0f; 2.0f ] @@>, true - <@@ List.average [ 1.0M; 2.0M ] @@>, true - ] - - tests |> List.forall (fun (test, canEval) -> - if canEval then - printfn "--> checking we can evaluate %A" test - FSharp.Linq.RuntimeHelpers.LeafExpressionConverter.EvaluateQuotation test |> ignore - printfn "<-- evaluated!" - else - printfn "skipping evaluation of %A because LinqExpressionConverter can't handle it" test - printfn "checking %A" test + <@@ 1y &&& 3y @@>, box 1y + <@@ 1uy &&& 3uy @@>, box 1uy + <@@ 1s &&& 3s @@>, box 1s + <@@ 1us &&& 3us @@>, box 1us + <@@ 1 &&& 3 @@>, box 1 + <@@ 1u &&& 3u @@>, box 1u + <@@ 1L &&& 3L @@>, box 1L + <@@ 1UL &&& 3UL @@>, box 1UL + <@@ 1I &&& 3I @@>, box 1I + <@@ LanguagePrimitives.GenericOne &&& LanguagePrimitives.GenericOne @@>, box 1n + <@@ LanguagePrimitives.GenericOne &&& LanguagePrimitives.GenericOne @@>, box 1un + + <@@ 1y ||| 3y @@>, box 3y + <@@ 1uy ||| 3uy @@>, box 3uy + <@@ 1s ||| 3s @@>, box 3s + <@@ 1us ||| 3us @@>, box 3us + <@@ 1 ||| 3 @@>, box 3 + <@@ 1u ||| 3u @@>, box 3u + <@@ 1L ||| 3L @@>, box 3L + <@@ 1UL ||| 3UL @@>, box 3UL + <@@ 1I ||| 3I @@>, box 3I + <@@ LanguagePrimitives.GenericOne ||| LanguagePrimitives.GenericOne @@>, box 1n + <@@ LanguagePrimitives.GenericOne ||| LanguagePrimitives.GenericOne @@>, box 1un + + <@@ 1y ^^^ 3y @@>, box 2y + <@@ 1uy ^^^ 3uy @@>, box 2uy + <@@ 1s ^^^ 3s @@>, box 2s + <@@ 1us ^^^ 3us @@>, box 2us + <@@ 1 ^^^ 3 @@>, box 2 + <@@ 1u ^^^ 3u @@>, box 2u + <@@ 1L ^^^ 3L @@>, box 2L + <@@ 1UL ^^^ 3UL @@>, box 2UL + <@@ 1I ^^^ 3I @@>, box 2I + <@@ LanguagePrimitives.GenericOne ^^^ LanguagePrimitives.GenericOne @@>, box 0n + <@@ LanguagePrimitives.GenericOne ^^^ LanguagePrimitives.GenericOne @@>, box 0un + + <@@ ~~~3y @@>, box -4y + <@@ ~~~3uy @@>, box 252uy + <@@ ~~~3s @@>, box -4s + <@@ ~~~3us @@>, box 65532us + <@@ ~~~3 @@>, box -4 + <@@ ~~~3u @@>, box 4294967292u + <@@ ~~~3L @@>, box -4L + <@@ ~~~3UL @@>, box 18446744073709551612UL + <@@ ~~~LanguagePrimitives.GenericOne @@>, box ~~~1n + <@@ ~~~LanguagePrimitives.GenericOne @@>, box ~~~1un + + <@@ byte 3uy @@>, box 3uy + <@@ byte 3y @@>, box 3uy + <@@ byte 3s @@>, box 3uy + <@@ byte 3us @@>, box 3uy + <@@ byte 3 @@>, box 3uy + <@@ byte 3u @@>, box 3uy + <@@ byte 3L @@>, box 3uy + <@@ byte 3UL @@>, box 3uy + <@@ byte '\003' @@>, box 3uy + <@@ byte 3.0f @@>, box 3uy + <@@ byte 3.0 @@>, box 3uy + <@@ byte 3.0 @@>, box 3uy + <@@ byte 3I @@>, box 3uy + <@@ byte LanguagePrimitives.GenericOne @@>, box 1uy + <@@ byte LanguagePrimitives.GenericOne @@>, box 1uy + <@@ byte 3.0M @@>, box 3uy + <@@ byte "3" @@>, box 3uy + <@@ uint8 3uy @@>, box 3uy + <@@ uint8 3y @@>, box 3uy + <@@ uint8 3s @@>, box 3uy + <@@ uint8 3us @@>, box 3uy + <@@ uint8 3 @@>, box 3uy + <@@ uint8 3u @@>, box 3uy + <@@ uint8 3L @@>, box 3uy + <@@ uint8 3UL @@>, box 3uy + <@@ uint8 '\003' @@>, box 3uy + <@@ uint8 3.0f @@>, box 3uy + <@@ uint8 3.0 @@>, box 3uy + <@@ uint8 3.0 @@>, box 3uy + <@@ uint8 3I @@>, box 3uy + <@@ uint8 LanguagePrimitives.GenericOne @@>, box 1uy + <@@ uint8 LanguagePrimitives.GenericOne @@>, box 1uy + <@@ uint8 3.0M @@>, box 3uy + <@@ uint8 "3" @@>, box 3uy + <@@ Checked.byte 3uy @@>, box 3uy + <@@ Checked.byte 3y @@>, box 3uy + <@@ Checked.byte 3s @@>, box 3uy + <@@ Checked.byte 3us @@>, box 3uy + <@@ Checked.byte 3 @@>, box 3uy + <@@ Checked.byte 3u @@>, box 3uy + <@@ Checked.byte 3L @@>, box 3uy + <@@ Checked.byte 3UL @@>, box 3uy + <@@ Checked.byte '\003' @@>, box 3uy + <@@ Checked.byte 3.0f @@>, box 3uy + <@@ Checked.byte 3.0 @@>, box 3uy + <@@ Checked.byte 3.0 @@>, box 3uy + <@@ Checked.byte 3I @@>, box 3uy + <@@ Checked.byte LanguagePrimitives.GenericOne @@>, box 1uy + <@@ Checked.byte LanguagePrimitives.GenericOne @@>, box 1uy + <@@ Checked.byte 3.0M @@>, box 3uy + <@@ Checked.byte "3" @@>, box 3uy + <@@ Checked.uint8 3uy @@>, box 3uy + <@@ Checked.uint8 3y @@>, box 3uy + <@@ Checked.uint8 3s @@>, box 3uy + <@@ Checked.uint8 3us @@>, box 3uy + <@@ Checked.uint8 3 @@>, box 3uy + <@@ Checked.uint8 3u @@>, box 3uy + <@@ Checked.uint8 3L @@>, box 3uy + <@@ Checked.uint8 3UL @@>, box 3uy + <@@ Checked.uint8 '\003' @@>, box 3uy + <@@ Checked.uint8 3.0f @@>, box 3uy + <@@ Checked.uint8 3.0 @@>, box 3uy + <@@ Checked.uint8 3.0 @@>, box 3uy + <@@ Checked.uint8 3I @@>, box 3uy + <@@ Checked.uint8 LanguagePrimitives.GenericOne @@>, box 1uy + <@@ Checked.uint8 LanguagePrimitives.GenericOne @@>, box 1uy + <@@ Checked.uint8 3.0M @@>, box 3uy + <@@ Checked.uint8 "3" @@>, box 3uy + + <@@ sbyte 3uy @@>, box 3y + <@@ sbyte 3y @@>, box 3y + <@@ sbyte 3s @@>, box 3y + <@@ sbyte 3us @@>, box 3y + <@@ sbyte 3 @@>, box 3y + <@@ sbyte 3u @@>, box 3y + <@@ sbyte 3L @@>, box 3y + <@@ sbyte 3UL @@>, box 3y + <@@ sbyte '\003' @@>, box 3y + <@@ sbyte 3.0f @@>, box 3y + <@@ sbyte 3.0 @@>, box 3y + <@@ sbyte 3.0 @@>, box 3y + <@@ sbyte 3I @@>, box 3y + <@@ sbyte LanguagePrimitives.GenericOne @@>, box 1y + <@@ sbyte LanguagePrimitives.GenericOne @@>, box 1y + <@@ sbyte 3.0M @@>, box 3y + <@@ sbyte "3" @@>, box 3y + <@@ int8 3uy @@>, box 3y + <@@ int8 3y @@>, box 3y + <@@ int8 3s @@>, box 3y + <@@ int8 3us @@>, box 3y + <@@ int8 3 @@>, box 3y + <@@ int8 3u @@>, box 3y + <@@ int8 3L @@>, box 3y + <@@ int8 3UL @@>, box 3y + <@@ int8 '\003' @@>, box 3y + <@@ int8 3.0f @@>, box 3y + <@@ int8 3.0 @@>, box 3y + <@@ int8 3.0 @@>, box 3y + <@@ int8 3I @@>, box 3y + <@@ int8 LanguagePrimitives.GenericOne @@>, box 1y + <@@ int8 LanguagePrimitives.GenericOne @@>, box 1y + <@@ int8 3.0M @@>, box 3y + <@@ int8 "3" @@>, box 3y + <@@ Checked.sbyte 3uy @@>, box 3y + <@@ Checked.sbyte 3y @@>, box 3y + <@@ Checked.sbyte 3s @@>, box 3y + <@@ Checked.sbyte 3us @@>, box 3y + <@@ Checked.sbyte 3 @@>, box 3y + <@@ Checked.sbyte 3u @@>, box 3y + <@@ Checked.sbyte 3L @@>, box 3y + <@@ Checked.sbyte 3UL @@>, box 3y + <@@ Checked.sbyte '\003' @@>, box 3y + <@@ Checked.sbyte 3.0f @@>, box 3y + <@@ Checked.sbyte 3.0 @@>, box 3y + <@@ Checked.sbyte 3.0 @@>, box 3y + <@@ Checked.sbyte 3I @@>, box 3y + <@@ Checked.sbyte LanguagePrimitives.GenericOne @@>, box 1y + <@@ Checked.sbyte LanguagePrimitives.GenericOne @@>, box 1y + <@@ Checked.sbyte 3.0M @@>, box 3y + <@@ Checked.sbyte "3" @@>, box 3y + <@@ Checked.int8 3uy @@>, box 3y + <@@ Checked.int8 3y @@>, box 3y + <@@ Checked.int8 3s @@>, box 3y + <@@ Checked.int8 3us @@>, box 3y + <@@ Checked.int8 3 @@>, box 3y + <@@ Checked.int8 3u @@>, box 3y + <@@ Checked.int8 3L @@>, box 3y + <@@ Checked.int8 3UL @@>, box 3y + <@@ Checked.int8 '\003' @@>, box 3y + <@@ Checked.int8 3.0f @@>, box 3y + <@@ Checked.int8 3.0 @@>, box 3y + <@@ Checked.int8 3.0 @@>, box 3y + <@@ Checked.int8 3I @@>, box 3y + <@@ Checked.int8 LanguagePrimitives.GenericOne @@>, box 1y + <@@ Checked.int8 LanguagePrimitives.GenericOne @@>, box 1y + <@@ Checked.int8 3.0M @@>, box 3y + <@@ Checked.int8 "3" @@>, box 3y + + <@@ int16 3uy @@>, box 3s + <@@ int16 3y @@>, box 3s + <@@ int16 3s @@>, box 3s + <@@ int16 3us @@>, box 3s + <@@ int16 3 @@>, box 3s + <@@ int16 3u @@>, box 3s + <@@ int16 3L @@>, box 3s + <@@ int16 3UL @@>, box 3s + <@@ int16 '\003' @@>, box 3s + <@@ int16 3.0f @@>, box 3s + <@@ int16 3.0 @@>, box 3s + <@@ int16 3.0 @@>, box 3s + <@@ int16 3I @@>, box 3s + <@@ int16 LanguagePrimitives.GenericOne @@>, box 1s + <@@ int16 LanguagePrimitives.GenericOne @@>, box 1s + <@@ int16 3.0M @@>, box 3s + <@@ int16 "3" @@>, box 3s + <@@ Checked.int16 3uy @@>, box 3s + <@@ Checked.int16 3y @@>, box 3s + <@@ Checked.int16 3s @@>, box 3s + <@@ Checked.int16 3us @@>, box 3s + <@@ Checked.int16 3 @@>, box 3s + <@@ Checked.int16 3u @@>, box 3s + <@@ Checked.int16 3L @@>, box 3s + <@@ Checked.int16 3UL @@>, box 3s + <@@ Checked.int16 '\003' @@>, box 3s + <@@ Checked.int16 3.0f @@>, box 3s + <@@ Checked.int16 3.0 @@>, box 3s + <@@ Checked.int16 3.0 @@>, box 3s + <@@ Checked.int16 3I @@>, box 3s + <@@ Checked.int16 LanguagePrimitives.GenericOne @@>, box 1s + <@@ Checked.int16 LanguagePrimitives.GenericOne @@>, box 1s + <@@ Checked.int16 3.0M @@>, box 3s + <@@ Checked.int16 "3" @@>, box 3s + + <@@ uint16 3uy @@>, box 3us + <@@ uint16 3y @@>, box 3us + <@@ uint16 3s @@>, box 3us + <@@ uint16 3us @@>, box 3us + <@@ uint16 3 @@>, box 3us + <@@ uint16 3u @@>, box 3us + <@@ uint16 3L @@>, box 3us + <@@ uint16 3UL @@>, box 3us + <@@ uint16 '\003' @@>, box 3us + <@@ uint16 3.0f @@>, box 3us + <@@ uint16 3.0 @@>, box 3us + <@@ uint16 3.0 @@>, box 3us + <@@ uint16 3I @@>, box 3us + <@@ uint16 LanguagePrimitives.GenericOne @@>, box 1us + <@@ uint16 LanguagePrimitives.GenericOne @@>, box 1us + <@@ uint16 3.0M @@>, box 3us + <@@ uint16 "3" @@>, box 3us + <@@ Checked.uint16 3uy @@>, box 3us + <@@ Checked.uint16 3y @@>, box 3us + <@@ Checked.uint16 3s @@>, box 3us + <@@ Checked.uint16 3us @@>, box 3us + <@@ Checked.uint16 3 @@>, box 3us + <@@ Checked.uint16 3u @@>, box 3us + <@@ Checked.uint16 3L @@>, box 3us + <@@ Checked.uint16 3UL @@>, box 3us + <@@ Checked.uint16 '\003' @@>, box 3us + <@@ Checked.uint16 3.0f @@>, box 3us + <@@ Checked.uint16 3.0 @@>, box 3us + <@@ Checked.uint16 3.0 @@>, box 3us + <@@ Checked.uint16 3I @@>, box 3us + <@@ Checked.uint16 LanguagePrimitives.GenericOne @@>, box 1us + <@@ Checked.uint16 LanguagePrimitives.GenericOne @@>, box 1us + <@@ Checked.uint16 3.0M @@>, box 3us + <@@ Checked.uint16 "3" @@>, box 3us + + <@@ int 3uy @@>, box 3 + <@@ int 3y @@>, box 3 + <@@ int 3s @@>, box 3 + <@@ int 3us @@>, box 3 + <@@ int 3 @@>, box 3 + <@@ int 3u @@>, box 3 + <@@ int 3L @@>, box 3 + <@@ int 3UL @@>, box 3 + <@@ int '\003' @@>, box 3 + <@@ int 3.0f @@>, box 3 + <@@ int 3.0 @@>, box 3 + <@@ int 3.0 @@>, box 3 + <@@ int 3I @@>, box 3 + <@@ int LanguagePrimitives.GenericOne @@>, box 1 + <@@ int LanguagePrimitives.GenericOne @@>, box 1 + <@@ int 3.0M @@>, box 3 + <@@ int "3" @@>, box 3 + <@@ int32 3uy @@>, box 3 + <@@ int32 3y @@>, box 3 + <@@ int32 3s @@>, box 3 + <@@ int32 3us @@>, box 3 + <@@ int32 3 @@>, box 3 + <@@ int32 3u @@>, box 3 + <@@ int32 3L @@>, box 3 + <@@ int32 3UL @@>, box 3 + <@@ int32 '\003' @@>, box 3 + <@@ int32 3.0f @@>, box 3 + <@@ int32 3.0 @@>, box 3 + <@@ int32 3.0 @@>, box 3 + <@@ int32 3I @@>, box 3 + <@@ int32 LanguagePrimitives.GenericOne @@>, box 1 + <@@ int32 LanguagePrimitives.GenericOne @@>, box 1 + <@@ int32 3.0M @@>, box 3 + <@@ int32 "3" @@>, box 3 + <@@ Checked.int 3uy @@>, box 3 + <@@ Checked.int 3y @@>, box 3 + <@@ Checked.int 3s @@>, box 3 + <@@ Checked.int 3us @@>, box 3 + <@@ Checked.int 3 @@>, box 3 + <@@ Checked.int 3u @@>, box 3 + <@@ Checked.int 3L @@>, box 3 + <@@ Checked.int 3UL @@>, box 3 + <@@ Checked.int '\003' @@>, box 3 + <@@ Checked.int 3.0f @@>, box 3 + <@@ Checked.int 3.0 @@>, box 3 + <@@ Checked.int 3.0 @@>, box 3 + <@@ Checked.int 3I @@>, box 3 + <@@ Checked.int LanguagePrimitives.GenericOne @@>, box 1 + <@@ Checked.int LanguagePrimitives.GenericOne @@>, box 1 + <@@ Checked.int 3.0M @@>, box 3 + <@@ Checked.int "3" @@>, box 3 + <@@ Checked.int32 3uy @@>, box 3 + <@@ Checked.int32 3y @@>, box 3 + <@@ Checked.int32 3s @@>, box 3 + <@@ Checked.int32 3us @@>, box 3 + <@@ Checked.int32 3 @@>, box 3 + <@@ Checked.int32 3u @@>, box 3 + <@@ Checked.int32 3L @@>, box 3 + <@@ Checked.int32 3UL @@>, box 3 + <@@ Checked.int32 '\003' @@>, box 3 + <@@ Checked.int32 3.0f @@>, box 3 + <@@ Checked.int32 3.0 @@>, box 3 + <@@ Checked.int32 3.0 @@>, box 3 + <@@ Checked.int32 3I @@>, box 3 + <@@ Checked.int32 LanguagePrimitives.GenericOne @@>, box 1 + <@@ Checked.int32 LanguagePrimitives.GenericOne @@>, box 1 + <@@ Checked.int32 3.0M @@>, box 3 + <@@ Checked.int32 "3" @@>, box 3 + + <@@ uint 3uy @@>, box 3u + <@@ uint 3y @@>, box 3u + <@@ uint 3s @@>, box 3u + <@@ uint 3us @@>, box 3u + <@@ uint 3 @@>, box 3u + <@@ uint 3u @@>, box 3u + <@@ uint 3L @@>, box 3u + <@@ uint 3UL @@>, box 3u + <@@ uint '\003' @@>, box 3u + <@@ uint 3.0f @@>, box 3u + <@@ uint 3.0 @@>, box 3u + <@@ uint 3.0 @@>, box 3u + <@@ uint 3I @@>, box 3u + <@@ uint LanguagePrimitives.GenericOne @@>, box 1u + <@@ uint LanguagePrimitives.GenericOne @@>, box 1u + <@@ uint 3.0M @@>, box 3u + <@@ uint "3" @@>, box 3u + <@@ uint32 3uy @@>, box 3u + <@@ uint32 3y @@>, box 3u + <@@ uint32 3s @@>, box 3u + <@@ uint32 3us @@>, box 3u + <@@ uint32 3 @@>, box 3u + <@@ uint32 3u @@>, box 3u + <@@ uint32 3L @@>, box 3u + <@@ uint32 3UL @@>, box 3u + <@@ uint32 '\003' @@>, box 3u + <@@ uint32 3.0f @@>, box 3u + <@@ uint32 3.0 @@>, box 3u + <@@ uint32 3.0 @@>, box 3u + <@@ uint32 3I @@>, box 3u + <@@ uint32 LanguagePrimitives.GenericOne @@>, box 1u + <@@ uint32 LanguagePrimitives.GenericOne @@>, box 1u + <@@ uint32 3.0M @@>, box 3u + <@@ uint32 "3" @@>, box 3u + <@@ Checked.uint32 3uy @@>, box 3u + <@@ Checked.uint32 3y @@>, box 3u + <@@ Checked.uint32 3s @@>, box 3u + <@@ Checked.uint32 3us @@>, box 3u + <@@ Checked.uint32 3 @@>, box 3u + <@@ Checked.uint32 3u @@>, box 3u + <@@ Checked.uint32 3L @@>, box 3u + <@@ Checked.uint32 3UL @@>, box 3u + <@@ Checked.uint32 '\003' @@>, box 3u + <@@ Checked.uint32 3.0f @@>, box 3u + <@@ Checked.uint32 3.0 @@>, box 3u + <@@ Checked.uint32 3.0 @@>, box 3u + <@@ Checked.uint32 3I @@>, box 3u + <@@ Checked.uint32 LanguagePrimitives.GenericOne @@>, box 1u + <@@ Checked.uint32 LanguagePrimitives.GenericOne @@>, box 1u + <@@ Checked.uint32 3.0M @@>, box 3u + <@@ Checked.uint32 "3" @@>, box 3u + + <@@ int64 3uy @@>, box 3L + <@@ int64 3y @@>, box 3L + <@@ int64 3s @@>, box 3L + <@@ int64 3us @@>, box 3L + <@@ int64 3 @@>, box 3L + <@@ int64 3u @@>, box 3L + <@@ int64 3L @@>, box 3L + <@@ int64 3UL @@>, box 3L + <@@ int64 '\003' @@>, box 3L + <@@ int64 3.0f @@>, box 3L + <@@ int64 3.0 @@>, box 3L + <@@ int64 3.0 @@>, box 3L + <@@ int64 3I @@>, box 3L + <@@ int64 LanguagePrimitives.GenericOne @@>, box 1L + <@@ int64 LanguagePrimitives.GenericOne @@>, box 1L + <@@ int64 3.0M @@>, box 3L + <@@ int64 "3" @@>, box 3L + <@@ Checked.int64 3uy @@>, box 3L + <@@ Checked.int64 3y @@>, box 3L + <@@ Checked.int64 3s @@>, box 3L + <@@ Checked.int64 3us @@>, box 3L + <@@ Checked.int64 3 @@>, box 3L + <@@ Checked.int64 3u @@>, box 3L + <@@ Checked.int64 3L @@>, box 3L + <@@ Checked.int64 3UL @@>, box 3L + <@@ Checked.int64 '\003' @@>, box 3L + <@@ Checked.int64 3.0f @@>, box 3L + <@@ Checked.int64 3.0 @@>, box 3L + <@@ Checked.int64 3.0 @@>, box 3L + <@@ Checked.int64 3I @@>, box 3L + <@@ Checked.int64 LanguagePrimitives.GenericOne @@>, box 1L + <@@ Checked.int64 LanguagePrimitives.GenericOne @@>, box 1L + <@@ Checked.int64 3.0M @@>, box 3L + <@@ Checked.int64 "3" @@>, box 3L + + <@@ uint64 3uy @@>, box 3UL + <@@ uint64 3y @@>, box 3UL + <@@ uint64 3s @@>, box 3UL + <@@ uint64 3us @@>, box 3UL + <@@ uint64 3 @@>, box 3UL + <@@ uint64 3u @@>, box 3UL + <@@ uint64 3L @@>, box 3UL + <@@ uint64 3UL @@>, box 3UL + <@@ uint64 '\003' @@>, box 3UL + <@@ uint64 3.0f @@>, box 3UL + <@@ uint64 3.0 @@>, box 3UL + <@@ uint64 3.0 @@>, box 3UL + <@@ uint64 3I @@>, box 3UL + <@@ uint64 LanguagePrimitives.GenericOne @@>, box 1UL + <@@ uint64 LanguagePrimitives.GenericOne @@>, box 1UL + <@@ uint64 3.0M @@>, box 3UL + <@@ uint64 "3" @@>, box 3UL + <@@ Checked.uint64 3uy @@>, box 3UL + <@@ Checked.uint64 3y @@>, box 3UL + <@@ Checked.uint64 3s @@>, box 3UL + <@@ Checked.uint64 3us @@>, box 3UL + <@@ Checked.uint64 3 @@>, box 3UL + <@@ Checked.uint64 3u @@>, box 3UL + <@@ Checked.uint64 3L @@>, box 3UL + <@@ Checked.uint64 3UL @@>, box 3UL + <@@ Checked.uint64 '\003' @@>, box 3UL + <@@ Checked.uint64 3.0f @@>, box 3UL + <@@ Checked.uint64 3.0 @@>, box 3UL + <@@ Checked.uint64 3.0 @@>, box 3UL + <@@ Checked.uint64 3I @@>, box 3UL + <@@ Checked.uint64 LanguagePrimitives.GenericOne @@>, box 1UL + <@@ Checked.uint64 LanguagePrimitives.GenericOne @@>, box 1UL + <@@ Checked.uint64 3.0M @@>, box 3UL + <@@ Checked.uint64 "3" @@>, box 3UL + + <@@ char 51uy @@>, box '3' + <@@ char 51y @@>, box '3' + <@@ char 51s @@>, box '3' + <@@ char 51us @@>, box '3' + <@@ char 51 @@>, box '3' + <@@ char 51u @@>, box '3' + <@@ char 51L @@>, box '3' + <@@ char 51UL @@>, box '3' + <@@ char '3' @@>, box '3' + <@@ char 51.0f @@>, box '3' + <@@ char 51.0 @@>, box '3' + <@@ char 51.0 @@>, box '3' + <@@ char LanguagePrimitives.GenericOne @@>, box '\001' + <@@ char LanguagePrimitives.GenericOne @@>, box '\001' + <@@ char 51.0M @@>, box '3' + <@@ char "3" @@>, box '3' + <@@ Checked.char 51uy @@>, box '3' + <@@ Checked.char 51y @@>, box '3' + <@@ Checked.char 51s @@>, box '3' + <@@ Checked.char 51us @@>, box '3' + <@@ Checked.char 51 @@>, box '3' + <@@ Checked.char 51u @@>, box '3' + <@@ Checked.char 51L @@>, box '3' + <@@ Checked.char 51UL @@>, box '3' + <@@ Checked.char '3' @@>, box '3' + <@@ Checked.char 51.0f @@>, box '3' + <@@ Checked.char 51.0 @@>, box '3' + <@@ Checked.char 51.0 @@>, box '3' + <@@ Checked.char LanguagePrimitives.GenericOne @@>, box '\001' + <@@ Checked.char LanguagePrimitives.GenericOne @@>, box '\001' + <@@ Checked.char 51.0M @@>, box '3' + <@@ Checked.char "3" @@>, box '3' + + <@@ nativeint 3uy @@>, box 3n + <@@ nativeint 3y @@>, box 3n + <@@ nativeint 3s @@>, box 3n + <@@ nativeint 3us @@>, box 3n + <@@ nativeint 3 @@>, box 3n + <@@ nativeint 3u @@>, box 3n + <@@ nativeint 3L @@>, box 3n + <@@ nativeint 3UL @@>, box 3n + <@@ nativeint '\003' @@>, box 3n + <@@ nativeint 3.0f @@>, box 3n + <@@ nativeint 3.0 @@>, box 3n + <@@ nativeint 3.0 @@>, box 3n + <@@ nativeint LanguagePrimitives.GenericOne @@>, box 1n + <@@ nativeint LanguagePrimitives.GenericOne @@>, box 1n + <@@ nativeint 3.0M @@>, box 3n + <@@ nativeint "3" @@>, box 3n + <@@ Checked.nativeint 3uy @@>, box 3n + <@@ Checked.nativeint 3y @@>, box 3n + <@@ Checked.nativeint 3s @@>, box 3n + <@@ Checked.nativeint 3us @@>, box 3n + <@@ Checked.nativeint 3 @@>, box 3n + <@@ Checked.nativeint 3u @@>, box 3n + <@@ Checked.nativeint 3L @@>, box 3n + <@@ Checked.nativeint 3UL @@>, box 3n + <@@ Checked.nativeint '\003' @@>, box 3n + <@@ Checked.nativeint 3.0f @@>, box 3n + <@@ Checked.nativeint 3.0 @@>, box 3n + <@@ Checked.nativeint 3.0 @@>, box 3n + <@@ Checked.nativeint LanguagePrimitives.GenericOne @@>, box 1n + <@@ Checked.nativeint LanguagePrimitives.GenericOne @@>, box 1n + <@@ Checked.nativeint 3.0M @@>, box 3n + <@@ Checked.nativeint "3" @@>, box 3n + + <@@ unativeint 3uy @@>, box 3un + <@@ unativeint 3y @@>, box 3un + <@@ unativeint 3s @@>, box 3un + <@@ unativeint 3us @@>, box 3un + <@@ unativeint 3 @@>, box 3un + <@@ unativeint 3u @@>, box 3un + <@@ unativeint 3L @@>, box 3un + <@@ unativeint 3UL @@>, box 3un + <@@ unativeint '\003' @@>, box 3un + <@@ unativeint 3.0f @@>, box 3un + <@@ unativeint 3.0 @@>, box 3un + <@@ unativeint 3.0 @@>, box 3un + <@@ unativeint LanguagePrimitives.GenericOne @@>, box 1un + <@@ unativeint LanguagePrimitives.GenericOne @@>, box 1un + <@@ unativeint 3.0M @@>, box 3un + <@@ unativeint "3" @@>, box 3un + <@@ Checked.unativeint 3uy @@>, box 3un + <@@ Checked.unativeint 3y @@>, box 3un + <@@ Checked.unativeint 3s @@>, box 3un + <@@ Checked.unativeint 3us @@>, box 3un + <@@ Checked.unativeint 3 @@>, box 3un + <@@ Checked.unativeint 3u @@>, box 3un + <@@ Checked.unativeint 3L @@>, box 3un + <@@ Checked.unativeint 3UL @@>, box 3un + <@@ Checked.unativeint '\003' @@>, box 3un + <@@ Checked.unativeint 3.0f @@>, box 3un + <@@ Checked.unativeint 3.0 @@>, box 3un + <@@ Checked.unativeint 3.0 @@>, box 3un + <@@ Checked.unativeint LanguagePrimitives.GenericOne @@>, box 1un + <@@ Checked.unativeint LanguagePrimitives.GenericOne @@>, box 1un + <@@ Checked.unativeint 3.0M @@>, box 3un + <@@ Checked.unativeint "3" @@>, box 3un + + <@@ single 3uy @@>, box 3f + <@@ single 3y @@>, box 3f + <@@ single 3s @@>, box 3f + <@@ single 3us @@>, box 3f + <@@ single 3 @@>, box 3f + <@@ single 3u @@>, box 3f + <@@ single 3L @@>, box 3f + <@@ single 3UL @@>, box 3f + <@@ single '\003' @@>, box 3f + <@@ single 3.0f @@>, box 3f + <@@ single 3.0 @@>, box 3f + <@@ single 3.0 @@>, box 3f + <@@ single 3I @@>, box 3f + <@@ single LanguagePrimitives.GenericOne @@>, box 1f + <@@ single LanguagePrimitives.GenericOne @@>, box 1f + <@@ single 3.0M @@>, box 3f + <@@ single "3" @@>, box 3f + <@@ float32 3uy @@>, box 3f + <@@ float32 3y @@>, box 3f + <@@ float32 3s @@>, box 3f + <@@ float32 3us @@>, box 3f + <@@ float32 3 @@>, box 3f + <@@ float32 3u @@>, box 3f + <@@ float32 3L @@>, box 3f + <@@ float32 3UL @@>, box 3f + <@@ float32 '\003' @@>, box 3f + <@@ float32 3.0f @@>, box 3f + <@@ float32 3.0 @@>, box 3f + <@@ float32 3.0 @@>, box 3f + <@@ float32 3I @@>, box 3f + <@@ float32 LanguagePrimitives.GenericOne @@>, box 1f + <@@ float32 LanguagePrimitives.GenericOne @@>, box 1f + <@@ float32 3.0M @@>, box 3f + <@@ float32 "3" @@>, box 3f + + <@@ double 3uy @@>, box 3. + <@@ double 3y @@>, box 3. + <@@ double 3s @@>, box 3. + <@@ double 3us @@>, box 3. + <@@ double 3 @@>, box 3. + <@@ double 3u @@>, box 3. + <@@ double 3L @@>, box 3. + <@@ double 3UL @@>, box 3. + <@@ double '\003' @@>, box 3. + <@@ double 3.0f @@>, box 3. + <@@ double 3.0 @@>, box 3. + <@@ double 3.0 @@>, box 3. + <@@ double 3I @@>, box 3. + <@@ double LanguagePrimitives.GenericOne @@>, box 1. + <@@ double LanguagePrimitives.GenericOne @@>, box 1. + <@@ double 3.0M @@>, box 3. + <@@ double "3" @@>, box 3. + <@@ float 3uy @@>, box 3. + <@@ float 3y @@>, box 3. + <@@ float 3s @@>, box 3. + <@@ float 3us @@>, box 3. + <@@ float 3 @@>, box 3. + <@@ float 3u @@>, box 3. + <@@ float 3L @@>, box 3. + <@@ float 3UL @@>, box 3. + <@@ float '\003' @@>, box 3. + <@@ float 3.0f @@>, box 3. + <@@ float 3.0 @@>, box 3. + <@@ float 3.0 @@>, box 3. + <@@ float 3I @@>, box 3. + <@@ float LanguagePrimitives.GenericOne @@>, box 1. + <@@ float LanguagePrimitives.GenericOne @@>, box 1. + <@@ float 3.0M @@>, box 3. + <@@ float "3" @@>, box 3. + + <@@ decimal 3uy @@>, box 3m + <@@ decimal 3y @@>, box 3m + <@@ decimal 3s @@>, box 3m + <@@ decimal 3us @@>, box 3m + <@@ decimal 3 @@>, box 3m + <@@ decimal 3u @@>, box 3m + <@@ decimal 3L @@>, box 3m + <@@ decimal 3UL @@>, box 3m + <@@ decimal '\003' @@>, box 3m + <@@ decimal 3.0f @@>, box 3m + <@@ decimal 3.0 @@>, box 3m + <@@ decimal 3.0 @@>, box 3m + <@@ decimal 3I @@>, box 3m + <@@ decimal LanguagePrimitives.GenericOne @@>, box 1m + <@@ decimal LanguagePrimitives.GenericOne @@>, box 1m + <@@ decimal 3.0M @@>, box 3m + <@@ decimal "3" @@>, box 3m + + <@@ LanguagePrimitives.GenericZero @@>, box 0uy + <@@ LanguagePrimitives.GenericZero @@>, box 0uy + <@@ LanguagePrimitives.GenericZero @@>, box 0y + <@@ LanguagePrimitives.GenericZero @@>, box 0y + <@@ LanguagePrimitives.GenericZero @@>, box 0s + <@@ LanguagePrimitives.GenericZero @@>, box 0us + <@@ LanguagePrimitives.GenericZero @@>, box 0 + <@@ LanguagePrimitives.GenericZero @@>, box 0 + <@@ LanguagePrimitives.GenericZero @@>, box 0u + <@@ LanguagePrimitives.GenericZero @@>, box 0u + <@@ LanguagePrimitives.GenericZero @@>, box 0L + <@@ LanguagePrimitives.GenericZero @@>, box 0UL + <@@ LanguagePrimitives.GenericZero @@>, box 0I + <@@ LanguagePrimitives.GenericZero @@>, box '\000' + <@@ LanguagePrimitives.GenericZero @@>, box 0n + <@@ LanguagePrimitives.GenericZero @@>, box 0un + <@@ LanguagePrimitives.GenericZero @@>, box 0f + <@@ LanguagePrimitives.GenericZero @@>, box 0. + <@@ LanguagePrimitives.GenericZero @@>, box 0m + <@@ LanguagePrimitives.GenericZero> @@>, box 0m + + <@@ LanguagePrimitives.GenericOne @@>, box 1uy + <@@ LanguagePrimitives.GenericOne @@>, box 1uy + <@@ LanguagePrimitives.GenericOne @@>, box 1y + <@@ LanguagePrimitives.GenericOne @@>, box 1y + <@@ LanguagePrimitives.GenericOne @@>, box 1s + <@@ LanguagePrimitives.GenericOne @@>, box 1us + <@@ LanguagePrimitives.GenericOne @@>, box 1 + <@@ LanguagePrimitives.GenericOne @@>, box 1 + <@@ LanguagePrimitives.GenericOne @@>, box 1u + <@@ LanguagePrimitives.GenericOne @@>, box 1u + <@@ LanguagePrimitives.GenericOne @@>, box 1L + <@@ LanguagePrimitives.GenericOne @@>, box 1UL + <@@ LanguagePrimitives.GenericOne @@>, box 1I + <@@ LanguagePrimitives.GenericOne @@>, box '\001' + <@@ LanguagePrimitives.GenericOne @@>, box 1n + <@@ LanguagePrimitives.GenericOne @@>, box 1un + <@@ LanguagePrimitives.GenericOne @@>, box 1f + <@@ LanguagePrimitives.GenericOne @@>, box 1. + <@@ LanguagePrimitives.GenericOne @@>, box 1m + //<@@ LanguagePrimitives.GenericOne> @@>, box 1m // Doesn't typecheck + + <@@ List.sum [ 1; 2 ] @@>, box 3 + <@@ List.sum [ 1I; 2I ] @@>, box 3I + <@@ List.sum [ 1.0f; 2.0f ] @@>, box 3f + <@@ List.sum [ 1.0; 2.0 ] @@>, box 3. + <@@ List.sum [ 1.0M; 2.0M ] @@>, box 3m + <@@ List.sum [ 1.0M; 2.0M ] @@>, box 3m + <@@ List.average [ 1.0; 2.0 ] @@>, box 1.5 + <@@ List.average [ 1.0f; 2.0f ] @@>, box 1.5f + <@@ List.average [ 1.0M; 2.0M ] @@>, box 1.5m + <@@ List.average [ 1.0M; 2.0M ] @@>, box 1.5m + + <@@ Nullable.byte (Nullable<_> 3uy) @@>, box 3uy + <@@ Nullable.byte (Nullable<_> 3y) @@>, box 3uy + <@@ Nullable.byte (Nullable<_> 3s) @@>, box 3uy + <@@ Nullable.byte (Nullable<_> 3us) @@>, box 3uy + <@@ Nullable.byte (Nullable<_> 3) @@>, box 3uy + <@@ Nullable.byte (Nullable<_> 3u) @@>, box 3uy + <@@ Nullable.byte (Nullable<_> 3L) @@>, box 3uy + <@@ Nullable.byte (Nullable<_> 3UL) @@>, box 3uy + <@@ Nullable.byte (Nullable<_> '\003') @@>, box 3uy + <@@ Nullable.byte (Nullable<_> 3.0f) @@>, box 3uy + <@@ Nullable.byte (Nullable<_> 3.0) @@>, box 3uy + <@@ Nullable.byte (Nullable<_> 3.0) @@>, box 3uy + <@@ Nullable.byte (Nullable<_> 3I) @@>, box 3uy + <@@ Nullable.byte (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1uy + <@@ Nullable.byte (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1uy + <@@ Nullable.byte (Nullable<_> 3.0M) @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> 3uy) @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> 3y) @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> 3s) @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> 3us) @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> 3) @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> 3u) @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> 3L) @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> 3UL) @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> '\003') @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> 3.0f) @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> 3.0) @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> 3.0) @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> 3I) @@>, box 3uy + <@@ Nullable.uint8 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1uy + <@@ Nullable.uint8 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1uy + <@@ Nullable.uint8 (Nullable<_> 3.0M) @@>, box 3uy + + <@@ Nullable.sbyte (Nullable<_> 3uy) @@>, box 3y + <@@ Nullable.sbyte (Nullable<_> 3y) @@>, box 3y + <@@ Nullable.sbyte (Nullable<_> 3s) @@>, box 3y + <@@ Nullable.sbyte (Nullable<_> 3us) @@>, box 3y + <@@ Nullable.sbyte (Nullable<_> 3) @@>, box 3y + <@@ Nullable.sbyte (Nullable<_> 3u) @@>, box 3y + <@@ Nullable.sbyte (Nullable<_> 3L) @@>, box 3y + <@@ Nullable.sbyte (Nullable<_> 3UL) @@>, box 3y + <@@ Nullable.sbyte (Nullable<_> '\003') @@>, box 3y + <@@ Nullable.sbyte (Nullable<_> 3.0f) @@>, box 3y + <@@ Nullable.sbyte (Nullable<_> 3.0) @@>, box 3y + <@@ Nullable.sbyte (Nullable<_> 3.0) @@>, box 3y + <@@ Nullable.sbyte (Nullable<_> 3I) @@>, box 3y + <@@ Nullable.sbyte (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1y + <@@ Nullable.sbyte (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1y + <@@ Nullable.sbyte (Nullable<_> 3.0M) @@>, box 3y + <@@ Nullable.int8 (Nullable<_> 3uy) @@>, box 3y + <@@ Nullable.int8 (Nullable<_> 3y) @@>, box 3y + <@@ Nullable.int8 (Nullable<_> 3s) @@>, box 3y + <@@ Nullable.int8 (Nullable<_> 3us) @@>, box 3y + <@@ Nullable.int8 (Nullable<_> 3) @@>, box 3y + <@@ Nullable.int8 (Nullable<_> 3u) @@>, box 3y + <@@ Nullable.int8 (Nullable<_> 3L) @@>, box 3y + <@@ Nullable.int8 (Nullable<_> 3UL) @@>, box 3y + <@@ Nullable.int8 (Nullable<_> '\003') @@>, box 3y + <@@ Nullable.int8 (Nullable<_> 3.0f) @@>, box 3y + <@@ Nullable.int8 (Nullable<_> 3.0) @@>, box 3y + <@@ Nullable.int8 (Nullable<_> 3.0) @@>, box 3y + <@@ Nullable.int8 (Nullable<_> 3I) @@>, box 3y + <@@ Nullable.int8 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1y + <@@ Nullable.int8 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1y + <@@ Nullable.int8 (Nullable<_> 3.0M) @@>, box 3y + + <@@ Nullable.int16 (Nullable<_> 3uy) @@>, box 3s + <@@ Nullable.int16 (Nullable<_> 3y) @@>, box 3s + <@@ Nullable.int16 (Nullable<_> 3s) @@>, box 3s + <@@ Nullable.int16 (Nullable<_> 3us) @@>, box 3s + <@@ Nullable.int16 (Nullable<_> 3) @@>, box 3s + <@@ Nullable.int16 (Nullable<_> 3u) @@>, box 3s + <@@ Nullable.int16 (Nullable<_> 3L) @@>, box 3s + <@@ Nullable.int16 (Nullable<_> 3UL) @@>, box 3s + <@@ Nullable.int16 (Nullable<_> '\003') @@>, box 3s + <@@ Nullable.int16 (Nullable<_> 3.0f) @@>, box 3s + <@@ Nullable.int16 (Nullable<_> 3.0) @@>, box 3s + <@@ Nullable.int16 (Nullable<_> 3.0) @@>, box 3s + <@@ Nullable.int16 (Nullable<_> 3I) @@>, box 3s + <@@ Nullable.int16 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1s + <@@ Nullable.int16 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1s + <@@ Nullable.int16 (Nullable<_> 3.0M) @@>, box 3s + + <@@ Nullable.uint16 (Nullable<_> 3uy) @@>, box 3us + <@@ Nullable.uint16 (Nullable<_> 3y) @@>, box 3us + <@@ Nullable.uint16 (Nullable<_> 3s) @@>, box 3us + <@@ Nullable.uint16 (Nullable<_> 3us) @@>, box 3us + <@@ Nullable.uint16 (Nullable<_> 3) @@>, box 3us + <@@ Nullable.uint16 (Nullable<_> 3u) @@>, box 3us + <@@ Nullable.uint16 (Nullable<_> 3L) @@>, box 3us + <@@ Nullable.uint16 (Nullable<_> 3UL) @@>, box 3us + <@@ Nullable.uint16 (Nullable<_> '\003') @@>, box 3us + <@@ Nullable.uint16 (Nullable<_> 3.0f) @@>, box 3us + <@@ Nullable.uint16 (Nullable<_> 3.0) @@>, box 3us + <@@ Nullable.uint16 (Nullable<_> 3.0) @@>, box 3us + <@@ Nullable.uint16 (Nullable<_> 3I) @@>, box 3us + <@@ Nullable.uint16 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1us + <@@ Nullable.uint16 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1us + <@@ Nullable.uint16 (Nullable<_> 3.0M) @@>, box 3us + + <@@ Nullable.int (Nullable<_> 3uy) @@>, box 3 + <@@ Nullable.int (Nullable<_> 3y) @@>, box 3 + <@@ Nullable.int (Nullable<_> 3s) @@>, box 3 + <@@ Nullable.int (Nullable<_> 3us) @@>, box 3 + <@@ Nullable.int (Nullable<_> 3) @@>, box 3 + <@@ Nullable.int (Nullable<_> 3u) @@>, box 3 + <@@ Nullable.int (Nullable<_> 3L) @@>, box 3 + <@@ Nullable.int (Nullable<_> 3UL) @@>, box 3 + <@@ Nullable.int (Nullable<_> '\003') @@>, box 3 + <@@ Nullable.int (Nullable<_> 3.0f) @@>, box 3 + <@@ Nullable.int (Nullable<_> 3.0) @@>, box 3 + <@@ Nullable.int (Nullable<_> 3.0) @@>, box 3 + <@@ Nullable.int (Nullable<_> 3I) @@>, box 3 + <@@ Nullable.int (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1 + <@@ Nullable.int (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1 + <@@ Nullable.int (Nullable<_> 3.0M) @@>, box 3 + <@@ Nullable.int32 (Nullable<_> 3uy) @@>, box 3 + <@@ Nullable.int32 (Nullable<_> 3y) @@>, box 3 + <@@ Nullable.int32 (Nullable<_> 3s) @@>, box 3 + <@@ Nullable.int32 (Nullable<_> 3us) @@>, box 3 + <@@ Nullable.int32 (Nullable<_> 3) @@>, box 3 + <@@ Nullable.int32 (Nullable<_> 3u) @@>, box 3 + <@@ Nullable.int32 (Nullable<_> 3L) @@>, box 3 + <@@ Nullable.int32 (Nullable<_> 3UL) @@>, box 3 + <@@ Nullable.int32 (Nullable<_> '\003') @@>, box 3 + <@@ Nullable.int32 (Nullable<_> 3.0f) @@>, box 3 + <@@ Nullable.int32 (Nullable<_> 3.0) @@>, box 3 + <@@ Nullable.int32 (Nullable<_> 3.0) @@>, box 3 + <@@ Nullable.int32 (Nullable<_> 3I) @@>, box 3 + <@@ Nullable.int32 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1 + <@@ Nullable.int32 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1 + <@@ Nullable.int32 (Nullable<_> 3.0M) @@>, box 3 + + <@@ Nullable.uint (Nullable<_> 3uy) @@>, box 3u + <@@ Nullable.uint (Nullable<_> 3y) @@>, box 3u + <@@ Nullable.uint (Nullable<_> 3s) @@>, box 3u + <@@ Nullable.uint (Nullable<_> 3us) @@>, box 3u + <@@ Nullable.uint (Nullable<_> 3) @@>, box 3u + <@@ Nullable.uint (Nullable<_> 3u) @@>, box 3u + <@@ Nullable.uint (Nullable<_> 3L) @@>, box 3u + <@@ Nullable.uint (Nullable<_> 3UL) @@>, box 3u + <@@ Nullable.uint (Nullable<_> '\003') @@>, box 3u + <@@ Nullable.uint (Nullable<_> 3.0f) @@>, box 3u + <@@ Nullable.uint (Nullable<_> 3.0) @@>, box 3u + <@@ Nullable.uint (Nullable<_> 3.0) @@>, box 3u + <@@ Nullable.uint (Nullable<_> 3I) @@>, box 3u + <@@ Nullable.uint (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1u + <@@ Nullable.uint (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1u + <@@ Nullable.uint (Nullable<_> 3.0M) @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> 3uy) @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> 3y) @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> 3s) @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> 3us) @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> 3) @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> 3u) @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> 3L) @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> 3UL) @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> '\003') @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> 3.0f) @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> 3.0) @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> 3.0) @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> 3I) @@>, box 3u + <@@ Nullable.uint32 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1u + <@@ Nullable.uint32 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1u + <@@ Nullable.uint32 (Nullable<_> 3.0M) @@>, box 3u + + <@@ Nullable.int64 (Nullable<_> 3uy) @@>, box 3L + <@@ Nullable.int64 (Nullable<_> 3y) @@>, box 3L + <@@ Nullable.int64 (Nullable<_> 3s) @@>, box 3L + <@@ Nullable.int64 (Nullable<_> 3us) @@>, box 3L + <@@ Nullable.int64 (Nullable<_> 3) @@>, box 3L + <@@ Nullable.int64 (Nullable<_> 3u) @@>, box 3L + <@@ Nullable.int64 (Nullable<_> 3L) @@>, box 3L + <@@ Nullable.int64 (Nullable<_> 3UL) @@>, box 3L + <@@ Nullable.int64 (Nullable<_> '\003') @@>, box 3L + <@@ Nullable.int64 (Nullable<_> 3.0f) @@>, box 3L + <@@ Nullable.int64 (Nullable<_> 3.0) @@>, box 3L + <@@ Nullable.int64 (Nullable<_> 3.0) @@>, box 3L + <@@ Nullable.int64 (Nullable<_> 3I) @@>, box 3L + <@@ Nullable.int64 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1L + <@@ Nullable.int64 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1L + <@@ Nullable.int64 (Nullable<_> 3.0M) @@>, box 3L + + <@@ Nullable.uint64 (Nullable<_> 3uy) @@>, box 3UL + <@@ Nullable.uint64 (Nullable<_> 3y) @@>, box 3UL + <@@ Nullable.uint64 (Nullable<_> 3s) @@>, box 3UL + <@@ Nullable.uint64 (Nullable<_> 3us) @@>, box 3UL + <@@ Nullable.uint64 (Nullable<_> 3) @@>, box 3UL + <@@ Nullable.uint64 (Nullable<_> 3u) @@>, box 3UL + <@@ Nullable.uint64 (Nullable<_> 3L) @@>, box 3UL + <@@ Nullable.uint64 (Nullable<_> 3UL) @@>, box 3UL + <@@ Nullable.uint64 (Nullable<_> '\003') @@>, box 3UL + <@@ Nullable.uint64 (Nullable<_> 3.0f) @@>, box 3UL + <@@ Nullable.uint64 (Nullable<_> 3.0) @@>, box 3UL + <@@ Nullable.uint64 (Nullable<_> 3.0) @@>, box 3UL + <@@ Nullable.uint64 (Nullable<_> 3I) @@>, box 3UL + <@@ Nullable.uint64 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1UL + <@@ Nullable.uint64 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1UL + <@@ Nullable.uint64 (Nullable<_> 3.0M) @@>, box 3UL + + <@@ Nullable.char (Nullable<_> 51uy) @@>, box '3' + <@@ Nullable.char (Nullable<_> 51y) @@>, box '3' + <@@ Nullable.char (Nullable<_> 51s) @@>, box '3' + <@@ Nullable.char (Nullable<_> 51us) @@>, box '3' + <@@ Nullable.char (Nullable<_> 51) @@>, box '3' + <@@ Nullable.char (Nullable<_> 51u) @@>, box '3' + <@@ Nullable.char (Nullable<_> 51L) @@>, box '3' + <@@ Nullable.char (Nullable<_> 51UL) @@>, box '3' + <@@ Nullable.char (Nullable<_> '3') @@>, box '3' + <@@ Nullable.char (Nullable<_> 51.0f) @@>, box '3' + <@@ Nullable.char (Nullable<_> 51.0) @@>, box '3' + <@@ Nullable.char (Nullable<_> 51.0) @@>, box '3' + <@@ Nullable.char (Nullable<_> LanguagePrimitives.GenericOne) @@>, box '\001' + <@@ Nullable.char (Nullable<_> LanguagePrimitives.GenericOne) @@>, box '\001' + <@@ Nullable.char (Nullable<_> 51.0M) @@>, box '3' + + <@@ Nullable.single (Nullable<_> 3uy) @@>, box 3f + <@@ Nullable.single (Nullable<_> 3y) @@>, box 3f + <@@ Nullable.single (Nullable<_> 3s) @@>, box 3f + <@@ Nullable.single (Nullable<_> 3us) @@>, box 3f + <@@ Nullable.single (Nullable<_> 3) @@>, box 3f + <@@ Nullable.single (Nullable<_> 3u) @@>, box 3f + <@@ Nullable.single (Nullable<_> 3L) @@>, box 3f + <@@ Nullable.single (Nullable<_> 3UL) @@>, box 3f + <@@ Nullable.single (Nullable<_> '\003') @@>, box 3f + <@@ Nullable.single (Nullable<_> 3.0f) @@>, box 3f + <@@ Nullable.single (Nullable<_> 3.0) @@>, box 3f + <@@ Nullable.single (Nullable<_> 3.0) @@>, box 3f + <@@ Nullable.single (Nullable<_> 3I) @@>, box 3f + <@@ Nullable.single (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1f + <@@ Nullable.single (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1f + <@@ Nullable.single (Nullable<_> 3.0M) @@>, box 3f + <@@ Nullable.float32 (Nullable<_> 3uy) @@>, box 3f + <@@ Nullable.float32 (Nullable<_> 3y) @@>, box 3f + <@@ Nullable.float32 (Nullable<_> 3s) @@>, box 3f + <@@ Nullable.float32 (Nullable<_> 3us) @@>, box 3f + <@@ Nullable.float32 (Nullable<_> 3) @@>, box 3f + <@@ Nullable.float32 (Nullable<_> 3u) @@>, box 3f + <@@ Nullable.float32 (Nullable<_> 3L) @@>, box 3f + <@@ Nullable.float32 (Nullable<_> 3UL) @@>, box 3f + <@@ Nullable.float32 (Nullable<_> '\003') @@>, box 3f + <@@ Nullable.float32 (Nullable<_> 3.0f) @@>, box 3f + <@@ Nullable.float32 (Nullable<_> 3.0) @@>, box 3f + <@@ Nullable.float32 (Nullable<_> 3.0) @@>, box 3f + <@@ Nullable.float32 (Nullable<_> 3I) @@>, box 3f + <@@ Nullable.float32 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1f + <@@ Nullable.float32 (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1f + <@@ Nullable.float32 (Nullable<_> 3.0M) @@>, box 3f + + <@@ Nullable.double (Nullable<_> 3uy) @@>, box 3. + <@@ Nullable.double (Nullable<_> 3y) @@>, box 3. + <@@ Nullable.double (Nullable<_> 3s) @@>, box 3. + <@@ Nullable.double (Nullable<_> 3us) @@>, box 3. + <@@ Nullable.double (Nullable<_> 3) @@>, box 3. + <@@ Nullable.double (Nullable<_> 3u) @@>, box 3. + <@@ Nullable.double (Nullable<_> 3L) @@>, box 3. + <@@ Nullable.double (Nullable<_> 3UL) @@>, box 3. + <@@ Nullable.double (Nullable<_> '\003') @@>, box 3. + <@@ Nullable.double (Nullable<_> 3.0f) @@>, box 3. + <@@ Nullable.double (Nullable<_> 3.0) @@>, box 3. + <@@ Nullable.double (Nullable<_> 3.0) @@>, box 3. + <@@ Nullable.double (Nullable<_> 3I) @@>, box 3. + <@@ Nullable.double (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1. + <@@ Nullable.double (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1. + <@@ Nullable.double (Nullable<_> 3.0M) @@>, box 3. + <@@ Nullable.float (Nullable<_> 3uy) @@>, box 3. + <@@ Nullable.float (Nullable<_> 3y) @@>, box 3. + <@@ Nullable.float (Nullable<_> 3s) @@>, box 3. + <@@ Nullable.float (Nullable<_> 3us) @@>, box 3. + <@@ Nullable.float (Nullable<_> 3) @@>, box 3. + <@@ Nullable.float (Nullable<_> 3u) @@>, box 3. + <@@ Nullable.float (Nullable<_> 3L) @@>, box 3. + <@@ Nullable.float (Nullable<_> 3UL) @@>, box 3. + <@@ Nullable.float (Nullable<_> '\003') @@>, box 3. + <@@ Nullable.float (Nullable<_> 3.0f) @@>, box 3. + <@@ Nullable.float (Nullable<_> 3.0) @@>, box 3. + <@@ Nullable.float (Nullable<_> 3.0) @@>, box 3. + <@@ Nullable.float (Nullable<_> 3I) @@>, box 3. + <@@ Nullable.float (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1. + <@@ Nullable.float (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1. + <@@ Nullable.float (Nullable<_> 3.0M) @@>, box 3. + + <@@ Nullable.decimal (Nullable<_> 3uy) @@>, box 3m + <@@ Nullable.decimal (Nullable<_> 3y) @@>, box 3m + <@@ Nullable.decimal (Nullable<_> 3s) @@>, box 3m + <@@ Nullable.decimal (Nullable<_> 3us) @@>, box 3m + <@@ Nullable.decimal (Nullable<_> 3) @@>, box 3m + <@@ Nullable.decimal (Nullable<_> 3u) @@>, box 3m + <@@ Nullable.decimal (Nullable<_> 3L) @@>, box 3m + <@@ Nullable.decimal (Nullable<_> 3UL) @@>, box 3m + <@@ Nullable.decimal (Nullable<_> '\003') @@>, box 3m + <@@ Nullable.decimal (Nullable<_> 3.0f) @@>, box 3m + <@@ Nullable.decimal (Nullable<_> 3.0) @@>, box 3m + <@@ Nullable.decimal (Nullable<_> 3.0) @@>, box 3m + <@@ Nullable.decimal (Nullable<_> 3I) @@>, box 3m + <@@ Nullable.decimal (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1m + <@@ Nullable.decimal (Nullable<_> LanguagePrimitives.GenericOne) @@>, box 1m + <@@ Nullable.decimal (Nullable<_> 3.0M) @@>, box 3m + + <@@ Nullable<_> 1y ?+ 4y @@>, box 5y + <@@ Nullable<_> 1uy ?+ 4uy @@>, box 5uy + <@@ Nullable<_> 1s ?+ 4s @@>, box 5s + <@@ Nullable<_> 1us ?+ 4us @@>, box 5us + <@@ Nullable<_> 1 ?+ 4 @@>, box 5 + <@@ Nullable<_> 1u ?+ 4u @@>, box 5u + <@@ Nullable<_> 1L ?+ 4L @@>, box 5L + <@@ Nullable<_> 1uL ?+ 4uL @@>, box 5uL + <@@ Nullable<_> 1.0f ?+ 4.0f @@>, box 5f + <@@ Nullable<_> 1.0 ?+ 4.0 @@>, box 5. + <@@ Nullable<_> 1m ?+ 4m @@>, box 5m + <@@ Nullable<_> 1m ?+ 4m @@>, box 5m + <@@ Nullable<_> 1I ?+ 4I @@>, box 5I + <@@ Nullable<_> '1' ?+ '\004' @@>, box '5' + <@@ Nullable<_> LanguagePrimitives.GenericOne ?+ LanguagePrimitives.GenericOne @@>, box 2n + <@@ Nullable<_> LanguagePrimitives.GenericOne ?+ LanguagePrimitives.GenericOne @@>, box 2un + + <@@ 1y +? Nullable<_> 4y @@>, box 5y + <@@ 1uy +? Nullable<_> 4uy @@>, box 5uy + <@@ 1s +? Nullable<_> 4s @@>, box 5s + <@@ 1us +? Nullable<_> 4us @@>, box 5us + <@@ 1 +? Nullable<_> 4 @@>, box 5 + <@@ 1u +? Nullable<_> 4u @@>, box 5u + <@@ 1L +? Nullable<_> 4L @@>, box 5L + <@@ 1uL +? Nullable<_> 4uL @@>, box 5uL + <@@ 1.0f +? Nullable<_> 4.0f @@>, box 5f + <@@ 1.0 +? Nullable<_> 4.0 @@>, box 5. + <@@ 1m +? Nullable<_> 4m @@>, box 5m + <@@ 1m +? Nullable<_> 4m @@>, box 5m + <@@ 1I +? Nullable<_> 4I @@>, box 5I + <@@ '1' +? Nullable<_> '\004' @@>, box '5' + <@@ LanguagePrimitives.GenericOne +? Nullable<_> LanguagePrimitives.GenericOne @@>, box 2n + <@@ LanguagePrimitives.GenericOne +? Nullable<_> LanguagePrimitives.GenericOne @@>, box 2un + + <@@ Nullable<_> 1y ?+? Nullable<_> 4y @@>, box 5y + <@@ Nullable<_> 1uy ?+? Nullable<_> 4uy @@>, box 5uy + <@@ Nullable<_> 1s ?+? Nullable<_> 4s @@>, box 5s + <@@ Nullable<_> 1us ?+? Nullable<_> 4us @@>, box 5us + <@@ Nullable<_> 1 ?+? Nullable<_> 4 @@>, box 5 + <@@ Nullable<_> 1u ?+? Nullable<_> 4u @@>, box 5u + <@@ Nullable<_> 1L ?+? Nullable<_> 4L @@>, box 5L + <@@ Nullable<_> 1uL ?+? Nullable<_> 4uL @@>, box 5uL + <@@ Nullable<_> 1.0f ?+? Nullable<_> 4.0f @@>, box 5f + <@@ Nullable<_> 1.0 ?+? Nullable<_> 4.0 @@>, box 5. + <@@ Nullable<_> 1m ?+? Nullable<_> 4m @@>, box 5m + <@@ Nullable<_> 1m ?+? Nullable<_> 4m @@>, box 5m + <@@ Nullable<_> 1I ?+? Nullable<_> 4I @@>, box 5I + <@@ Nullable<_> '1' ?+? Nullable<_> '\004' @@>, box '5' + <@@ Nullable<_> LanguagePrimitives.GenericOne ?+? Nullable<_> LanguagePrimitives.GenericOne @@>, box 2n + <@@ Nullable<_> LanguagePrimitives.GenericOne ?+? Nullable<_> LanguagePrimitives.GenericOne @@>, box 2un + + <@@ Nullable<_> 4y ?- 1y @@>, box 3y + <@@ Nullable<_> 4uy ?- 1uy @@>, box 3uy + <@@ Nullable<_> 4s ?- 1s @@>, box 3s + <@@ Nullable<_> 4us ?- 1us @@>, box 3us + <@@ Nullable<_> 4 ?- 1 @@>, box 3 + <@@ Nullable<_> 4u ?- 1u @@>, box 3u + <@@ Nullable<_> 4L ?- 1L @@>, box 3L + <@@ Nullable<_> 4uL ?- 1uL @@>, box 3uL + <@@ Nullable<_> 4.0f ?- 1.0f @@>, box 3f + <@@ Nullable<_> 4.0 ?- 1.0 @@>, box 3. + <@@ Nullable<_> 4m ?- 1m @@>, box 3m + <@@ Nullable<_> 4m ?- 1m @@>, box 3m + <@@ Nullable<_> 4I ?- 1I @@>, box 3I + <@@ Nullable<_> '4' ?- '\001' @@>, box '3' + <@@ Nullable<_> LanguagePrimitives.GenericOne ?- LanguagePrimitives.GenericOne @@>, box 0n + <@@ Nullable<_> LanguagePrimitives.GenericOne ?- LanguagePrimitives.GenericOne @@>, box 0un + + <@@ 4y -? Nullable<_> 1y @@>, box 3y + <@@ 4uy -? Nullable<_> 1uy @@>, box 3uy + <@@ 4s -? Nullable<_> 1s @@>, box 3s + <@@ 4us -? Nullable<_> 1us @@>, box 3us + <@@ 4 -? Nullable<_> 1 @@>, box 3 + <@@ 4u -? Nullable<_> 1u @@>, box 3u + <@@ 4L -? Nullable<_> 1L @@>, box 3L + <@@ 4uL -? Nullable<_> 1uL @@>, box 3uL + <@@ 4.0f -? Nullable<_> 1.0f @@>, box 3f + <@@ 4.0 -? Nullable<_> 1.0 @@>, box 3. + <@@ 4m -? Nullable<_> 1m @@>, box 3m + <@@ 4m -? Nullable<_> 1m @@>, box 3m + <@@ 4I -? Nullable<_> 1I @@>, box 3I + <@@ '4' -? Nullable<_> '\001' @@>, box '3' + <@@ LanguagePrimitives.GenericOne -? Nullable<_> LanguagePrimitives.GenericOne @@>, box 0n + <@@ LanguagePrimitives.GenericOne -? Nullable<_> LanguagePrimitives.GenericOne @@>, box 0un + + <@@ Nullable<_> 4y ?-? Nullable<_> 1y @@>, box 3y + <@@ Nullable<_> 4uy ?-? Nullable<_> 1uy @@>, box 3uy + <@@ Nullable<_> 4s ?-? Nullable<_> 1s @@>, box 3s + <@@ Nullable<_> 4us ?-? Nullable<_> 1us @@>, box 3us + <@@ Nullable<_> 4 ?-? Nullable<_> 1 @@>, box 3 + <@@ Nullable<_> 4u ?-? Nullable<_> 1u @@>, box 3u + <@@ Nullable<_> 4L ?-? Nullable<_> 1L @@>, box 3L + <@@ Nullable<_> 4uL ?-? Nullable<_> 1uL @@>, box 3uL + <@@ Nullable<_> 4.0f ?-? Nullable<_> 1.0f @@>, box 3f + <@@ Nullable<_> 4.0 ?-? Nullable<_> 1.0 @@>, box 3. + <@@ Nullable<_> 4m ?-? Nullable<_> 1m @@>, box 3m + <@@ Nullable<_> 4m ?-? Nullable<_> 1m @@>, box 3m + <@@ Nullable<_> 4I ?-? Nullable<_> 1I @@>, box 3I + <@@ Nullable<_> '4' ?-? Nullable<_> '\001' @@>, box '3' + <@@ Nullable<_> LanguagePrimitives.GenericOne ?-? Nullable<_> LanguagePrimitives.GenericOne @@>, box 0n + <@@ Nullable<_> LanguagePrimitives.GenericOne ?-? Nullable<_> LanguagePrimitives.GenericOne @@>, box 0un + + <@@ Nullable<_> 2y ?* 4y @@>, box 8y + <@@ Nullable<_> 2uy ?* 4uy @@>, box 8uy + <@@ Nullable<_> 2s ?* 4s @@>, box 8s + <@@ Nullable<_> 2us ?* 4us @@>, box 8us + <@@ Nullable<_> 2 ?* 4 @@>, box 8 + <@@ Nullable<_> 2u ?* 4u @@>, box 8u + <@@ Nullable<_> 2L ?* 4L @@>, box 8L + <@@ Nullable<_> 2uL ?* 4uL @@>, box 8uL + <@@ Nullable<_> 2.0f ?* 4.0f @@>, box 8f + <@@ Nullable<_> 2.0 ?* 4.0 @@>, box 8. + <@@ Nullable<_> 2m ?* 4m @@>, box 8m + <@@ Nullable<_> 2m ?* 4m @@>, box 8m + <@@ Nullable<_> 2I ?* 4I @@>, box 8I + <@@ Nullable<_> LanguagePrimitives.GenericOne ?* LanguagePrimitives.GenericOne @@>, box 1n + <@@ Nullable<_> LanguagePrimitives.GenericOne ?* LanguagePrimitives.GenericOne @@>, box 1un + + <@@ 2y *? Nullable<_> 4y @@>, box 8y + <@@ 2uy *? Nullable<_> 4uy @@>, box 8uy + <@@ 2s *? Nullable<_> 4s @@>, box 8s + <@@ 2us *? Nullable<_> 4us @@>, box 8us + <@@ 2 *? Nullable<_> 4 @@>, box 8 + <@@ 2u *? Nullable<_> 4u @@>, box 8u + <@@ 2L *? Nullable<_> 4L @@>, box 8L + <@@ 2uL *? Nullable<_> 4uL @@>, box 8uL + <@@ 2.0f *? Nullable<_> 4.0f @@>, box 8f + <@@ 2.0 *? Nullable<_> 4.0 @@>, box 8. + <@@ 2m *? Nullable<_> 4m @@>, box 8m + <@@ 2m *? Nullable<_> 4m @@>, box 8m + <@@ 2I *? Nullable<_> 4I @@>, box 8I + <@@ LanguagePrimitives.GenericOne *? Nullable<_> LanguagePrimitives.GenericOne @@>, box 1n + <@@ LanguagePrimitives.GenericOne *? Nullable<_> LanguagePrimitives.GenericOne @@>, box 1un + + <@@ Nullable<_> 2y ?*? Nullable<_> 4y @@>, box 8y + <@@ Nullable<_> 2uy ?*? Nullable<_> 4uy @@>, box 8uy + <@@ Nullable<_> 2s ?*? Nullable<_> 4s @@>, box 8s + <@@ Nullable<_> 2us ?*? Nullable<_> 4us @@>, box 8us + <@@ Nullable<_> 2 ?*? Nullable<_> 4 @@>, box 8 + <@@ Nullable<_> 2u ?*? Nullable<_> 4u @@>, box 8u + <@@ Nullable<_> 2L ?*? Nullable<_> 4L @@>, box 8L + <@@ Nullable<_> 2uL ?*? Nullable<_> 4uL @@>, box 8uL + <@@ Nullable<_> 2.0f ?*? Nullable<_> 4.0f @@>, box 8f + <@@ Nullable<_> 2.0 ?*? Nullable<_> 4.0 @@>, box 8. + <@@ Nullable<_> 2m ?*? Nullable<_> 4m @@>, box 8m + <@@ Nullable<_> 2m ?*? Nullable<_> 4m @@>, box 8m + <@@ Nullable<_> 2I ?*? Nullable<_> 4I @@>, box 8I + <@@ Nullable<_> LanguagePrimitives.GenericOne ?*? Nullable<_> LanguagePrimitives.GenericOne @@>, box 1n + <@@ Nullable<_> LanguagePrimitives.GenericOne ?*? Nullable<_> LanguagePrimitives.GenericOne @@>, box 1un + + <@@ Nullable<_> 6y ?/ 3y @@>, box 2y + <@@ Nullable<_> 6uy ?/ 3uy @@>, box 2uy + <@@ Nullable<_> 6s ?/ 3s @@>, box 2s + <@@ Nullable<_> 6us ?/ 3us @@>, box 2us + <@@ Nullable<_> 6 ?/ 3 @@>, box 2 + <@@ Nullable<_> 6u ?/ 3u @@>, box 2u + <@@ Nullable<_> 6L ?/ 3L @@>, box 2L + <@@ Nullable<_> 6uL ?/ 3uL @@>, box 2uL + <@@ Nullable<_> 6.0f ?/ 3.0f @@>, box 2f + <@@ Nullable<_> 6.0 ?/ 3.0 @@>, box 2. + <@@ Nullable<_> 6m ?/ 3m @@>, box 2m + <@@ Nullable<_> 6m ?/ 3m @@>, box 2m + <@@ Nullable<_> 6I ?/ 3I @@>, box 2I + <@@ Nullable<_> LanguagePrimitives.GenericOne ?/ LanguagePrimitives.GenericOne @@>, box 1n + <@@ Nullable<_> LanguagePrimitives.GenericOne ?/ LanguagePrimitives.GenericOne @@>, box 1un + + <@@ 6y /? Nullable<_> 3y @@>, box 2y + <@@ 6uy /? Nullable<_> 3uy @@>, box 2uy + <@@ 6s /? Nullable<_> 3s @@>, box 2s + <@@ 6us /? Nullable<_> 3us @@>, box 2us + <@@ 6 /? Nullable<_> 3 @@>, box 2 + <@@ 6u /? Nullable<_> 3u @@>, box 2u + <@@ 6L /? Nullable<_> 3L @@>, box 2L + <@@ 6uL /? Nullable<_> 3uL @@>, box 2uL + <@@ 6.0f /? Nullable<_> 3.0f @@>, box 2f + <@@ 6.0 /? Nullable<_> 3.0 @@>, box 2. + <@@ 6m /? Nullable<_> 3m @@>, box 2m + <@@ 6m /? Nullable<_> 3m @@>, box 2m + <@@ 6I /? Nullable<_> 3I @@>, box 2I + <@@ LanguagePrimitives.GenericOne /? Nullable<_> LanguagePrimitives.GenericOne @@>, box 1n + <@@ LanguagePrimitives.GenericOne /? Nullable<_> LanguagePrimitives.GenericOne @@>, box 1un + + <@@ Nullable<_> 6y ?/? Nullable<_> 3y @@>, box 2y + <@@ Nullable<_> 6uy ?/? Nullable<_> 3uy @@>, box 2uy + <@@ Nullable<_> 6s ?/? Nullable<_> 3s @@>, box 2s + <@@ Nullable<_> 6us ?/? Nullable<_> 3us @@>, box 2us + <@@ Nullable<_> 6 ?/? Nullable<_> 3 @@>, box 2 + <@@ Nullable<_> 6u ?/? Nullable<_> 3u @@>, box 2u + <@@ Nullable<_> 6L ?/? Nullable<_> 3L @@>, box 2L + <@@ Nullable<_> 6uL ?/? Nullable<_> 3uL @@>, box 2uL + <@@ Nullable<_> 6.0f ?/? Nullable<_> 3.0f @@>, box 2f + <@@ Nullable<_> 6.0 ?/? Nullable<_> 3.0 @@>, box 2. + <@@ Nullable<_> 6m ?/? Nullable<_> 3m @@>, box 2m + <@@ Nullable<_> 6m ?/? Nullable<_> 3m @@>, box 2m + <@@ Nullable<_> 6I ?/? Nullable<_> 3I @@>, box 2I + <@@ Nullable<_> LanguagePrimitives.GenericOne ?/? Nullable<_> LanguagePrimitives.GenericOne @@>, box 1n + <@@ Nullable<_> LanguagePrimitives.GenericOne ?/? Nullable<_> LanguagePrimitives.GenericOne @@>, box 1un + + <@@ Nullable<_> 9y ?% 4y @@>, box 1y + <@@ Nullable<_> 9uy ?% 4uy @@>, box 1uy + <@@ Nullable<_> 9s ?% 4s @@>, box 1s + <@@ Nullable<_> 9us ?% 4us @@>, box 1us + <@@ Nullable<_> 9 ?% 4 @@>, box 1 + <@@ Nullable<_> 9u ?% 4u @@>, box 1u + <@@ Nullable<_> 9L ?% 4L @@>, box 1L + <@@ Nullable<_> 9uL ?% 4uL @@>, box 1uL + <@@ Nullable<_> 9.0f ?% 4.0f @@>, box 1f + <@@ Nullable<_> 9.0 ?% 4.0 @@>, box 1. + <@@ Nullable<_> 9m ?% 4m @@>, box 1m + <@@ Nullable<_> 9m ?% 4m @@>, box 1m + <@@ Nullable<_> 9I ?% 4I @@>, box 1I + <@@ Nullable<_> LanguagePrimitives.GenericOne ?% LanguagePrimitives.GenericOne @@>, box 0n + <@@ Nullable<_> LanguagePrimitives.GenericOne ?% LanguagePrimitives.GenericOne @@>, box 0un + + <@@ 9y %? Nullable<_> 4y @@>, box 1y + <@@ 9uy %? Nullable<_> 4uy @@>, box 1uy + <@@ 9s %? Nullable<_> 4s @@>, box 1s + <@@ 9us %? Nullable<_> 4us @@>, box 1us + <@@ 9 %? Nullable<_> 4 @@>, box 1 + <@@ 9u %? Nullable<_> 4u @@>, box 1u + <@@ 9L %? Nullable<_> 4L @@>, box 1L + <@@ 9uL %? Nullable<_> 4uL @@>, box 1uL + <@@ 9.0f %? Nullable<_> 4.0f @@>, box 1f + <@@ 9.0 %? Nullable<_> 4.0 @@>, box 1. + <@@ 9m %? Nullable<_> 4m @@>, box 1m + <@@ 9m %? Nullable<_> 4m @@>, box 1m + <@@ 9I %? Nullable<_> 4I @@>, box 1I + <@@ LanguagePrimitives.GenericOne %? Nullable<_> LanguagePrimitives.GenericOne @@>, box 0n + <@@ LanguagePrimitives.GenericOne %? Nullable<_> LanguagePrimitives.GenericOne @@>, box 0un + + <@@ Nullable<_> 9y ?%? Nullable<_> 4y @@>, box 1y + <@@ Nullable<_> 9uy ?%? Nullable<_> 4uy @@>, box 1uy + <@@ Nullable<_> 9s ?%? Nullable<_> 4s @@>, box 1s + <@@ Nullable<_> 9us ?%? Nullable<_> 4us @@>, box 1us + <@@ Nullable<_> 9 ?%? Nullable<_> 4 @@>, box 1 + <@@ Nullable<_> 9u ?%? Nullable<_> 4u @@>, box 1u + <@@ Nullable<_> 9L ?%? Nullable<_> 4L @@>, box 1L + <@@ Nullable<_> 9uL ?%? Nullable<_> 4uL @@>, box 1uL + <@@ Nullable<_> 9.0f ?%? Nullable<_> 4.0f @@>, box 1f + <@@ Nullable<_> 9.0 ?%? Nullable<_> 4.0 @@>, box 1. + <@@ Nullable<_> 9m ?%? Nullable<_> 4m @@>, box 1m + <@@ Nullable<_> 9m ?%? Nullable<_> 4m @@>, box 1m + <@@ Nullable<_> 9I ?%? Nullable<_> 4I @@>, box 1I + <@@ Nullable<_> LanguagePrimitives.GenericOne ?%? Nullable<_> LanguagePrimitives.GenericOne @@>, box 0n + <@@ Nullable<_> LanguagePrimitives.GenericOne ?%? Nullable<_> LanguagePrimitives.GenericOne @@>, box 0un + + <@@ NonStructuralComparison.(=) 3y 3y @@>, box true + <@@ NonStructuralComparison.(=) 3uy 3uy @@>, box true + <@@ NonStructuralComparison.(=) 3s 3s @@>, box true + <@@ NonStructuralComparison.(=) 3us 3us @@>, box true + <@@ NonStructuralComparison.(=) 3 3 @@>, box true + <@@ NonStructuralComparison.(=) 3u 3u @@>, box true + <@@ NonStructuralComparison.(=) 3L 3L @@>, box true + <@@ NonStructuralComparison.(=) 3UL 3UL @@>, box true + <@@ NonStructuralComparison.(=) '3' '3' @@>, box true + <@@ NonStructuralComparison.(=) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box true + <@@ NonStructuralComparison.(=) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box true + <@@ NonStructuralComparison.(=) 3f 3f @@>, box true + <@@ NonStructuralComparison.(=) 3. 3. @@>, box true + <@@ NonStructuralComparison.(=) 3m 3m @@>, box true + <@@ NonStructuralComparison.(=) 3m 3m @@>, box true + <@@ NonStructuralComparison.(=) 3I 3I @@>, box true + <@@ NonStructuralComparison.(=) "3" "3" @@>, box true + + <@@ NonStructuralComparison.(<>) 3y 3y @@>, box false + <@@ NonStructuralComparison.(<>) 3uy 3uy @@>, box false + <@@ NonStructuralComparison.(<>) 3s 3s @@>, box false + <@@ NonStructuralComparison.(<>) 3us 3us @@>, box false + <@@ NonStructuralComparison.(<>) 3 3 @@>, box false + <@@ NonStructuralComparison.(<>) 3u 3u @@>, box false + <@@ NonStructuralComparison.(<>) 3L 3L @@>, box false + <@@ NonStructuralComparison.(<>) 3UL 3UL @@>, box false + <@@ NonStructuralComparison.(<>) '3' '3' @@>, box false + <@@ NonStructuralComparison.(<>) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box false + <@@ NonStructuralComparison.(<>) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box false + <@@ NonStructuralComparison.(<>) 3f 3f @@>, box false + <@@ NonStructuralComparison.(<>) 3. 3. @@>, box false + <@@ NonStructuralComparison.(<>) 3m 3m @@>, box false + <@@ NonStructuralComparison.(<>) 3m 3m @@>, box false + <@@ NonStructuralComparison.(<>) 3I 3I @@>, box false + <@@ NonStructuralComparison.(<>) "3" "3" @@>, box false + + <@@ NonStructuralComparison.(<=) 3y 3y @@>, box true + <@@ NonStructuralComparison.(<=) 3uy 3uy @@>, box true + <@@ NonStructuralComparison.(<=) 3s 3s @@>, box true + <@@ NonStructuralComparison.(<=) 3us 3us @@>, box true + <@@ NonStructuralComparison.(<=) 3 3 @@>, box true + <@@ NonStructuralComparison.(<=) 3u 3u @@>, box true + <@@ NonStructuralComparison.(<=) 3L 3L @@>, box true + <@@ NonStructuralComparison.(<=) 3UL 3UL @@>, box true + <@@ NonStructuralComparison.(<=) '3' '3' @@>, box true + <@@ NonStructuralComparison.(<=) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box true + <@@ NonStructuralComparison.(<=) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box true + <@@ NonStructuralComparison.(<=) 3f 3f @@>, box true + <@@ NonStructuralComparison.(<=) 3. 3. @@>, box true + <@@ NonStructuralComparison.(<=) 3m 3m @@>, box true + <@@ NonStructuralComparison.(<=) 3m 3m @@>, box true + <@@ NonStructuralComparison.(<=) 3I 3I @@>, box true + <@@ NonStructuralComparison.(<=) "3" "3" @@>, box true + + <@@ NonStructuralComparison.(<) 3y 3y @@>, box false + <@@ NonStructuralComparison.(<) 3uy 3uy @@>, box false + <@@ NonStructuralComparison.(<) 3s 3s @@>, box false + <@@ NonStructuralComparison.(<) 3us 3us @@>, box false + <@@ NonStructuralComparison.(<) 3 3 @@>, box false + <@@ NonStructuralComparison.(<) 3u 3u @@>, box false + <@@ NonStructuralComparison.(<) 3L 3L @@>, box false + <@@ NonStructuralComparison.(<) 3UL 3UL @@>, box false + <@@ NonStructuralComparison.(<) '3' '3' @@>, box false + <@@ NonStructuralComparison.(<) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box false + <@@ NonStructuralComparison.(<) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box false + <@@ NonStructuralComparison.(<) 3f 3f @@>, box false + <@@ NonStructuralComparison.(<) 3. 3. @@>, box false + <@@ NonStructuralComparison.(<) 3m 3m @@>, box false + <@@ NonStructuralComparison.(<) 3m 3m @@>, box false + <@@ NonStructuralComparison.(<) 3I 3I @@>, box false + <@@ NonStructuralComparison.(<) "3" "3" @@>, box false + + <@@ NonStructuralComparison.(>=) 3y 3y @@>, box true + <@@ NonStructuralComparison.(>=) 3uy 3uy @@>, box true + <@@ NonStructuralComparison.(>=) 3s 3s @@>, box true + <@@ NonStructuralComparison.(>=) 3us 3us @@>, box true + <@@ NonStructuralComparison.(>=) 3 3 @@>, box true + <@@ NonStructuralComparison.(>=) 3u 3u @@>, box true + <@@ NonStructuralComparison.(>=) 3L 3L @@>, box true + <@@ NonStructuralComparison.(>=) 3UL 3UL @@>, box true + <@@ NonStructuralComparison.(>=) '3' '3' @@>, box true + <@@ NonStructuralComparison.(>=) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box true + <@@ NonStructuralComparison.(>=) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box true + <@@ NonStructuralComparison.(>=) 3f 3f @@>, box true + <@@ NonStructuralComparison.(>=) 3. 3. @@>, box true + <@@ NonStructuralComparison.(>=) 3m 3m @@>, box true + <@@ NonStructuralComparison.(>=) 3m 3m @@>, box true + <@@ NonStructuralComparison.(>=) 3I 3I @@>, box true + <@@ NonStructuralComparison.(>=) "3" "3" @@>, box true + + <@@ NonStructuralComparison.(>) 3y 3y @@>, box false + <@@ NonStructuralComparison.(>) 3uy 3uy @@>, box false + <@@ NonStructuralComparison.(>) 3s 3s @@>, box false + <@@ NonStructuralComparison.(>) 3us 3us @@>, box false + <@@ NonStructuralComparison.(>) 3 3 @@>, box false + <@@ NonStructuralComparison.(>) 3u 3u @@>, box false + <@@ NonStructuralComparison.(>) 3L 3L @@>, box false + <@@ NonStructuralComparison.(>) 3UL 3UL @@>, box false + <@@ NonStructuralComparison.(>) '3' '3' @@>, box false + <@@ NonStructuralComparison.(>) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box false + <@@ NonStructuralComparison.(>) LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box false + <@@ NonStructuralComparison.(>) 3f 3f @@>, box false + <@@ NonStructuralComparison.(>) 3. 3. @@>, box false + <@@ NonStructuralComparison.(>) 3m 3m @@>, box false + <@@ NonStructuralComparison.(>) 3m 3m @@>, box false + <@@ NonStructuralComparison.(>) 3I 3I @@>, box false + <@@ NonStructuralComparison.(>) "3" "3" @@>, box false + |] + + tests |> Array.map (fun (test, eval) -> + begin + printfn "--> Checking we can evaluate %A" test + let res = FSharp.Linq.RuntimeHelpers.LeafExpressionConverter.EvaluateQuotation test + let b = res = eval + if b then printfn "--- Success, it is %A which is equal to %A" res eval + else printfn "!!! FAILURE, it is %A which is not equal to %A" res eval + b + end + && match test with - | CallWithWitnesses(None, minfo1, minfo2, witnessArgs, args) -> - minfo1.IsStatic && - minfo2.IsStatic && - minfo2.Name = minfo1.Name + "$W" && + | CallWithWitnesses(None, minfo1, minfo2, witnessArgs, args) -> + minfo1.IsStatic && + minfo2.IsStatic && + minfo2.Name = minfo1.Name + "$W" && (* - (printfn "checking minfo2.GetParameters().Length = %d..." (minfo2.GetParameters().Length); true) && - minfo2.GetParameters().Length = 3 && - (printfn "checking witnessArgs.Length..."; true) && - witnessArgs.Length = 1 && - (printfn "checking args.Length..."; true) && - args.Length = 2 && - (printfn "witnessArgs..."; true) && - (match witnessArgs with [ Lambda _ ] -> true | _ -> false) && - (printfn "args..."; true) && - (match args with [ _; _ ] -> true | _ -> false) - *) - true - | _ -> false)) + (printfn "checking minfo2.GetParameters().Length = %d..." (minfo2.GetParameters().Length); true) && + minfo2.GetParameters().Length = 3 && + (printfn "checking witnessArgs.Length..."; true) && + witnessArgs.Length = 1 && + (printfn "checking args.Length..."; true) && + args.Length = 2 && + (printfn "witnessArgs..."; true) && + (match witnessArgs with [ Lambda _ ] -> true | _ -> false) && + (printfn "args..."; true) && + (match args with [ _; _ ] -> true | _ -> false) + *) + (printfn "<-- Successfully checked with Quotations.Patterns.(|CallWithWitnesses|_|)"; true) + || (printfn "<-- FAILURE, failed after matching with Quotations.Patterns.(|CallWithWitnesses|_|)"; true) + | _ -> + printfn " Array.forall id) // Don't short circuit on a failed test + + test "check non-CallWithWitnesses operators" + (let tests = [| + <@@ LanguagePrimitives.PhysicalEquality [|3|] [|3|] @@>, box false + <@@ let x = [|3|] in LanguagePrimitives.PhysicalEquality x x @@>, box true + <@@ LanguagePrimitives.PhysicalEquality (seq { 3 }) (seq { 3 }) @@>, box false + <@@ let x = seq { 3 } in LanguagePrimitives.PhysicalEquality x x @@>, box true + <@@ LanguagePrimitives.PhysicalEquality (obj()) (obj()) @@>, box false + <@@ let x = obj() in LanguagePrimitives.PhysicalEquality x x @@>, box true + + <@@ 3y = 3y @@>, box true + <@@ 3uy = 3uy @@>, box true + <@@ 3s = 3s @@>, box true + <@@ 3us = 3us @@>, box true + <@@ 3 = 3 @@>, box true + <@@ 3u = 3u @@>, box true + <@@ 3L = 3L @@>, box true + <@@ 3UL = 3UL @@>, box true + <@@ '3' = '3' @@>, box true + <@@ LanguagePrimitives.GenericOne = LanguagePrimitives.GenericOne @@>, box true + <@@ LanguagePrimitives.GenericOne = LanguagePrimitives.GenericOne @@>, box true + <@@ 3f = 3f @@>, box true + <@@ 3. = 3. @@>, box true + <@@ 3m = 3m @@>, box true + <@@ 3m = 3m @@>, box true + <@@ 3I = 3I @@>, box true + <@@ "3" = "3" @@>, box true + <@@ [3] = [3] @@>, box true + <@@ [|3|] = [|3|] @@>, box true + <@@ seq { 3 } = seq { 3 } @@>, box false // Reference equality + <@@ let x = seq { 3 } in x = x @@>, box true + <@@ obj() = obj() @@>, box false + <@@ let x = obj() in x = x @@>, box true + + <@@ 3y <> 3y @@>, box false + <@@ 3uy <> 3uy @@>, box false + <@@ 3s <> 3s @@>, box false + <@@ 3us <> 3us @@>, box false + <@@ 3 <> 3 @@>, box false + <@@ 3u <> 3u @@>, box false + <@@ 3L <> 3L @@>, box false + <@@ 3UL <> 3UL @@>, box false + <@@ '3' <> '3' @@>, box false + <@@ LanguagePrimitives.GenericOne <> LanguagePrimitives.GenericOne @@>, box false + <@@ LanguagePrimitives.GenericOne <> LanguagePrimitives.GenericOne @@>, box false + <@@ 3f <> 3f @@>, box false + <@@ 3. <> 3. @@>, box false + <@@ 3m <> 3m @@>, box false + <@@ 3m <> 3m @@>, box false + <@@ 3I <> 3I @@>, box false + <@@ "3" <> "3" @@>, box false + <@@ [3] <> [3] @@>, box false + <@@ [|3|] <> [|3|] @@>, box false + <@@ seq { 3 } <> seq { 3 } @@>, box true // Reference equality + <@@ let x = seq { 3 } in x <> x @@>, box false + <@@ obj() <> obj() @@>, box true + <@@ let x = obj() in x <> x @@>, box false + + <@@ 3y <= 3y @@>, box true + <@@ 3uy <= 3uy @@>, box true + <@@ 3s <= 3s @@>, box true + <@@ 3us <= 3us @@>, box true + <@@ 3 <= 3 @@>, box true + <@@ 3u <= 3u @@>, box true + <@@ 3L <= 3L @@>, box true + <@@ 3UL <= 3UL @@>, box true + <@@ '3' <= '3' @@>, box true + <@@ LanguagePrimitives.GenericOne <= LanguagePrimitives.GenericOne @@>, box true + <@@ LanguagePrimitives.GenericOne <= LanguagePrimitives.GenericOne @@>, box true + <@@ 3f <= 3f @@>, box true + <@@ 3. <= 3. @@>, box true + <@@ 3m <= 3m @@>, box true + <@@ 3m <= 3m @@>, box true + <@@ 3I <= 3I @@>, box true + <@@ "3" <= "3" @@>, box true + <@@ [3] <= [3] @@>, box true + <@@ [|3|] <= [|3|] @@>, box true + + <@@ 3y < 3y @@>, box false + <@@ 3uy < 3uy @@>, box false + <@@ 3s < 3s @@>, box false + <@@ 3us < 3us @@>, box false + <@@ 3 < 3 @@>, box false + <@@ 3u < 3u @@>, box false + <@@ 3L < 3L @@>, box false + <@@ 3UL < 3UL @@>, box false + <@@ '3' < '3' @@>, box false + <@@ LanguagePrimitives.GenericOne < LanguagePrimitives.GenericOne @@>, box false + <@@ LanguagePrimitives.GenericOne < LanguagePrimitives.GenericOne @@>, box false + <@@ 3f < 3f @@>, box false + <@@ 3. < 3. @@>, box false + <@@ 3m < 3m @@>, box false + <@@ 3m < 3m @@>, box false + <@@ 3I < 3I @@>, box false + <@@ "3" < "3" @@>, box false + <@@ [3] < [3] @@>, box false + <@@ [|3|] < [|3|] @@>, box false + + <@@ 3y >= 3y @@>, box true + <@@ 3uy >= 3uy @@>, box true + <@@ 3s >= 3s @@>, box true + <@@ 3us >= 3us @@>, box true + <@@ 3 >= 3 @@>, box true + <@@ 3u >= 3u @@>, box true + <@@ 3L >= 3L @@>, box true + <@@ 3UL >= 3UL @@>, box true + <@@ '3' >= '3' @@>, box true + <@@ LanguagePrimitives.GenericOne >= LanguagePrimitives.GenericOne @@>, box true + <@@ LanguagePrimitives.GenericOne >= LanguagePrimitives.GenericOne @@>, box true + <@@ 3f >= 3f @@>, box true + <@@ 3. >= 3. @@>, box true + <@@ 3m >= 3m @@>, box true + <@@ 3m >= 3m @@>, box true + <@@ 3I >= 3I @@>, box true + <@@ "3" >= "3" @@>, box true + <@@ [3] >= [3] @@>, box true + <@@ [|3|] >= [|3|] @@>, box true + + <@@ 3y > 3y @@>, box false + <@@ 3uy > 3uy @@>, box false + <@@ 3s > 3s @@>, box false + <@@ 3us > 3us @@>, box false + <@@ 3 > 3 @@>, box false + <@@ 3u > 3u @@>, box false + <@@ 3L > 3L @@>, box false + <@@ 3UL > 3UL @@>, box false + <@@ '3' > '3' @@>, box false + <@@ LanguagePrimitives.GenericOne > LanguagePrimitives.GenericOne @@>, box false + <@@ LanguagePrimitives.GenericOne > LanguagePrimitives.GenericOne @@>, box false + <@@ 3f > 3f @@>, box false + <@@ 3. > 3. @@>, box false + <@@ 3m > 3m @@>, box false + <@@ 3m > 3m @@>, box false + <@@ 3I > 3I @@>, box false + <@@ "3" > "3" @@>, box false + <@@ [3] > [3] @@>, box false + <@@ [|3|] > [|3|] @@>, box false + + <@@ Nullable<_> 1y ?= 1y @@>, box true + <@@ Nullable<_> 1uy ?= 1uy @@>, box true + <@@ Nullable<_> 1s ?= 1s @@>, box true + <@@ Nullable<_> 1us ?= 1us @@>, box true + <@@ Nullable<_> 1 ?= 1 @@>, box true + <@@ Nullable<_> 1u ?= 1u @@>, box true + <@@ Nullable<_> 1L ?= 1L @@>, box true + <@@ Nullable<_> 1uL ?= 1uL @@>, box true + <@@ Nullable<_> 1.0f ?= 1.0f @@>, box true + <@@ Nullable<_> 1.0 ?= 1.0 @@>, box true + <@@ Nullable<_> 1m ?= 1m @@>, box true + <@@ Nullable<_> 1m ?= 1m @@>, box true + <@@ Nullable<_> 1I ?= 1I @@>, box true + <@@ Nullable<_> '1' ?= '1' @@>, box true + <@@ Nullable<_> LanguagePrimitives.GenericOne ?= LanguagePrimitives.GenericOne @@>, box true + <@@ Nullable<_> LanguagePrimitives.GenericOne ?= LanguagePrimitives.GenericOne @@>, box true + + <@@ 1y =? Nullable<_> 1y @@>, box true + <@@ 1uy =? Nullable<_> 1uy @@>, box true + <@@ 1s =? Nullable<_> 1s @@>, box true + <@@ 1us =? Nullable<_> 1us @@>, box true + <@@ 1 =? Nullable<_> 1 @@>, box true + <@@ 1u =? Nullable<_> 1u @@>, box true + <@@ 1L =? Nullable<_> 1L @@>, box true + <@@ 1uL =? Nullable<_> 1uL @@>, box true + <@@ 1.0f =? Nullable<_> 1.0f @@>, box true + <@@ 1.0 =? Nullable<_> 1.0 @@>, box true + <@@ 1m =? Nullable<_> 1m @@>, box true + <@@ 1m =? Nullable<_> 1m @@>, box true + <@@ 1I =? Nullable<_> 1I @@>, box true + <@@ '1' =? Nullable<_> '1' @@>, box true + <@@ LanguagePrimitives.GenericOne =? Nullable<_> LanguagePrimitives.GenericOne @@>, box true + <@@ LanguagePrimitives.GenericOne =? Nullable<_> LanguagePrimitives.GenericOne @@>, box true + + <@@ Nullable<_> 1y ?=? Nullable<_> 1y @@>, box true + <@@ Nullable<_> 1uy ?=? Nullable<_> 1uy @@>, box true + <@@ Nullable<_> 1s ?=? Nullable<_> 1s @@>, box true + <@@ Nullable<_> 1us ?=? Nullable<_> 1us @@>, box true + <@@ Nullable<_> 1 ?=? Nullable<_> 1 @@>, box true + <@@ Nullable<_> 1u ?=? Nullable<_> 1u @@>, box true + <@@ Nullable<_> 1L ?=? Nullable<_> 1L @@>, box true + <@@ Nullable<_> 1uL ?=? Nullable<_> 1uL @@>, box true + <@@ Nullable<_> 1.0f ?=? Nullable<_> 1.0f @@>, box true + <@@ Nullable<_> 1.0 ?=? Nullable<_> 1.0 @@>, box true + <@@ Nullable<_> 1m ?=? Nullable<_> 1m @@>, box true + <@@ Nullable<_> 1m ?=? Nullable<_> 1m @@>, box true + <@@ Nullable<_> 1I ?=? Nullable<_> 1I @@>, box true + <@@ Nullable<_> '1' ?=? Nullable<_> '1' @@>, box true + <@@ Nullable<_> LanguagePrimitives.GenericOne ?=? Nullable<_> LanguagePrimitives.GenericOne @@>, box true + <@@ Nullable<_> LanguagePrimitives.GenericOne ?=? Nullable<_> LanguagePrimitives.GenericOne @@>, box true + + <@@ Nullable<_> 3y ?<> 3y @@>, box false + <@@ Nullable<_> 3uy ?<> 3uy @@>, box false + <@@ Nullable<_> 3s ?<> 3s @@>, box false + <@@ Nullable<_> 3us ?<> 3us @@>, box false + <@@ Nullable<_> 3 ?<> 3 @@>, box false + <@@ Nullable<_> 3u ?<> 3u @@>, box false + <@@ Nullable<_> 3L ?<> 3L @@>, box false + <@@ Nullable<_> 3UL ?<> 3UL @@>, box false + <@@ Nullable<_> '3' ?<> '3' @@>, box false + <@@ Nullable<_> LanguagePrimitives.GenericOne ?<> LanguagePrimitives.GenericOne @@>, box false + <@@ Nullable<_> LanguagePrimitives.GenericOne ?<> LanguagePrimitives.GenericOne @@>, box false + <@@ Nullable<_> 3f ?<> 3f @@>, box false + <@@ Nullable<_> 3. ?<> 3. @@>, box false + <@@ Nullable<_> 3m ?<> 3m @@>, box false + <@@ Nullable<_> 3m ?<> 3m @@>, box false + <@@ Nullable<_> 3I ?<> 3I @@>, box false + + <@@ 3y <>? Nullable<_> 3y @@>, box false + <@@ 3uy <>? Nullable<_> 3uy @@>, box false + <@@ 3s <>? Nullable<_> 3s @@>, box false + <@@ 3us <>? Nullable<_> 3us @@>, box false + <@@ 3 <>? Nullable<_> 3 @@>, box false + <@@ 3u <>? Nullable<_> 3u @@>, box false + <@@ 3L <>? Nullable<_> 3L @@>, box false + <@@ 3UL <>? Nullable<_> 3UL @@>, box false + <@@ '3' <>? Nullable<_> '3' @@>, box false + <@@ LanguagePrimitives.GenericOne <>? Nullable<_> LanguagePrimitives.GenericOne @@>, box false + <@@ LanguagePrimitives.GenericOne <>? Nullable<_> LanguagePrimitives.GenericOne @@>, box false + <@@ 3f <>? Nullable<_> 3f @@>, box false + <@@ 3. <>? Nullable<_> 3. @@>, box false + <@@ 3m <>? Nullable<_> 3m @@>, box false + <@@ 3m <>? Nullable<_> 3m @@>, box false + <@@ 3I <>? Nullable<_> 3I @@>, box false + + <@@ Nullable<_> 3y ?<>? Nullable<_> 3y @@>, box false + <@@ Nullable<_> 3uy ?<>? Nullable<_> 3uy @@>, box false + <@@ Nullable<_> 3s ?<>? Nullable<_> 3s @@>, box false + <@@ Nullable<_> 3us ?<>? Nullable<_> 3us @@>, box false + <@@ Nullable<_> 3 ?<>? Nullable<_> 3 @@>, box false + <@@ Nullable<_> 3u ?<>? Nullable<_> 3u @@>, box false + <@@ Nullable<_> 3L ?<>? Nullable<_> 3L @@>, box false + <@@ Nullable<_> 3UL ?<>? Nullable<_> 3UL @@>, box false + <@@ Nullable<_> '3' ?<>? Nullable<_> '3' @@>, box false + <@@ Nullable<_> LanguagePrimitives.GenericOne ?<>? Nullable<_> LanguagePrimitives.GenericOne @@>, box false + <@@ Nullable<_> LanguagePrimitives.GenericOne ?<>? Nullable<_> LanguagePrimitives.GenericOne @@>, box false + <@@ Nullable<_> 3f ?<>? Nullable<_> 3f @@>, box false + <@@ Nullable<_> 3. ?<>? Nullable<_> 3. @@>, box false + <@@ Nullable<_> 3m ?<>? Nullable<_> 3m @@>, box false + <@@ Nullable<_> 3m ?<>? Nullable<_> 3m @@>, box false + <@@ Nullable<_> 3I ?<>? Nullable<_> 3I @@>, box false + + <@@ Nullable<_> 3y ?<= 3y @@>, box true + <@@ Nullable<_> 3uy ?<= 3uy @@>, box true + <@@ Nullable<_> 3s ?<= 3s @@>, box true + <@@ Nullable<_> 3us ?<= 3us @@>, box true + <@@ Nullable<_> 3 ?<= 3 @@>, box true + <@@ Nullable<_> 3u ?<= 3u @@>, box true + <@@ Nullable<_> 3L ?<= 3L @@>, box true + <@@ Nullable<_> 3UL ?<= 3UL @@>, box true + <@@ Nullable<_> '3' ?<= '3' @@>, box true + <@@ Nullable<_> LanguagePrimitives.GenericOne ?<= LanguagePrimitives.GenericOne @@>, box true + <@@ Nullable<_> LanguagePrimitives.GenericOne ?<= LanguagePrimitives.GenericOne @@>, box true + <@@ Nullable<_> 3f ?<= 3f @@>, box true + <@@ Nullable<_> 3. ?<= 3. @@>, box true + <@@ Nullable<_> 3m ?<= 3m @@>, box true + <@@ Nullable<_> 3m ?<= 3m @@>, box true + <@@ Nullable<_> 3I ?<= 3I @@>, box true + + <@@ 3y <=? Nullable<_> 3y @@>, box true + <@@ 3uy <=? Nullable<_> 3uy @@>, box true + <@@ 3s <=? Nullable<_> 3s @@>, box true + <@@ 3us <=? Nullable<_> 3us @@>, box true + <@@ 3 <=? Nullable<_> 3 @@>, box true + <@@ 3u <=? Nullable<_> 3u @@>, box true + <@@ 3L <=? Nullable<_> 3L @@>, box true + <@@ 3UL <=? Nullable<_> 3UL @@>, box true + <@@ '3' <=? Nullable<_> '3' @@>, box true + <@@ LanguagePrimitives.GenericOne <=? Nullable<_> LanguagePrimitives.GenericOne @@>, box true + <@@ LanguagePrimitives.GenericOne <=? Nullable<_> LanguagePrimitives.GenericOne @@>, box true + <@@ 3f <=? Nullable<_> 3f @@>, box true + <@@ 3. <=? Nullable<_> 3. @@>, box true + <@@ 3m <=? Nullable<_> 3m @@>, box true + <@@ 3m <=? Nullable<_> 3m @@>, box true + <@@ 3I <=? Nullable<_> 3I @@>, box true + + <@@ Nullable<_> 3y ?<=? Nullable<_> 3y @@>, box true + <@@ Nullable<_> 3uy ?<=? Nullable<_> 3uy @@>, box true + <@@ Nullable<_> 3s ?<=? Nullable<_> 3s @@>, box true + <@@ Nullable<_> 3us ?<=? Nullable<_> 3us @@>, box true + <@@ Nullable<_> 3 ?<=? Nullable<_> 3 @@>, box true + <@@ Nullable<_> 3u ?<=? Nullable<_> 3u @@>, box true + <@@ Nullable<_> 3L ?<=? Nullable<_> 3L @@>, box true + <@@ Nullable<_> 3UL ?<=? Nullable<_> 3UL @@>, box true + <@@ Nullable<_> '3' ?<=? Nullable<_> '3' @@>, box true + <@@ Nullable<_> LanguagePrimitives.GenericOne ?<=? Nullable<_> LanguagePrimitives.GenericOne @@>, box true + <@@ Nullable<_> LanguagePrimitives.GenericOne ?<=? Nullable<_> LanguagePrimitives.GenericOne @@>, box true + <@@ Nullable<_> 3f ?<=? Nullable<_> 3f @@>, box true + <@@ Nullable<_> 3. ?<=? Nullable<_> 3. @@>, box true + <@@ Nullable<_> 3m ?<=? Nullable<_> 3m @@>, box true + <@@ Nullable<_> 3m ?<=? Nullable<_> 3m @@>, box true + <@@ Nullable<_> 3I ?<=? Nullable<_> 3I @@>, box true + + <@@ Nullable<_> 3y ?< 3y @@>, box false + <@@ Nullable<_> 3uy ?< 3uy @@>, box false + <@@ Nullable<_> 3s ?< 3s @@>, box false + <@@ Nullable<_> 3us ?< 3us @@>, box false + <@@ Nullable<_> 3 ?< 3 @@>, box false + <@@ Nullable<_> 3u ?< 3u @@>, box false + <@@ Nullable<_> 3L ?< 3L @@>, box false + <@@ Nullable<_> 3UL ?< 3UL @@>, box false + <@@ Nullable<_> '3' ?< '3' @@>, box false + <@@ Nullable<_> LanguagePrimitives.GenericOne ?< LanguagePrimitives.GenericOne @@>, box false + <@@ Nullable<_> LanguagePrimitives.GenericOne ?< LanguagePrimitives.GenericOne @@>, box false + <@@ Nullable<_> 3f ?< 3f @@>, box false + <@@ Nullable<_> 3. ?< 3. @@>, box false + <@@ Nullable<_> 3m ?< 3m @@>, box false + <@@ Nullable<_> 3m ?< 3m @@>, box false + <@@ Nullable<_> 3I ?< 3I @@>, box false + + <@@ 3y 3y @@>, box false + <@@ 3uy 3uy @@>, box false + <@@ 3s 3s @@>, box false + <@@ 3us 3us @@>, box false + <@@ 3 3 @@>, box false + <@@ 3u 3u @@>, box false + <@@ 3L 3L @@>, box false + <@@ 3UL 3UL @@>, box false + <@@ '3' '3' @@>, box false + <@@ LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box false + <@@ LanguagePrimitives.GenericOne LanguagePrimitives.GenericOne @@>, box false + <@@ 3f 3f @@>, box false + <@@ 3. 3. @@>, box false + <@@ 3m 3m @@>, box false + <@@ 3m 3m @@>, box false + <@@ 3I 3I @@>, box false + + <@@ Nullable<_> 3y ? 3y @@>, box false + <@@ Nullable<_> 3uy ? 3uy @@>, box false + <@@ Nullable<_> 3s ? 3s @@>, box false + <@@ Nullable<_> 3us ? 3us @@>, box false + <@@ Nullable<_> 3 ? 3 @@>, box false + <@@ Nullable<_> 3u ? 3u @@>, box false + <@@ Nullable<_> 3L ? 3L @@>, box false + <@@ Nullable<_> 3UL ? 3UL @@>, box false + <@@ Nullable<_> '3' ? '3' @@>, box false + <@@ Nullable<_> LanguagePrimitives.GenericOne ? LanguagePrimitives.GenericOne @@>, box false + <@@ Nullable<_> LanguagePrimitives.GenericOne ? LanguagePrimitives.GenericOne @@>, box false + <@@ Nullable<_> 3f ? 3f @@>, box false + <@@ Nullable<_> 3. ? 3. @@>, box false + <@@ Nullable<_> 3m ? 3m @@>, box false + <@@ Nullable<_> 3m ? 3m @@>, box false + <@@ Nullable<_> 3I ? 3I @@>, box false + + <@@ Nullable<_> 3y ?>= 3y @@>, box true + <@@ Nullable<_> 3uy ?>= 3uy @@>, box true + <@@ Nullable<_> 3s ?>= 3s @@>, box true + <@@ Nullable<_> 3us ?>= 3us @@>, box true + <@@ Nullable<_> 3 ?>= 3 @@>, box true + <@@ Nullable<_> 3u ?>= 3u @@>, box true + <@@ Nullable<_> 3L ?>= 3L @@>, box true + <@@ Nullable<_> 3UL ?>= 3UL @@>, box true + <@@ Nullable<_> '3' ?>= '3' @@>, box true + <@@ Nullable<_> LanguagePrimitives.GenericOne ?>= LanguagePrimitives.GenericOne @@>, box true + <@@ Nullable<_> LanguagePrimitives.GenericOne ?>= LanguagePrimitives.GenericOne @@>, box true + <@@ Nullable<_> 3f ?>= 3f @@>, box true + <@@ Nullable<_> 3. ?>= 3. @@>, box true + <@@ Nullable<_> 3m ?>= 3m @@>, box true + <@@ Nullable<_> 3m ?>= 3m @@>, box true + <@@ Nullable<_> 3I ?>= 3I @@>, box true + + <@@ 3y >=? Nullable<_> 3y @@>, box true + <@@ 3uy >=? Nullable<_> 3uy @@>, box true + <@@ 3s >=? Nullable<_> 3s @@>, box true + <@@ 3us >=? Nullable<_> 3us @@>, box true + <@@ 3 >=? Nullable<_> 3 @@>, box true + <@@ 3u >=? Nullable<_> 3u @@>, box true + <@@ 3L >=? Nullable<_> 3L @@>, box true + <@@ 3UL >=? Nullable<_> 3UL @@>, box true + <@@ '3' >=? Nullable<_> '3' @@>, box true + <@@ LanguagePrimitives.GenericOne >=? Nullable<_> LanguagePrimitives.GenericOne @@>, box true + <@@ LanguagePrimitives.GenericOne >=? Nullable<_> LanguagePrimitives.GenericOne @@>, box true + <@@ 3f >=? Nullable<_> 3f @@>, box true + <@@ 3. >=? Nullable<_> 3. @@>, box true + <@@ 3m >=? Nullable<_> 3m @@>, box true + <@@ 3m >=? Nullable<_> 3m @@>, box true + <@@ 3I >=? Nullable<_> 3I @@>, box true + + <@@ Nullable<_> 3y ?>=? Nullable<_> 3y @@>, box true + <@@ Nullable<_> 3uy ?>=? Nullable<_> 3uy @@>, box true + <@@ Nullable<_> 3s ?>=? Nullable<_> 3s @@>, box true + <@@ Nullable<_> 3us ?>=? Nullable<_> 3us @@>, box true + <@@ Nullable<_> 3 ?>=? Nullable<_> 3 @@>, box true + <@@ Nullable<_> 3u ?>=? Nullable<_> 3u @@>, box true + <@@ Nullable<_> 3L ?>=? Nullable<_> 3L @@>, box true + <@@ Nullable<_> 3UL ?>=? Nullable<_> 3UL @@>, box true + <@@ Nullable<_> '3' ?>=? Nullable<_> '3' @@>, box true + <@@ Nullable<_> LanguagePrimitives.GenericOne ?>=? Nullable<_> LanguagePrimitives.GenericOne @@>, box true + <@@ Nullable<_> LanguagePrimitives.GenericOne ?>=? Nullable<_> LanguagePrimitives.GenericOne @@>, box true + <@@ Nullable<_> 3f ?>=? Nullable<_> 3f @@>, box true + <@@ Nullable<_> 3. ?>=? Nullable<_> 3. @@>, box true + <@@ Nullable<_> 3m ?>=? Nullable<_> 3m @@>, box true + <@@ Nullable<_> 3m ?>=? Nullable<_> 3m @@>, box true + <@@ Nullable<_> 3I ?>=? Nullable<_> 3I @@>, box true + + <@@ Nullable<_> 3y ?> 3y @@>, box false + <@@ Nullable<_> 3uy ?> 3uy @@>, box false + <@@ Nullable<_> 3s ?> 3s @@>, box false + <@@ Nullable<_> 3us ?> 3us @@>, box false + <@@ Nullable<_> 3 ?> 3 @@>, box false + <@@ Nullable<_> 3u ?> 3u @@>, box false + <@@ Nullable<_> 3L ?> 3L @@>, box false + <@@ Nullable<_> 3UL ?> 3UL @@>, box false + <@@ Nullable<_> '3' ?> '3' @@>, box false + <@@ Nullable<_> LanguagePrimitives.GenericOne ?> LanguagePrimitives.GenericOne @@>, box false + <@@ Nullable<_> LanguagePrimitives.GenericOne ?> LanguagePrimitives.GenericOne @@>, box false + <@@ Nullable<_> 3f ?> 3f @@>, box false + <@@ Nullable<_> 3. ?> 3. @@>, box false + <@@ Nullable<_> 3m ?> 3m @@>, box false + <@@ Nullable<_> 3m ?> 3m @@>, box false + <@@ Nullable<_> 3I ?> 3I @@>, box false + + <@@ 3y >? Nullable<_> 3y @@>, box false + <@@ 3uy >? Nullable<_> 3uy @@>, box false + <@@ 3s >? Nullable<_> 3s @@>, box false + <@@ 3us >? Nullable<_> 3us @@>, box false + <@@ 3 >? Nullable<_> 3 @@>, box false + <@@ 3u >? Nullable<_> 3u @@>, box false + <@@ 3L >? Nullable<_> 3L @@>, box false + <@@ 3UL >? Nullable<_> 3UL @@>, box false + <@@ '3' >? Nullable<_> '3' @@>, box false + <@@ LanguagePrimitives.GenericOne >? Nullable<_> LanguagePrimitives.GenericOne @@>, box false + <@@ LanguagePrimitives.GenericOne >? Nullable<_> LanguagePrimitives.GenericOne @@>, box false + <@@ 3f >? Nullable<_> 3f @@>, box false + <@@ 3. >? Nullable<_> 3. @@>, box false + <@@ 3m >? Nullable<_> 3m @@>, box false + <@@ 3m >? Nullable<_> 3m @@>, box false + <@@ 3I >? Nullable<_> 3I @@>, box false + + <@@ Nullable<_> 3y ?>? Nullable<_> 3y @@>, box false + <@@ Nullable<_> 3uy ?>? Nullable<_> 3uy @@>, box false + <@@ Nullable<_> 3s ?>? Nullable<_> 3s @@>, box false + <@@ Nullable<_> 3us ?>? Nullable<_> 3us @@>, box false + <@@ Nullable<_> 3 ?>? Nullable<_> 3 @@>, box false + <@@ Nullable<_> 3u ?>? Nullable<_> 3u @@>, box false + <@@ Nullable<_> 3L ?>? Nullable<_> 3L @@>, box false + <@@ Nullable<_> 3UL ?>? Nullable<_> 3UL @@>, box false + <@@ Nullable<_> '3' ?>? Nullable<_> '3' @@>, box false + <@@ Nullable<_> LanguagePrimitives.GenericOne ?>? Nullable<_> LanguagePrimitives.GenericOne @@>, box false + <@@ Nullable<_> LanguagePrimitives.GenericOne ?>? Nullable<_> LanguagePrimitives.GenericOne @@>, box false + <@@ Nullable<_> 3f ?>? Nullable<_> 3f @@>, box false + <@@ Nullable<_> 3. ?>? Nullable<_> 3. @@>, box false + <@@ Nullable<_> 3m ?>? Nullable<_> 3m @@>, box false + <@@ Nullable<_> 3m ?>? Nullable<_> 3m @@>, box false + <@@ Nullable<_> 3I ?>? Nullable<_> 3I @@>, box false + |] + tests |> Array.map (fun (test, eval) -> + begin + printfn "--> Checking we can evaluate %A" test + let res = FSharp.Linq.RuntimeHelpers.LeafExpressionConverter.EvaluateQuotation test + let b = res = eval + if b then printfn "--- Success, it is %A which is equal to %A" res eval + else printfn "!!! FAILURE, it is %A which is not equal to %A" res eval + b + end + && + match test with + | CallWithWitnesses(None, minfo1, minfo2, witnessArgs, args) -> + printfn " + printfn "<-- Success, it did not match Quotations.Patterns.(|CallWithWitnesses|_|)" + true) |> Array.forall id) // Don't short circuit on a failed test module MoreWitnessTests = open System.Runtime.CompilerServices diff --git a/tests/fsharp/tools/eval/test.fsx b/tests/fsharp/tools/eval/test.fsx index a289c17794a..f6a669653ce 100644 --- a/tests/fsharp/tools/eval/test.fsx +++ b/tests/fsharp/tools/eval/test.fsx @@ -1236,6 +1236,7 @@ module EvaluationTests = check "vroievr097q" (LanguagePrimitives.AdditionDynamic 3.0 4.0) 7.0 check "vroievr097w" (LanguagePrimitives.AdditionDynamic 3.0f 4.0f) 7.0f check "vroievr097e" (LanguagePrimitives.AdditionDynamic 3.0M 4.0M) 7.0M + check "vroievr097n" (LanguagePrimitives.AdditionDynamic '3' '\004') '7' check "vroievr097r" (LanguagePrimitives.CheckedAdditionDynamic 3y 4y) 7y check "vroievr097t" (LanguagePrimitives.CheckedAdditionDynamic 3s 4s) 7s @@ -1250,6 +1251,37 @@ module EvaluationTests = check "vroievr097f" (LanguagePrimitives.CheckedAdditionDynamic 3.0 4.0) 7.0 check "vroievr097g" (LanguagePrimitives.CheckedAdditionDynamic 3.0f 4.0f) 7.0f check "vroievr097h" (LanguagePrimitives.CheckedAdditionDynamic 3.0M 4.0M) 7.0M + check "vroievr097u" (LanguagePrimitives.CheckedAdditionDynamic '3' '\004') '7' + + check "vroievr0981" (LanguagePrimitives.SubtractionDynamic 7y 4y) 3y + check "vroievr0982" (LanguagePrimitives.SubtractionDynamic 7s 4s) 3s + check "vroievr0983" (LanguagePrimitives.SubtractionDynamic 7 4) 3 + check "vroievr0984" (LanguagePrimitives.SubtractionDynamic 7L 4L) 3L + check "vroievr0985" (LanguagePrimitives.SubtractionDynamic 7n 4n) 3n + check "vroievr0986" (LanguagePrimitives.SubtractionDynamic 7uy 4uy) 3uy + check "vroievr0987" (LanguagePrimitives.SubtractionDynamic 7us 4us) 3us + check "vroievr0988" (LanguagePrimitives.SubtractionDynamic 7u 4u) 3u + check "vroievr0989" (LanguagePrimitives.SubtractionDynamic 7UL 4UL) 3UL + check "vroievr0980" (LanguagePrimitives.SubtractionDynamic 7un 4un) 3un + check "vroievr098q" (LanguagePrimitives.SubtractionDynamic 7.0 4.0) 3.0 + check "vroievr098w" (LanguagePrimitives.SubtractionDynamic 7.0f 4.0f) 3.0f + check "vroievr098e" (LanguagePrimitives.SubtractionDynamic 7.0M 4.0M) 3.0M + check "vroievr098n" (LanguagePrimitives.SubtractionDynamic '7' '\004') '3' + + check "vroievr098r" (LanguagePrimitives.CheckedSubtractionDynamic 7y 4y) 3y + check "vroievr098t" (LanguagePrimitives.CheckedSubtractionDynamic 7s 4s) 3s + check "vroievr098y" (LanguagePrimitives.CheckedSubtractionDynamic 7 4) 3 + check "vroievr098u" (LanguagePrimitives.CheckedSubtractionDynamic 7L 4L) 3L + check "vroievr098i" (LanguagePrimitives.CheckedSubtractionDynamic 7n 4n) 3n + check "vroievr098o" (LanguagePrimitives.CheckedSubtractionDynamic 7uy 4uy) 3uy + check "vroievr098p" (LanguagePrimitives.CheckedSubtractionDynamic 7us 4us) 3us + check "vroievr098a" (LanguagePrimitives.CheckedSubtractionDynamic 7u 4u) 3u + check "vroievr098s" (LanguagePrimitives.CheckedSubtractionDynamic 7UL 4UL) 3UL + check "vroievr098d" (LanguagePrimitives.CheckedSubtractionDynamic 7un 4un) 3un + check "vroievr098f" (LanguagePrimitives.CheckedSubtractionDynamic 7.0 4.0) 3.0 + check "vroievr098g" (LanguagePrimitives.CheckedSubtractionDynamic 7.0f 4.0f) 3.0f + check "vroievr098h" (LanguagePrimitives.CheckedSubtractionDynamic 7.0M 4.0M) 3.0M + check "vroievr098u" (LanguagePrimitives.CheckedSubtractionDynamic '7' '\004') '3' check "vroievr0912q" (LanguagePrimitives.MultiplyDynamic 3y 4y) 12y check "vroievr0912w" (LanguagePrimitives.MultiplyDynamic 3s 4s) 12s @@ -1265,7 +1297,6 @@ module EvaluationTests = check "vroievr0912s" (LanguagePrimitives.MultiplyDynamic 3.0f 4.0f) 12.0f check "vroievr0912d" (LanguagePrimitives.MultiplyDynamic 3.0M 4.0M) 12.0M - check "vroievr0912f" (LanguagePrimitives.CheckedMultiplyDynamic 3y 4y) 12y check "vroievr0912g" (LanguagePrimitives.CheckedMultiplyDynamic 3s 4s) 12s check "vroievr0912h" (LanguagePrimitives.CheckedMultiplyDynamic 3 4) 12 diff --git a/tests/service/ExprTests.fs b/tests/service/ExprTests.fs index 05b42f7a67d..9a1f6d6bb56 100644 --- a/tests/service/ExprTests.fs +++ b/tests/service/ExprTests.fs @@ -1184,7 +1184,7 @@ let ``Test Operator Declarations for Byte`` () = [], "let testByteAdditionChecked(e1) (e2) = Checked.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),Checked.op_Addition (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.AdditionDynamic (arg0_0,arg1_0),e1,e2)) @ (24,53--24,70)" [], "let testByteSubtractionChecked(e1) (e2) = Checked.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),Checked.op_Subtraction (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.SubtractionDynamic (arg0_0,arg1_0),e1,e2)) @ (25,53--25,70)" [], "let testByteMultiplyChecked(e1) (e2) = Checked.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),Checked.op_Multiply (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.MultiplyDynamic (arg0_0,arg1_0),e1,e2)) @ (26,53--26,70)" - [], "let testByteToByteChecked(e1) = Checked.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (29,43--29,58)" + [], "let testByteToByteChecked(e1) = e1 @ (29,56--29,58)" [], "let testByteToSByteChecked(e1) = Checked.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (30,43--30,59)" [], "let testByteToInt16Checked(e1) = Checked.ToInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (31,43--31,59)" [], "let testByteToUInt16Checked(e1) = Checked.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (32,43--32,60)" @@ -1195,7 +1195,7 @@ let ``Test Operator Declarations for Byte`` () = [], "let testByteToUInt64Checked(e1) = Checked.ToUInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (37,43--37,60)" [], "let testByteToIntPtrChecked(e1) = Checked.ToIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (38,43--38,63)" [], "let testByteToUIntPtrChecked(e1) = Checked.ToUIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (39,43--39,64)" - [], "let testByteToByteOperator(e1) = Operators.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (41,43--41,50)" + [], "let testByteToByteOperator(e1) = e1 @ (41,48--41,50)" [], "let testByteToSByteOperator(e1) = Operators.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (42,43--42,51)" [], "let testByteToInt16Operator(e1) = Operators.ToInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (43,43--43,51)" [], "let testByteToUInt16Operator(e1) = Operators.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (44,43--44,52)" @@ -1296,7 +1296,7 @@ let ``Test Operator Declarations for SByte`` () = [], "let testSByteMultiplyChecked(e1) (e2) = Checked.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),Checked.op_Multiply (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.MultiplyDynamic (arg0_0,arg1_0),e1,e2)) @ (26,56--26,73)" [], "let testSByteUnaryNegChecked(e1) = Checked.op_Subtraction (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.SubtractionDynamic (arg0_0,arg1_0),0,e1) @ (27,45--27,60)" [], "let testSByteToByteChecked(e1) = Checked.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (29,45--29,60)" - [], "let testSByteToSByteChecked(e1) = Checked.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (30,45--30,61)" + [], "let testSByteToSByteChecked(e1) = e1 @ (30,59--30,61)" [], "let testSByteToInt16Checked(e1) = Checked.ToInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (31,45--31,61)" [], "let testSByteToUInt16Checked(e1) = Checked.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (32,45--32,62)" [], "let testSByteToIntChecked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (33,45--33,59)" @@ -1307,7 +1307,7 @@ let ``Test Operator Declarations for SByte`` () = [], "let testSByteToIntPtrChecked(e1) = Checked.ToIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (38,45--38,65)" [], "let testSByteToUIntPtrChecked(e1) = Checked.ToUIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (39,45--39,66)" [], "let testSByteToByteOperator(e1) = Operators.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (41,45--41,52)" - [], "let testSByteToSByteOperator(e1) = Operators.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (42,45--42,53)" + [], "let testSByteToSByteOperator(e1) = e1 @ (42,51--42,53)" [], "let testSByteToInt16Operator(e1) = Operators.ToInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (43,45--43,53)" [], "let testSByteToUInt16Operator(e1) = Operators.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (44,45--44,54)" [], "let testSByteToIntOperator(e1) = Operators.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (45,45--45,51)" @@ -1406,7 +1406,7 @@ let ``Test Operator Declarations for Int16`` () = [], "let testInt16UnaryNegChecked(e1) = Checked.op_Subtraction (fun arg0_0 -> fun arg1_0 -> LanguagePrimitives.SubtractionDynamic (arg0_0,arg1_0),0,e1) @ (27,45--27,60)" [], "let testInt16ToByteChecked(e1) = Checked.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (29,45--29,60)" [], "let testInt16ToSByteChecked(e1) = Checked.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (30,45--30,61)" - [], "let testInt16ToInt16Checked(e1) = Checked.ToInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (31,45--31,61)" + [], "let testInt16ToInt16Checked(e1) = e1 @ (31,59--31,61)" [], "let testInt16ToUInt16Checked(e1) = Checked.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (32,45--32,62)" [], "let testInt16ToIntChecked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (33,45--33,59)" [], "let testInt16ToInt32Checked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (34,45--34,61)" @@ -1417,7 +1417,7 @@ let ``Test Operator Declarations for Int16`` () = [], "let testInt16ToUIntPtrChecked(e1) = Checked.ToUIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (39,45--39,66)" [], "let testInt16ToByteOperator(e1) = Operators.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (41,45--41,52)" [], "let testInt16ToSByteOperator(e1) = Operators.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (42,45--42,53)" - [], "let testInt16ToInt16Operator(e1) = Operators.ToInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (43,45--43,53)" + [], "let testInt16ToInt16Operator(e1) = e1 @ (43,51--43,53)" [], "let testInt16ToUInt16Operator(e1) = Operators.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (44,45--44,54)" [], "let testInt16ToIntOperator(e1) = Operators.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (45,45--45,51)" [], "let testInt16ToInt32Operator(e1) = Operators.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (46,45--46,53)" @@ -1515,7 +1515,7 @@ let ``Test Operator Declarations for UInt16`` () = [], "let testUInt16ToByteChecked(e1) = Checked.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (29,47--29,62)" [], "let testUInt16ToSByteChecked(e1) = Checked.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (30,47--30,63)" [], "let testUInt16ToInt16Checked(e1) = Checked.ToInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (31,47--31,63)" - [], "let testUInt16ToUInt16Checked(e1) = Checked.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (32,47--32,64)" + [], "let testUInt16ToUInt16Checked(e1) = e1 @ (32,62--32,64)" [], "let testUInt16ToIntChecked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (33,47--33,61)" [], "let testUInt16ToInt32Checked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (34,47--34,63)" [], "let testUInt16ToUInt32Checked(e1) = Checked.ToUInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (35,47--35,64)" @@ -1526,7 +1526,7 @@ let ``Test Operator Declarations for UInt16`` () = [], "let testUInt16ToByteOperator(e1) = Operators.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (41,47--41,54)" [], "let testUInt16ToSByteOperator(e1) = Operators.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (42,47--42,55)" [], "let testUInt16ToInt16Operator(e1) = Operators.ToInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (43,47--43,55)" - [], "let testUInt16ToUInt16Operator(e1) = Operators.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (44,47--44,56)" + [], "let testUInt16ToUInt16Operator(e1) = e1 @ (44,54--44,56)" [], "let testUInt16ToIntOperator(e1) = Operators.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (45,47--45,53)" [], "let testUInt16ToInt32Operator(e1) = Operators.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (46,47--46,55)" [], "let testUInt16ToUInt32Operator(e1) = Operators.ToUInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (47,47--47,56)" @@ -1537,7 +1537,7 @@ let ``Test Operator Declarations for UInt16`` () = [], "let testUInt16ToSingleOperator(e1) = Operators.ToSingle (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),Operators.ToDouble (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1)) @ (52,47--52,57)" [], "let testUInt16ToDoubleOperator(e1) = Operators.ToDouble (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),Operators.ToDouble (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1)) @ (53,47--53,55)" [], "let testUInt16ToDecimalOperator(e1) = Convert.ToDecimal (e1) @ (54,47--54,57)" - [], "let testUInt16ToCharOperator(e1) = Operators.ToChar (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (55,47--55,54)" + [], "let testUInt16ToCharOperator(e1) = e1 @ (55,47--55,54)" [FC47; FC50], "let testUInt16ToStringOperator(e1) = let mutable copyOfStruct: Microsoft.FSharp.Core.uint16 = e1 in copyOfStruct.ToString() @ (56,47--56,56)" ] @@ -1625,8 +1625,8 @@ let ``Test Operator Declarations for Int`` () = [], "let testIntToSByteChecked(e1) = Checked.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (30,41--30,57)" [], "let testIntToInt16Checked(e1) = Checked.ToInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (31,41--31,57)" [], "let testIntToUInt16Checked(e1) = Checked.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (32,41--32,58)" - [], "let testIntToIntChecked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (33,41--33,55)" - [], "let testIntToInt32Checked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (34,41--34,57)" + [], "let testIntToIntChecked(e1) = e1 @ (33,53--33,55)" + [], "let testIntToInt32Checked(e1) = e1 @ (34,55--34,57)" [], "let testIntToUInt32Checked(e1) = Checked.ToUInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (35,41--35,58)" [], "let testIntToInt64Checked(e1) = Checked.ToInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (36,41--36,57)" [], "let testIntToUInt64Checked(e1) = Checked.ToUInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (37,41--37,58)" @@ -1734,8 +1734,8 @@ let ``Test Operator Declarations for Int32`` () = [], "let testInt32ToSByteChecked(e1) = Checked.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (30,45--30,61)" [], "let testInt32ToInt16Checked(e1) = Checked.ToInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (31,45--31,61)" [], "let testInt32ToUInt16Checked(e1) = Checked.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (32,45--32,62)" - [], "let testInt32ToIntChecked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (33,45--33,59)" - [], "let testInt32ToInt32Checked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (34,45--34,61)" + [], "let testInt32ToIntChecked(e1) = e1 @ (33,57--33,59)" + [], "let testInt32ToInt32Checked(e1) = e1 @ (34,59--34,61)" [], "let testInt32ToUInt32Checked(e1) = Checked.ToUInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (35,45--35,62)" [], "let testInt32ToInt64Checked(e1) = Checked.ToInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (36,45--36,61)" [], "let testInt32ToUInt64Checked(e1) = Checked.ToUInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (37,45--37,62)" @@ -1845,7 +1845,7 @@ let ``Test Operator Declarations for UInt32`` () = [], "let testUInt32ToUInt16Checked(e1) = Checked.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (32,47--32,64)" [], "let testUInt32ToIntChecked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (33,47--33,61)" [], "let testUInt32ToInt32Checked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (34,47--34,63)" - [], "let testUInt32ToUInt32Checked(e1) = Checked.ToUInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (35,47--35,64)" + [], "let testUInt32ToUInt32Checked(e1) = e1 @ (35,62--35,64)" [], "let testUInt32ToInt64Checked(e1) = Checked.ToInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (36,47--36,63)" [], "let testUInt32ToUInt64Checked(e1) = Checked.ToUInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (37,47--37,64)" [], "let testUInt32ToIntPtrChecked(e1) = Checked.ToIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (38,47--38,67)" @@ -1856,7 +1856,7 @@ let ``Test Operator Declarations for UInt32`` () = [], "let testUInt32ToUInt16Operator(e1) = Operators.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (44,47--44,56)" [], "let testUInt32ToIntOperator(e1) = Operators.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (45,47--45,53)" [], "let testUInt32ToInt32Operator(e1) = Operators.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (46,47--46,55)" - [], "let testUInt32ToUInt32Operator(e1) = Operators.ToUInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (47,47--47,56)" + [], "let testUInt32ToUInt32Operator(e1) = e1 @ (47,54--47,56)" [], "let testUInt32ToInt64Operator(e1) = Operators.ToUInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (48,47--48,55)" [], "let testUInt32ToUInt64Operator(e1) = Operators.ToUInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (49,47--49,56)" [], "let testUInt32ToIntPtrOperator(e1) = Operators.ToUIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (50,47--50,59)" @@ -1955,7 +1955,7 @@ let ``Test Operator Declarations for Int64`` () = [], "let testInt64ToIntChecked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (33,45--33,59)" [], "let testInt64ToInt32Checked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (34,45--34,61)" [], "let testInt64ToUInt32Checked(e1) = Checked.ToUInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (35,45--35,62)" - [], "let testInt64ToInt64Checked(e1) = Checked.ToInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (36,45--36,61)" + [], "let testInt64ToInt64Checked(e1) = e1 @ (36,59--36,61)" [], "let testInt64ToUInt64Checked(e1) = Checked.ToUInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (37,45--37,62)" [], "let testInt64ToIntPtrChecked(e1) = Checked.ToIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (38,45--38,65)" [], "let testInt64ToUIntPtrChecked(e1) = Checked.ToUIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (39,45--39,66)" @@ -1966,7 +1966,7 @@ let ``Test Operator Declarations for Int64`` () = [], "let testInt64ToIntOperator(e1) = Operators.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (45,45--45,51)" [], "let testInt64ToInt32Operator(e1) = Operators.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (46,45--46,53)" [], "let testInt64ToUInt32Operator(e1) = Operators.ToUInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (47,45--47,54)" - [], "let testInt64ToInt64Operator(e1) = Operators.ToInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (48,45--48,53)" + [], "let testInt64ToInt64Operator(e1) = e1 @ (48,51--48,53)" [], "let testInt64ToUInt64Operator(e1) = Operators.ToUInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (49,45--49,54)" [], "let testInt64ToIntPtrOperator(e1) = Operators.ToIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (50,45--50,57)" [], "let testInt64ToUIntPtrOperator(e1) = Operators.ToIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (51,45--51,58)" @@ -2065,7 +2065,7 @@ let ``Test Operator Declarations for UInt64`` () = [], "let testUInt64ToInt32Checked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (34,47--34,63)" [], "let testUInt64ToUInt32Checked(e1) = Checked.ToUInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (35,47--35,64)" [], "let testUInt64ToInt64Checked(e1) = Checked.ToInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (36,47--36,63)" - [], "let testUInt64ToUInt64Checked(e1) = Checked.ToUInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (37,47--37,64)" + [], "let testUInt64ToUInt64Checked(e1) = e1 @ (37,62--37,64)" [], "let testUInt64ToIntPtrChecked(e1) = Checked.ToIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (38,47--38,67)" [], "let testUInt64ToUIntPtrChecked(e1) = Checked.ToUIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (39,47--39,68)" [], "let testUInt64ToByteOperator(e1) = Operators.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (41,47--41,54)" @@ -2175,7 +2175,7 @@ let ``Test Operator Declarations for IntPtr`` () = [], "let testIntPtrToUInt32Checked(e1) = Checked.ToUInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (35,50--35,67)" [], "let testIntPtrToInt64Checked(e1) = Checked.ToInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (36,50--36,66)" [], "let testIntPtrToUInt64Checked(e1) = Checked.ToUInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (37,50--37,67)" - [], "let testIntPtrToIntPtrChecked(e1) = Checked.ToIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (38,50--38,70)" + [], "let testIntPtrToIntPtrChecked(e1) = e1 @ (38,68--38,70)" [], "let testIntPtrToUIntPtrChecked(e1) = Checked.ToUIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (39,50--39,71)" [], "let testIntPtrToByteOperator(e1) = Operators.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (41,50--41,57)" [], "let testIntPtrToSByteOperator(e1) = Operators.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (42,50--42,58)" @@ -2186,7 +2186,7 @@ let ``Test Operator Declarations for IntPtr`` () = [], "let testIntPtrToUInt32Operator(e1) = Operators.ToUInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (47,50--47,59)" [], "let testIntPtrToInt64Operator(e1) = Operators.ToInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (48,50--48,58)" [], "let testIntPtrToUInt64Operator(e1) = Operators.ToInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (49,50--49,59)" - [], "let testIntPtrToIntPtrOperator(e1) = Operators.ToIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (50,50--50,62)" + [], "let testIntPtrToIntPtrOperator(e1) = e1 @ (50,60--50,62)" [], "let testIntPtrToUIntPtrOperator(e1) = Operators.ToUIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (51,50--51,63)" [], "let testIntPtrToSingleOperator(e1) = Operators.ToSingle (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (52,50--52,60)" [], "let testIntPtrToDoubleOperator(e1) = Operators.ToDouble (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (53,50--53,58)" @@ -2284,7 +2284,7 @@ let ``Test Operator Declarations for UIntPtr`` () = [], "let testUIntPtrToInt64Checked(e1) = Checked.ToInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (36,52--36,68)" [], "let testUIntPtrToUInt64Checked(e1) = Checked.ToUInt64 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (37,52--37,69)" [], "let testUIntPtrToIntPtrChecked(e1) = Checked.ToIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (38,52--38,72)" - [], "let testUIntPtrToUIntPtrChecked(e1) = Checked.ToUIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (39,52--39,73)" + [], "let testUIntPtrToUIntPtrChecked(e1) = e1 @ (39,71--39,73)" [], "let testUIntPtrToByteOperator(e1) = Operators.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (41,52--41,59)" [], "let testUIntPtrToSByteOperator(e1) = Operators.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (42,52--42,60)" [], "let testUIntPtrToInt16Operator(e1) = Operators.ToInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (43,52--43,60)" @@ -2870,7 +2870,7 @@ let ``Test Operator Declarations for Char`` () = [], "let testCharToByteChecked(e1) = Checked.ToByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (29,43--29,58)" [], "let testCharToSByteChecked(e1) = Checked.ToSByte (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (30,43--30,59)" [], "let testCharToInt16Checked(e1) = Checked.ToInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (31,43--31,59)" - [], "let testCharToUInt16Checked(e1) = Checked.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (32,43--32,60)" + [], "let testCharToUInt16Checked(e1) = Operators.ToUInt16 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (32,43--32,60)" [], "let testCharToIntChecked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (33,43--33,57)" [], "let testCharToInt32Checked(e1) = Checked.ToInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (34,43--34,59)" [], "let testCharToUInt32Checked(e1) = Checked.ToUInt32 (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (35,43--35,60)" @@ -2891,7 +2891,7 @@ let ``Test Operator Declarations for Char`` () = [], "let testCharToUIntPtrOperator(e1) = Operators.ToUIntPtr (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (51,43--51,56)" [], "let testCharToSingleOperator(e1) = Operators.ToSingle (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),Operators.ToDouble (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1)) @ (52,43--52,53)" [], "let testCharToDoubleOperator(e1) = Operators.ToDouble (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),Operators.ToDouble (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1)) @ (53,43--53,51)" - [], "let testCharToCharOperator(e1) = Operators.ToChar (fun arg0_0 -> LanguagePrimitives.ExplicitDynamic (arg0_0),e1) @ (55,43--55,50)" + [], "let testCharToCharOperator(e1) = e1 @ (55,48--55,50)" [FC47; FC50], "let testCharToStringOperator(e1) = let mutable copyOfStruct: Microsoft.FSharp.Core.char = e1 in copyOfStruct.ToString() @ (56,43--56,52)" ] From 205b9a8908e71e5c158cc211af41b3bc7b1c1cf3 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Tue, 12 Jul 2022 16:48:04 +0100 Subject: [PATCH 11/11] Mark backing fields as CompilerGenerated (fixes serialization of fields in FSI multiemit) (#13494) --- VisualFSharp.sln | 10 +- src/Compiler/CodeGen/IlxGen.fs | 8 +- .../GenericComparison/Compare06.fsx.il.bsl | 2 + .../GenericComparison/Equals05.fsx.il.bsl | 2 + .../GenericComparison/Hash08.fsx.il.bsl | 2 + .../EmittedIL/Misc/AnonRecd.fs.il.bsl | 2 + .../TestFunction17.fs.il.debug.bsl | 2 + .../TestFunction17.fs.il.release.bsl | 2 + .../TestFunction24.fs.il.debug.bsl | 2 + .../TestFunction24.fs.il.release.bsl | 2 + tests/FSharp.Test.Utilities/TestFramework.fs | 4 +- .../core/printing/output.1000.stdout.bsl | 53 +++++++++ .../core/printing/output.200.stdout.bsl | 53 +++++++++ .../fsharp/core/printing/output.47.stderr.bsl | 108 ++++++++++++++++++ .../fsharp/core/printing/output.47.stdout.bsl | 2 +- .../core/printing/output.multiemit.stdout.bsl | 53 +++++++++ .../core/printing/output.off.stdout.bsl | 53 +++++++++ .../core/printing/output.quiet.stdout.bsl | 3 + tests/fsharp/core/printing/output.stdout.bsl | 53 +++++++++ tests/fsharp/core/printing/test.fsx | 40 +++++++ tests/fsharp/tests.fs | 11 +- 21 files changed, 456 insertions(+), 11 deletions(-) diff --git a/VisualFSharp.sln b/VisualFSharp.sln index c99c08c29c5..fa4c376c818 100644 --- a/VisualFSharp.sln +++ b/VisualFSharp.sln @@ -84,6 +84,14 @@ EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Test.Utilities", "tests\FSharp.Test.Utilities\FSharp.Test.Utilities.fsproj", "{60D275B0-B14A-41CB-A1B2-E815A7448FCB}" EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpSuite.Tests", "tests\fsharp\FSharpSuite.Tests.fsproj", "{C163E892-5BF7-4B59-AA99-B0E8079C67C4}" + ProjectSection(ProjectDependencies) = postProject + {0973C362-585C-4838-9459-D7E45C6B784B} = {0973C362-585C-4838-9459-D7E45C6B784B} + {37EB3E54-ABC6-4CF5-8273-7CE4B61A42C1} = {37EB3E54-ABC6-4CF5-8273-7CE4B61A42C1} + {511C95D9-3BA6-451F-B6F8-F033F40878A5} = {511C95D9-3BA6-451F-B6F8-F033F40878A5} + {597D9896-4B90-4E9E-9C99-445C2CB9FF60} = {597D9896-4B90-4E9E-9C99-445C2CB9FF60} + {E54456F4-D51A-4334-B225-92EBBED92B40} = {E54456F4-D51A-4334-B225-92EBBED92B40} + {EB015235-1E07-4CDA-9CC6-3FBCC27910D1} = {EB015235-1E07-4CDA-9CC6-3FBCC27910D1} + EndProjectSection EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.UnitTests", "tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj", "{A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5}" EndProject @@ -149,8 +157,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Service", " EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Service.Tests", "tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj", "{14F3D3D6-5C8E-43C2-98A2-17EA704D4DEA}" ProjectSection(ProjectDependencies) = postProject - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B} = {FF76BD3C-5E0A-4752-B6C3-044F6E15719B} {887630A3-4B1D-40EA-B8B3-2D842E9C40DB} = {887630A3-4B1D-40EA-B8B3-2D842E9C40DB} + {FF76BD3C-5E0A-4752-B6C3-044F6E15719B} = {FF76BD3C-5E0A-4752-B6C3-044F6E15719B} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisualFSharpDebug", "vsintegration\Vsix\VisualFSharpFull\VisualFSharpDebug.csproj", "{A422D673-8E3B-4924-821B-DD3174173426}" diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 361f9078495..63c543cfed2 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -2073,7 +2073,7 @@ type AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbu mkILFields [ for _, fldName, fldTy in flds -> - // Don't hide fields when splitting to multiple assemblies. + let access = if cenv.options.isInteractive && cenv.options.fsiMultiAssemblyEmit then ILMemberAccess.Public @@ -2081,7 +2081,8 @@ type AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbu ILMemberAccess.Private let fdef = mkILInstanceField (fldName, fldTy, None, access) - fdef.With(customAttrs = mkILCustomAttrs [ g.DebuggerBrowsableNeverAttribute ]) + let attrs = [ g.CompilerGeneratedAttribute; g.DebuggerBrowsableNeverAttribute ] + fdef.With(customAttrs = mkILCustomAttrs attrs) ] // Generate property definitions for the fields compiled as properties @@ -10676,7 +10677,8 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = let extraAttribs = match tyconRepr with - | TFSharpRecdRepr _ when not useGenuineField -> [ g.DebuggerBrowsableNeverAttribute ] // hide fields in records in debug display + | TFSharpRecdRepr _ when not useGenuineField -> + [ g.CompilerGeneratedAttribute; g.DebuggerBrowsableNeverAttribute ] | _ -> [] // don't hide fields in classes in debug display let access = ComputeMemberAccess isFieldHidden diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare06.fsx.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare06.fsx.il.bsl index 30f333f36c8..b7aea842a83 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare06.fsx.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare06.fsx.il.bsl @@ -66,8 +66,10 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) .field assembly int32 key1@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field assembly int32 key2@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_key1() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals05.fsx.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals05.fsx.il.bsl index 78d4df8f587..34ab1b1e85c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals05.fsx.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals05.fsx.il.bsl @@ -66,8 +66,10 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) .field assembly int32 key1@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field assembly int32 key2@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_key1() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Hash08.fsx.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Hash08.fsx.il.bsl index b23967fe77b..c94a00b3427 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Hash08.fsx.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Hash08.fsx.il.bsl @@ -66,8 +66,10 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) .field assembly int32 key1@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field assembly int32 key2@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_key1() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/AnonRecd.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/AnonRecd.fs.il.bsl index 0b4d87cf293..31112ecefe0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/AnonRecd.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/AnonRecd.fs.il.bsl @@ -99,8 +99,10 @@ .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) .field private !'j__TPar' A@ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field private !'j__TPar' B@ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public specialname rtspecialname instance void .ctor(!'j__TPar' A, diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.debug.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.debug.bsl index ded94e51adc..de3a5062203 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.debug.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.debug.bsl @@ -62,8 +62,10 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) .field assembly int32 x@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field assembly int32 y@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_x() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.release.bsl index d34dc778f67..17ff542c4ed 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.release.bsl @@ -62,8 +62,10 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) .field assembly int32 x@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field assembly int32 y@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_x() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.debug.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.debug.bsl index 1139c1cdb0d..6047356613b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.debug.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.debug.bsl @@ -62,8 +62,10 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) .field public int32 x@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field public int32 y@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_x() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.release.bsl index 51afb9c71dd..97404f6bb4a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.release.bsl @@ -62,8 +62,10 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) .field public int32 x@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field public int32 y@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_x() cil managed diff --git a/tests/FSharp.Test.Utilities/TestFramework.fs b/tests/FSharp.Test.Utilities/TestFramework.fs index f2d93c0513c..60aac52400a 100644 --- a/tests/FSharp.Test.Utilities/TestFramework.fs +++ b/tests/FSharp.Test.Utilities/TestFramework.fs @@ -652,8 +652,8 @@ let diff normalize path1 path2 = if x >= 0 then line.Substring(x+cwd.Length) else line else line - let line1 = normalizePath lines1[i] - let line2 = normalizePath lines2[i] + let line1 = lines1[i] |> normalizePath + let line2 = lines2[i] |> normalizePath if line1 <> line2 then append <| sprintf "diff between [%s] and [%s]" path1 path2 diff --git a/tests/fsharp/core/printing/output.1000.stdout.bsl b/tests/fsharp/core/printing/output.1000.stdout.bsl index cc3eaef035e..cdf91519c8d 100644 --- a/tests/fsharp/core/printing/output.1000.stdout.bsl +++ b/tests/fsharp/core/printing/output.1000.stdout.bsl @@ -2764,4 +2764,57 @@ val ShortName: string = "hi" > val list2: int list = [1] +module FSI_0317. + D27805741a339047ef3ed7a2ca8faae3c17e6ef2371984011e49a6c9c3286641 + +{"ImmutableField0":6} +type R1 = + { ImmutableField0: int } +val it: unit = () + +> val it: R1 = { ImmutableField0 = 7 } + +> {"MutableField1":8} +type R2 = + { mutable MutableField1: int } +val it: unit = () + +> val it: R2 = { MutableField1 = 9 } + +> {"AnonRecordField2":10} +val it: unit = () + +> val it: {| AnonRecordField2: int |} = { AnonRecordField2 = 11 } + +module FSI_0324.Project.fsproj + +type R3 = + { ImmutableField3: int } +val test3a: string = "{"ImmutableField3":12}" + +> val test3b: R3 = { ImmutableField3 = 12 } + +> val test3c: string = "{"ImmutableField3":13}" + +> val test3d: R3 = { ImmutableField3 = 13 } + +> type R4 = + { mutable MutableField4: int } +val test4a: string = "{"MutableField4":15}" + +> val test4b: R4 = { MutableField4 = 15 } + +> val test4c: string = "{"MutableField4":16}" + +> val test4d: R4 = { MutableField4 = 16 } + +> type R5 = {| AnonRecordField5: int |} +val test5a: string = "{"AnonRecordField5":17}" + +> val test5b: R5 = { AnonRecordField5 = 17 } + +> val test5c: string = "{"AnonRecordField5":18}" + +> val test5d: R5 = { AnonRecordField5 = 18 } + > > > diff --git a/tests/fsharp/core/printing/output.200.stdout.bsl b/tests/fsharp/core/printing/output.200.stdout.bsl index 6d1b4c6dfc9..cb22322c94a 100644 --- a/tests/fsharp/core/printing/output.200.stdout.bsl +++ b/tests/fsharp/core/printing/output.200.stdout.bsl @@ -2009,4 +2009,57 @@ val ShortName: string = "hi" > val list2: int list = [1] +module FSI_0317. + D27805741a339047ef3ed7a2ca8faae3c17e6ef2371984011e49a6c9c3286641 + +{"ImmutableField0":6} +type R1 = + { ImmutableField0: int } +val it: unit = () + +> val it: R1 = { ImmutableField0 = 7 } + +> {"MutableField1":8} +type R2 = + { mutable MutableField1: int } +val it: unit = () + +> val it: R2 = { MutableField1 = 9 } + +> {"AnonRecordField2":10} +val it: unit = () + +> val it: {| AnonRecordField2: int |} = { AnonRecordField2 = 11 } + +module FSI_0324.Project.fsproj + +type R3 = + { ImmutableField3: int } +val test3a: string = "{"ImmutableField3":12}" + +> val test3b: R3 = { ImmutableField3 = 12 } + +> val test3c: string = "{"ImmutableField3":13}" + +> val test3d: R3 = { ImmutableField3 = 13 } + +> type R4 = + { mutable MutableField4: int } +val test4a: string = "{"MutableField4":15}" + +> val test4b: R4 = { MutableField4 = 15 } + +> val test4c: string = "{"MutableField4":16}" + +> val test4d: R4 = { MutableField4 = 16 } + +> type R5 = {| AnonRecordField5: int |} +val test5a: string = "{"AnonRecordField5":17}" + +> val test5b: R5 = { AnonRecordField5 = 17 } + +> val test5c: string = "{"AnonRecordField5":18}" + +> val test5d: R5 = { AnonRecordField5 = 18 } + > > > diff --git a/tests/fsharp/core/printing/output.47.stderr.bsl b/tests/fsharp/core/printing/output.47.stderr.bsl index 4d3209ca246..3e98bca2fc4 100644 --- a/tests/fsharp/core/printing/output.47.stderr.bsl +++ b/tests/fsharp/core/printing/output.47.stderr.bsl @@ -334,3 +334,111 @@ stdin(838,6): error FS1210: Active pattern '|A|B|' has a result type containing stdin(844,6): error FS1209: Active pattern '|A|B|' is not a function + + #r "nuget:Newtonsoft.Json, 13.0.1" + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +stdin(1117,1): error FS3302: The 'package management' feature requires language version 5.0 or above + + + JsonConvert.SerializeObject { ImmutableField0 = 7 } + ^^^^^^^^^^^ + +stdin(1122,1): error FS0039: The value, namespace, type or module 'JsonConvert' is not defined. + + + JsonConvert.SerializeObject { MutableField1 = 8 } |> printfn "%s";; + ^^^^^^^^^^^ + +stdin(1126,1): error FS0039: The value, namespace, type or module 'JsonConvert' is not defined. + + + JsonConvert.SerializeObject { MutableField1 = 9 } + ^^^^^^^^^^^ + +stdin(1128,1): error FS0039: The value, namespace, type or module 'JsonConvert' is not defined. + + + JsonConvert.SerializeObject {| AnonRecordField2 = 10 |} |> printfn "%s";; + ^^^^^^^^^^^ + +stdin(1131,1): error FS0039: The value, namespace, type or module 'JsonConvert' is not defined. + + + JsonConvert.SerializeObject {| AnonRecordField2 = 11 |} + ^^^^^^^^^^^ + +stdin(1133,1): error FS0039: The value, namespace, type or module 'JsonConvert' is not defined. + + + #r "nuget: System.Text.Json" + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +stdin(1136,1): error FS3302: The 'package management' feature requires language version 5.0 or above + + + let test3b = JsonSerializer.Deserialize test3a;; + -------------^^^^^^^^^^^^^^ + +stdin(1140,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test3c = JsonSerializer.Serialize { ImmutableField3 = 13 };; + -------------^^^^^^^^^^^^^^ + +stdin(1141,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test3d = JsonSerializer.Deserialize test3c;; + -------------^^^^^^^^^^^^^^ + +stdin(1142,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test4a = JsonSerializer.Serialize { MutableField4 = 15 };; + -------------^^^^^^^^^^^^^^ + +stdin(1145,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test4b = JsonSerializer.Deserialize test4a;; + -------------^^^^^^^^^^^^^^ + +stdin(1146,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test4c = JsonSerializer.Serialize { MutableField4 = 16 };; + -------------^^^^^^^^^^^^^^ + +stdin(1147,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test4d = JsonSerializer.Deserialize test4c;; + -------------^^^^^^^^^^^^^^ + +stdin(1148,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test5a = JsonSerializer.Serialize {| AnonRecordField5 = 17 |};; + -------------^^^^^^^^^^^^^^ + +stdin(1151,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test5b = JsonSerializer.Deserialize test5a;; + -------------^^^^^^^^^^^^^^ + +stdin(1152,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test5c = JsonSerializer.Serialize {| AnonRecordField5 = 18 |};; + -------------^^^^^^^^^^^^^^ + +stdin(1153,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test5d = JsonSerializer.Deserialize test5c;; + -------------^^^^^^^^^^^^^^ + +stdin(1154,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + diff --git a/tests/fsharp/core/printing/output.47.stdout.bsl b/tests/fsharp/core/printing/output.47.stdout.bsl index af2d597eaad..b6f38074b36 100644 --- a/tests/fsharp/core/printing/output.47.stdout.bsl +++ b/tests/fsharp/core/printing/output.47.stdout.bsl @@ -6309,4 +6309,4 @@ val ShortName: string = "hi" > val list2: int list = [1] -> > > +> > > > > > > > > > > > > > > > > > > > > diff --git a/tests/fsharp/core/printing/output.multiemit.stdout.bsl b/tests/fsharp/core/printing/output.multiemit.stdout.bsl index acdcf6c63d8..9183285f872 100644 --- a/tests/fsharp/core/printing/output.multiemit.stdout.bsl +++ b/tests/fsharp/core/printing/output.multiemit.stdout.bsl @@ -6311,4 +6311,57 @@ val ShortName: string = "hi" > val list2: int list = [1] +module FSI_0316. + D27805741a339047ef3ed7a2ca8faae3c17e6ef2371984011e49a6c9c3286641 + +{"ImmutableField0":6} +type R1 = + { ImmutableField0: int } +val it: unit = () + +> val it: R1 = { ImmutableField0 = 7 } + +> {"MutableField1":8} +type R2 = + { mutable MutableField1: int } +val it: unit = () + +> val it: R2 = { MutableField1 = 9 } + +> {"AnonRecordField2":10} +val it: unit = () + +> val it: {| AnonRecordField2: int |} = { AnonRecordField2 = 11 } + +module FSI_0323.Project.fsproj + +type R3 = + { ImmutableField3: int } +val test3a: string = "{"ImmutableField3":12}" + +> val test3b: R3 = { ImmutableField3 = 12 } + +> val test3c: string = "{"ImmutableField3":13}" + +> val test3d: R3 = { ImmutableField3 = 13 } + +> type R4 = + { mutable MutableField4: int } +val test4a: string = "{"MutableField4":15}" + +> val test4b: R4 = { MutableField4 = 15 } + +> val test4c: string = "{"MutableField4":16}" + +> val test4d: R4 = { MutableField4 = 16 } + +> type R5 = {| AnonRecordField5: int |} +val test5a: string = "{"AnonRecordField5":17}" + +> val test5b: R5 = { AnonRecordField5 = 17 } + +> val test5c: string = "{"AnonRecordField5":18}" + +> val test5d: R5 = { AnonRecordField5 = 18 } + > > > diff --git a/tests/fsharp/core/printing/output.off.stdout.bsl b/tests/fsharp/core/printing/output.off.stdout.bsl index 2bd43f77f8f..586d7a58860 100644 --- a/tests/fsharp/core/printing/output.off.stdout.bsl +++ b/tests/fsharp/core/printing/output.off.stdout.bsl @@ -1778,4 +1778,57 @@ val ShortName: string = "hi" > val list2: int list +module FSI_0317. + D27805741a339047ef3ed7a2ca8faae3c17e6ef2371984011e49a6c9c3286641 + +{"ImmutableField0":6} +type R1 = + { ImmutableField0: int } +val it: unit + +> val it: R1 = { ImmutableField0 = 7 } + +> {"MutableField1":8} +type R2 = + { mutable MutableField1: int } +val it: unit + +> val it: R2 = { MutableField1 = 9 } + +> {"AnonRecordField2":10} +val it: unit = () + +> val it: {| AnonRecordField2: int |} = { AnonRecordField2 = 11 } + +module FSI_0324.Project.fsproj + +type R3 = + { ImmutableField3: int } +val test3a: string + +> val test3b: R3 + +> val test3c: string + +> val test3d: R3 + +> type R4 = + { mutable MutableField4: int } +val test4a: string + +> val test4b: R4 + +> val test4c: string + +> val test4d: R4 + +> type R5 = {| AnonRecordField5: int |} +val test5a: string + +> val test5b: R5 + +> val test5c: string + +> val test5d: R5 + > > > diff --git a/tests/fsharp/core/printing/output.quiet.stdout.bsl b/tests/fsharp/core/printing/output.quiet.stdout.bsl index 26683b52103..d8d778aca70 100644 --- a/tests/fsharp/core/printing/output.quiet.stdout.bsl +++ b/tests/fsharp/core/printing/output.quiet.stdout.bsl @@ -11,3 +11,6 @@ [Building 5 3...done] Expect ABC = ABC Expect ABC = ABC +{"ImmutableField0":6} +{"MutableField1":8} +{"AnonRecordField2":10} diff --git a/tests/fsharp/core/printing/output.stdout.bsl b/tests/fsharp/core/printing/output.stdout.bsl index acdcf6c63d8..9183285f872 100644 --- a/tests/fsharp/core/printing/output.stdout.bsl +++ b/tests/fsharp/core/printing/output.stdout.bsl @@ -6311,4 +6311,57 @@ val ShortName: string = "hi" > val list2: int list = [1] +module FSI_0316. + D27805741a339047ef3ed7a2ca8faae3c17e6ef2371984011e49a6c9c3286641 + +{"ImmutableField0":6} +type R1 = + { ImmutableField0: int } +val it: unit = () + +> val it: R1 = { ImmutableField0 = 7 } + +> {"MutableField1":8} +type R2 = + { mutable MutableField1: int } +val it: unit = () + +> val it: R2 = { MutableField1 = 9 } + +> {"AnonRecordField2":10} +val it: unit = () + +> val it: {| AnonRecordField2: int |} = { AnonRecordField2 = 11 } + +module FSI_0323.Project.fsproj + +type R3 = + { ImmutableField3: int } +val test3a: string = "{"ImmutableField3":12}" + +> val test3b: R3 = { ImmutableField3 = 12 } + +> val test3c: string = "{"ImmutableField3":13}" + +> val test3d: R3 = { ImmutableField3 = 13 } + +> type R4 = + { mutable MutableField4: int } +val test4a: string = "{"MutableField4":15}" + +> val test4b: R4 = { MutableField4 = 15 } + +> val test4c: string = "{"MutableField4":16}" + +> val test4d: R4 = { MutableField4 = 16 } + +> type R5 = {| AnonRecordField5: int |} +val test5a: string = "{"AnonRecordField5":17}" + +> val test5b: R5 = { AnonRecordField5 = 17 } + +> val test5c: string = "{"AnonRecordField5":18}" + +> val test5d: R5 = { AnonRecordField5 = 18 } + > > > diff --git a/tests/fsharp/core/printing/test.fsx b/tests/fsharp/core/printing/test.fsx index 1bd15e348f8..c0943540b49 100644 --- a/tests/fsharp/core/printing/test.fsx +++ b/tests/fsharp/core/printing/test.fsx @@ -1114,6 +1114,46 @@ let list = [{ A = 1; B = "a" }];; let list2 = [ for x in list do x.A ];; +#r "nuget:Newtonsoft.Json, 13.0.1" +type R1 = { ImmutableField0: int } +open Newtonsoft.Json +JsonConvert.SerializeObject { ImmutableField0 = 6 } |> printfn "%s";; + +JsonConvert.SerializeObject { ImmutableField0 = 7 } +|> JsonConvert.DeserializeObject;; + +type R2 = { mutable MutableField1: int } +JsonConvert.SerializeObject { MutableField1 = 8 } |> printfn "%s";; + +JsonConvert.SerializeObject { MutableField1 = 9 } +|> JsonConvert.DeserializeObject;; + +JsonConvert.SerializeObject {| AnonRecordField2 = 10 |} |> printfn "%s";; + +JsonConvert.SerializeObject {| AnonRecordField2 = 11 |} +|> JsonConvert.DeserializeObject<{| AnonRecordField2 :int |}>;; + +#r "nuget: System.Text.Json" +open System.Text.Json +type R3 = { ImmutableField3: int } +let test3a = JsonSerializer.Serialize { ImmutableField3 = 12 };; +let test3b = JsonSerializer.Deserialize test3a;; +let test3c = JsonSerializer.Serialize { ImmutableField3 = 13 };; +let test3d = JsonSerializer.Deserialize test3c;; + +type R4 = { mutable MutableField4: int } +let test4a = JsonSerializer.Serialize { MutableField4 = 15 };; +let test4b = JsonSerializer.Deserialize test4a;; +let test4c = JsonSerializer.Serialize { MutableField4 = 16 };; +let test4d = JsonSerializer.Deserialize test4c;; + +type R5 = {| AnonRecordField5: int |} +let test5a = JsonSerializer.Serialize {| AnonRecordField5 = 17 |};; +let test5b = JsonSerializer.Deserialize test5a;; +let test5c = JsonSerializer.Serialize {| AnonRecordField5 = 18 |};; +let test5d = JsonSerializer.Deserialize test5c;; + + ;; (* ;; needed, to isolate error regressions *) ;;exit 0;; (* piped in to enable error regressions *) \ No newline at end of file diff --git a/tests/fsharp/tests.fs b/tests/fsharp/tests.fs index d8c4bd79cc2..d4da2adaf94 100644 --- a/tests/fsharp/tests.fs +++ b/tests/fsharp/tests.fs @@ -1060,10 +1060,13 @@ module CoreTests = let rawFileErr = tryCreateTemporaryFileName () ``fsi b 2>c`` "%s --nologo --preferreduilang:en-US %s" fsc_flags_errors_ok flag ("test.fsx", rawFileOut, rawFileErr) - // REM REVIEW: want to normalise CWD paths, not suppress them. - let ``findstr /v`` text = Seq.filter (fun (s: string) -> not <| s.Contains(text)) - let removeCDandHelp from' to' = - File.ReadLines from' |> (``findstr /v`` cfg.Directory) |> (``findstr /v`` "--help' for options") |> (fun lines -> File.WriteAllLines(getfullpath cfg to', lines)) + let removeCDandHelp fromFile toFile = + File.ReadAllLines fromFile + |> Array.filter (fun s -> not (s.Contains(cfg.Directory))) + |> Array.filter (fun s -> not (s.Contains("--help' for options"))) + |> Array.filter (fun s -> not (s.Contains("[Loading"))) + |> Array.filter (fun s -> not (s.Contains("Binding session"))) + |> (fun lines -> File.WriteAllLines(getfullpath cfg toFile, lines)) removeCDandHelp rawFileOut diffFileOut removeCDandHelp rawFileErr diffFileErr