diff --git a/docs/release-notes/.FSharp.Compiler.Service/10.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/10.0.300.md index 471abbfb982..c257183aa9b 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/10.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/10.0.300.md @@ -1,5 +1,22 @@ ### Fixed +* Fix TypeLoadException when creating delegate with voidptr parameter. (Issue [#11132](https://github.com/dotnet/fsharp/issues/11132)) +* Suppress tail calls when localloc (NativePtr.stackalloc) is used. (Issue [#13447](https://github.com/dotnet/fsharp/issues/13447)) +* Fix outref parameter compiled as byref. (Issue [#13468](https://github.com/dotnet/fsharp/issues/13468)) +* Fix DU case names matching IWSAM member names no longer cause duplicate property entries. (Issue [#14321](https://github.com/dotnet/fsharp/issues/14321)) +* Fix TypeLoadException in Release builds with inline constraints. (Issue [#14492](https://github.com/dotnet/fsharp/issues/14492)) +* Fix nativeptr in interfaces leads to TypeLoadException. (Issue [#14508](https://github.com/dotnet/fsharp/issues/14508)) +* Fix DefaultAugmentation(false) duplicate entry in method table. (Issue [#16565](https://github.com/dotnet/fsharp/issues/16565)) +* Avoid duplicate parameter names in closure constructors. (Issue [#17692](https://github.com/dotnet/fsharp/issues/17692)) +* Fix static abstract interface members with byref params. (Issue [#18135](https://github.com/dotnet/fsharp/issues/18135)) +* Use constrained.callvirt for method calls on value types. (Issue [#18140](https://github.com/dotnet/fsharp/issues/18140)) +* Fix box instruction for literal upcasts. (Issue [#18319](https://github.com/dotnet/fsharp/issues/18319)) +* Fix RuntimeWrappedException cannot be caught. (Issue [#18374](https://github.com/dotnet/fsharp/issues/18374)) +* Fix Action/Func conversion captures result not expression. (Issue [#18953](https://github.com/dotnet/fsharp/issues/18953)) +* Fix Decimal Literal causes InvalidProgramException in Debug builds. (Issue [#18956](https://github.com/dotnet/fsharp/issues/18956)) +* Fix object expressions in struct types no longer generate invalid IL with byref fields. (Issue [#19068](https://github.com/dotnet/fsharp/issues/19068)) +* Fix abstract event accessors now have SpecialName flag. (Issue [#5834](https://github.com/dotnet/fsharp/issues/5834)) +* Fix F# exception serialization now preserves fields. (Issue [#878](https://github.com/dotnet/fsharp/issues/878)) * Fixed Find All References not correctly finding active pattern cases in signature files. ([Issue #19173](https://github.com/dotnet/fsharp/issues/19173), [Issue #14969](https://github.com/dotnet/fsharp/issues/14969), [PR #19252](https://github.com/dotnet/fsharp/pull/19252)) * Fixed Rename not correctly handling operators containing `.` (e.g., `-.-`). ([Issue #17221](https://github.com/dotnet/fsharp/issues/17221), [Issue #14057](https://github.com/dotnet/fsharp/issues/14057), [PR #19252](https://github.com/dotnet/fsharp/pull/19252)) * Fixed Find All References not correctly applying `#line` directive remapping. ([Issue #9928](https://github.com/dotnet/fsharp/issues/9928), [PR #19252](https://github.com/dotnet/fsharp/pull/19252)) diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index 5d7848f246e..52a4efb6510 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -3333,6 +3333,15 @@ let mkILSimpleTypar nm = MetadataIndex = NoMetadataIdx } +let stripILGenericParamConstraints (gp: ILGenericParameterDef) = + { gp with + Constraints = [] + HasReferenceTypeConstraint = false + HasNotNullableValueTypeConstraint = false + HasDefaultConstructorConstraint = false + HasAllowsRefStruct = false + } + let genericParamOfGenericActual (_ga: ILType) = mkILSimpleTypar "T" let mkILFormalTypars (x: ILGenericArgsList) = List.map genericParamOfGenericActual x diff --git a/src/Compiler/AbstractIL/il.fsi b/src/Compiler/AbstractIL/il.fsi index 3d6f88bb6ca..29febf2b457 100644 --- a/src/Compiler/AbstractIL/il.fsi +++ b/src/Compiler/AbstractIL/il.fsi @@ -2066,6 +2066,7 @@ val internal mkILFormalNamedTy: ILBoxity -> ILTypeRef -> ILGenericParameterDef l val internal mkILFormalTypars: ILType list -> ILGenericParameterDefs val internal mkILFormalGenericArgs: int -> ILGenericParameterDefs -> ILGenericArgsList val internal mkILSimpleTypar: string -> ILGenericParameterDef +val internal stripILGenericParamConstraints: ILGenericParameterDef -> ILGenericParameterDef /// Make custom attributes. val internal mkILCustomAttribMethRef: diff --git a/src/Compiler/AbstractIL/ilwrite.fs b/src/Compiler/AbstractIL/ilwrite.fs index 40254a11965..cfa10ad46ac 100644 --- a/src/Compiler/AbstractIL/ilwrite.fs +++ b/src/Compiler/AbstractIL/ilwrite.fs @@ -446,16 +446,24 @@ type MethodDefKey(ilg:ILGlobals, tidx: int, garity: int, nm: string, retTy: ILTy override _.Equals(obj: obj) = match obj with | :? MethodDefKey as y -> - let compareILTypes o1 o2 = + let rec compareILTypes o1 o2 = match o1, o2 with - | ILType.Value v1, ILType.Value v2 -> v1.EqualsWithPrimaryScopeRef(ilg.primaryAssemblyScopeRef, v2 :> obj ) + | ILType.Value v1, ILType.Value v2 -> v1.EqualsWithPrimaryScopeRef(ilg.primaryAssemblyScopeRef, v2 :> obj) + | ILType.Boxed v1, ILType.Boxed v2 -> v1.EqualsWithPrimaryScopeRef(ilg.primaryAssemblyScopeRef, v2 :> obj) + | ILType.Byref t1, ILType.Byref t2 -> compareILTypes t1 t2 + | ILType.Ptr t1, ILType.Ptr t2 -> compareILTypes t1 t2 + | ILType.Array(sh1, t1), ILType.Array(sh2, t2) -> sh1 = sh2 && compareILTypes t1 t2 + | ILType.Modified(req1, tref1, t1), ILType.Modified(req2, tref2, t2) -> + req1 = req2 && tref1.EqualsWithPrimaryScopeRef(ilg.primaryAssemblyScopeRef, tref2 :> obj) && compareILTypes t1 t2 + | ILType.Modified(_, _, t1), t2 -> compareILTypes t1 t2 + | t1, ILType.Modified(_, _, t2) -> compareILTypes t1 t2 | _ -> o1 = o2 tidx = y.TypeIdx && garity = y.GenericArity && nm = y.Name && - // note: these next two use structural equality on AbstractIL ILType values - retTy = y.ReturnType && List.lengthsEqAndForall2 compareILTypes argTys y.ArgTypes && + // note: these next two use scope-aware equality on AbstractIL ILType values + compareILTypes retTy y.ReturnType && List.lengthsEqAndForall2 compareILTypes argTys y.ArgTypes && isStatic = y.IsStatic | _ -> false diff --git a/src/Compiler/Checking/MethodCalls.fs b/src/Compiler/Checking/MethodCalls.fs index 667eed5efc1..fb8d46cff15 100644 --- a/src/Compiler/Checking/MethodCalls.fs +++ b/src/Compiler/Checking/MethodCalls.fs @@ -1305,7 +1305,16 @@ let BuildObjCtorCall (g: TcGlobals) m = /// Implements the elaborated form of adhoc conversions from functions to delegates at member callsites let BuildNewDelegateExpr (eventInfoOpt: EventInfo option, g, amap, delegateTy, delInvokeMeth: MethInfo, delArgTys, delFuncExpr, delFuncTy, m) = let slotsig = delInvokeMeth.GetSlotSig(amap, m) - let delArgVals, expr = + + let needsBinding = + match delFuncExpr with + | Expr.Val _ + | Expr.Lambda _ + | Expr.TyLambda _ + | Expr.App(Expr.Val _, _, _, [], _) -> false + | _ -> true + + let delArgVals, expr, wrapperOpt = let valReprInfo = ValReprInfo([], List.replicate (max 1 (List.length delArgTys)) ValReprInfo.unnamedTopArg, ValReprInfo.unnamedRetVal) // Try to pull apart an explicit lambda and use it directly @@ -1322,6 +1331,13 @@ let BuildNewDelegateExpr (eventInfoOpt: EventInfo option, g, amap, delegateTy, d if List.exists (isByrefTy g) delArgTys then error(Error(FSComp.SR.tcFunctionRequiresExplicitLambda(delArgTys.Length), m)) + let funcExprToUse, funcTyToUse, wrapper = + if needsBinding then + let v, ve = mkCompGenLocal m "delegateFunc" delFuncTy + ve, delFuncTy, Some (fun body -> mkCompGenLet m v delFuncExpr body) + else + delFuncExpr, delFuncTy, None + let delFuncArgNamesIfFeatureEnabled = match delFuncExpr with | Expr.Val (valRef = vref) when g.langVersion.SupportsFeature LanguageFeature.ImprovedImpliedArgumentNames -> @@ -1350,15 +1366,16 @@ let BuildNewDelegateExpr (eventInfoOpt: EventInfo option, g, amap, delegateTy, d | h :: t -> [exprForVal m h; mkRefTupledVars g m t] | None -> if isNil delArgTys then [mkUnit g m] else List.map (exprForVal m) delArgVals - mkApps g ((delFuncExpr, delFuncTy), [], args, m) - delArgVals, expr + mkApps g ((funcExprToUse, funcTyToUse), [], args, m) + delArgVals, expr, wrapper | Some _ -> let _, _, _, vsl, body, _ = IteratedAdjustLambdaToMatchValReprInfo g amap valReprInfo delFuncExpr - List.concat vsl, body + List.concat vsl, body, None let meth = TObjExprMethod(slotsig, [], [], [delArgVals], expr, m) - mkObjExpr(delegateTy, None, BuildObjCtorCall g m, [meth], [], m) + let delegateExpr = mkObjExpr(delegateTy, None, BuildObjCtorCall g m, [meth], [], m) + (wrapperOpt |> Option.defaultValue id) delegateExpr let CoerceFromFSharpFuncToDelegate g amap infoReader ad callerArgTy m callerArgExpr delegateTy = let (SigOfFunctionForDelegate(delInvokeMeth, delArgTys, _, _)) = GetSigOfFunctionForDelegate infoReader delegateTy m ad diff --git a/src/Compiler/CodeGen/EraseClosures.fs b/src/Compiler/CodeGen/EraseClosures.fs index 6585fa1d661..b0b12aea283 100644 --- a/src/Compiler/CodeGen/EraseClosures.fs +++ b/src/Compiler/CodeGen/EraseClosures.fs @@ -152,7 +152,19 @@ let newIlxPubCloEnv (ilg, addMethodGeneratedAttrs, addFieldGeneratedAttrs, addFi let mkILTyFuncTy cenv = cenv.mkILTyFuncTy +let inline private (|IsVoidPtr|_|) ty = + match ty with + | ILType.Ptr ILType.Void -> true + | _ -> false + +let private fixVoidPtrForGenericArg (ilg: ILGlobals) ty = + match ty with + | IsVoidPtr -> ilg.typ_IntPtr + | _ -> ty + let mkILFuncTy cenv dty rty = + let dty = fixVoidPtrForGenericArg cenv.ilg dty + let rty = fixVoidPtrForGenericArg cenv.ilg rty mkILBoxedTy cenv.tref_Func[0] [ dty; rty ] let mkILCurriedFuncTy cenv dtys rty = @@ -167,6 +179,8 @@ let typ_Func cenv (dtys: ILType list) rty = else mkFuncTypeRef cenv.ilg.fsharpCoreAssemblyScopeRef n + let dtys = dtys |> List.map (fixVoidPtrForGenericArg cenv.ilg) + let rty = fixVoidPtrForGenericArg cenv.ilg rty mkILBoxedTy tref (dtys @ [ rty ]) let rec mkTyOfApps cenv apps = @@ -189,6 +203,8 @@ let mkMethSpecForMultiApp cenv (argTys: ILType list, retTy) = let n = argTys.Length let formalArgTys = List.mapi (fun i _ -> ILType.TypeVar(uint16 i)) argTys let formalRetTy = ILType.TypeVar(uint16 n) + let argTys = argTys |> List.map (fixVoidPtrForGenericArg cenv.ilg) + let retTy = fixVoidPtrForGenericArg cenv.ilg retTy let inst = argTys @ [ retTy ] if n = 1 then @@ -392,6 +408,19 @@ let mkILFreeVarForParam (p: ILParameter) = let mkILLocalForFreeVar (p: IlxClosureFreeVar) = mkILLocal p.fvType None +let mkUniqueFreeVarName (baseName: string) (existingFields: IlxClosureFreeVar[]) = + let existingNames = existingFields |> Array.map (fun fv -> fv.fvName) |> Set.ofArray + + let rec findUnique n = + let candidate = if n = 0 then baseName else baseName + string n + + if Set.contains candidate existingNames then + findUnique (n + 1) + else + candidate + + findUnique 0 + let mkILCloFldSpecs _cenv flds = flds |> Array.map (fun fv -> (fv.fvName, fv.fvType)) |> Array.toList @@ -490,7 +519,8 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo = let laterGenericParams = td.GenericParams @ addedGenParams let selfFreeVar = - mkILFreeVar (CompilerGeneratedName("self" + string nowFields.Length), true, nowCloSpec.ILType) + let baseName = CompilerGeneratedName("self" + string nowFields.Length) + mkILFreeVar (mkUniqueFreeVarName baseName nowFields, true, nowCloSpec.ILType) let laterFields = Array.append nowFields [| selfFreeVar |] let laterCloRef = IlxClosureRef(laterTypeRef, laterStruct, laterFields) @@ -545,12 +575,14 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo = let convil = convILMethodBody (Some nowCloSpec, boxReturnTy) clo.cloCode.Value + let specializeGenParams = addedGenParams |> List.map stripILGenericParamConstraints + let nowApplyMethDef = mkILGenericVirtualMethod ( "Specialize", ILCallingConv.Instance, ILMemberAccess.Public, - addedGenParams (* method is generic over added ILGenericParameterDefs *) , + specializeGenParams, [], mkILReturn cenv.ilg.typ_Object, MethodBody.IL(notlazy convil) @@ -612,7 +644,8 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo = let laterGenericParams = td.GenericParams // Number each argument left-to-right, adding one to account for the "this" pointer let selfFreeVar = - mkILFreeVar (CompilerGeneratedName "self", true, nowCloSpec.ILType) + let baseName = CompilerGeneratedName "self" + mkILFreeVar (mkUniqueFreeVarName baseName nowFields, true, nowCloSpec.ILType) let argToFreeVarMap = (0, selfFreeVar) @@ -676,7 +709,17 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo = else // CASE 2b - Build an Invoke method - let nowEnvParentClass = typ_Func cenv (typesOfILParams nowParams) nowReturnTy + let fixedNowParams = + nowParams + |> List.map (fun (p: ILParameter) -> + match p.Type with + | IsVoidPtr -> { p with Type = cenv.ilg.typ_IntPtr } + | _ -> p) + + let fixedNowReturnTy = fixVoidPtrForGenericArg cenv.ilg nowReturnTy + + let nowEnvParentClass = + typ_Func cenv (typesOfILParams fixedNowParams) fixedNowReturnTy let cloTypeDef = let convil = convILMethodBody (Some nowCloSpec, None) clo.cloCode.Value @@ -685,8 +728,8 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo = mkILNonGenericVirtualInstanceMethod ( "Invoke", ILMemberAccess.Public, - nowParams, - mkILReturn nowReturnTy, + fixedNowParams, + mkILReturn fixedNowReturnTy, MethodBody.IL(notlazy convil) ) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 1e2f26b011e..be53906e84d 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -605,6 +605,10 @@ let voidCheck m g permits ty = [] type DuFieldCoordinates = { CaseIdx: int; FieldIdx: int } +/// Flags propagated from interface slot signatures to parameter metadata. +[] +type SlotParamFlags = { IsIn: bool; IsOut: bool } + /// Structure for maintaining field reuse across struct unions type UnionFieldReuseMap = MultiMap @@ -643,8 +647,7 @@ and GenTyAppAux cenv m tyenv repr tinst = match repr with | CompiledTypeRepr.ILAsmOpen ty -> let ilTypeInst = GenTypeArgsAux cenv m tyenv tinst - let ty = instILType ilTypeInst ty - ty + instILType ilTypeInst ty | CompiledTypeRepr.ILAsmNamed(tref, boxity, ilTypeOpt) -> GenILTyAppAux cenv m tyenv (tref, boxity, ilTypeOpt) tinst and GenILTyAppAux cenv m tyenv (tref, boxity, ilTypeOpt) tinst = @@ -2508,6 +2511,8 @@ type CodeGenBuffer(m: range, mgbuf: AssemblyBuilder, methodName, alreadyUsedArgs let mutable hasDebugPoints = false let mutable anyDocument = None // we collect an arbitrary document in order to emit the header FeeFee if needed + let mutable hasStackAllocatedLocals = false + let codeLabelToPC: Dictionary = Dictionary<_, _>(10) let codeLabelToCodeLabel: Dictionary = @@ -2566,11 +2571,19 @@ type CodeGenBuffer(m: range, mgbuf: AssemblyBuilder, methodName, alreadyUsedArgs member cgbuf.EmitInstr(pops, pushes, i) = cgbuf.DoPops pops cgbuf.DoPushes pushes + + if i = I_localloc then + hasStackAllocatedLocals <- true + codebuf.Add i member cgbuf.EmitInstrs(pops, pushes, is) = cgbuf.DoPops pops cgbuf.DoPushes pushes + + if is |> List.exists (fun i -> i = I_localloc) then + hasStackAllocatedLocals <- true + is |> List.iter codebuf.Add member private _.EnsureNopBetweenDebugPoints() = @@ -2703,6 +2716,8 @@ type CodeGenBuffer(m: range, mgbuf: AssemblyBuilder, methodName, alreadyUsedArgs member _.HasPinnedLocals() = locals |> Seq.exists (fun (_, _, isFixed, _) -> isFixed) + member _.HasStackAllocatedLocals() = hasStackAllocatedLocals + member _.Close() = let instrs = codebuf.ToArray() @@ -3320,32 +3335,46 @@ and GenConstant cenv cgbuf eenv (c, m, ty) sequel = match TryEliminateDesugaredConstants g m c with | Some e -> GenExpr cenv cgbuf eenv e Continue | None -> - let emitInt64Constant i = + let needsBoxingToTargetTy = (match ilTy with ILType.Value _ -> false | _ -> true) + + // Wraps an emitter: calls it, then boxes if target type is not a value type (e.g. literal upcast to obj). + let inline emitAndBoxIfNeeded emitter uty arg = + emitter uty arg + if needsBoxingToTargetTy then + CG.EmitInstr cgbuf (pop 1) (Push [ ilTy ]) (I_box uty) + + let emitInt64Constant uty i = // see https://github.com/dotnet/fsharp/pull/3620 // and https://github.com/dotnet/fsharp/issue/8683 // and https://github.com/dotnet/roslyn/blob/98f12bb/src/Compilers/Core/Portable/CodeGen/ILBuilderEmit.cs#L679 if i >= int64 Int32.MinValue && i <= int64 Int32.MaxValue then - CG.EmitInstrs cgbuf (pop 0) (Push [ ilTy ]) [ mkLdcInt32 (int32 i); AI_conv DT_I8 ] + CG.EmitInstrs cgbuf (pop 0) (Push [ uty ]) [ mkLdcInt32 (int32 i); AI_conv DT_I8 ] elif i >= int64 UInt32.MinValue && i <= int64 UInt32.MaxValue then - CG.EmitInstrs cgbuf (pop 0) (Push [ ilTy ]) [ mkLdcInt32 (int32 i); AI_conv DT_U8 ] + CG.EmitInstrs cgbuf (pop 0) (Push [ uty ]) [ mkLdcInt32 (int32 i); AI_conv DT_U8 ] else - CG.EmitInstr cgbuf (pop 0) (Push [ ilTy ]) (iLdcInt64 i) + CG.EmitInstr cgbuf (pop 0) (Push [ uty ]) (iLdcInt64 i) + + let emitConst uty instr = + CG.EmitInstr cgbuf (pop 0) (Push [ uty ]) instr + + let emitConstI uty instrs = + CG.EmitInstrs cgbuf (pop 0) (Push [ uty ]) instrs match c with - | Const.Bool b -> CG.EmitInstr cgbuf (pop 0) (Push [ g.ilg.typ_Bool ]) (mkLdcInt32 (if b then 1 else 0)) - | Const.SByte i -> CG.EmitInstr cgbuf (pop 0) (Push [ ilTy ]) (mkLdcInt32 (int32 i)) - | Const.Int16 i -> CG.EmitInstr cgbuf (pop 0) (Push [ ilTy ]) (mkLdcInt32 (int32 i)) - | Const.Int32 i -> CG.EmitInstr cgbuf (pop 0) (Push [ ilTy ]) (mkLdcInt32 i) - | Const.Int64 i -> emitInt64Constant i - | Const.IntPtr i -> CG.EmitInstrs cgbuf (pop 0) (Push [ ilTy ]) [ iLdcInt64 i; AI_conv DT_I ] - | Const.Byte i -> CG.EmitInstr cgbuf (pop 0) (Push [ ilTy ]) (mkLdcInt32 (int32 i)) - | Const.UInt16 i -> CG.EmitInstr cgbuf (pop 0) (Push [ ilTy ]) (mkLdcInt32 (int32 i)) - | Const.UInt32 i -> CG.EmitInstr cgbuf (pop 0) (Push [ ilTy ]) (mkLdcInt32 (int32 i)) - | Const.UInt64 i -> emitInt64Constant (int64 i) - | Const.UIntPtr i -> CG.EmitInstrs cgbuf (pop 0) (Push [ ilTy ]) [ iLdcInt64 (int64 i); AI_conv DT_U ] - | Const.Double f -> CG.EmitInstr cgbuf (pop 0) (Push [ ilTy ]) (AI_ldc(DT_R8, ILConst.R8 f)) - | Const.Single f -> CG.EmitInstr cgbuf (pop 0) (Push [ ilTy ]) (AI_ldc(DT_R4, ILConst.R4 f)) - | Const.Char c -> CG.EmitInstr cgbuf (pop 0) (Push [ ilTy ]) (mkLdcInt32 (int c)) + | Const.Bool b -> emitAndBoxIfNeeded emitConst g.ilg.typ_Bool (mkLdcInt32 (if b then 1 else 0)) + | Const.SByte i -> emitAndBoxIfNeeded emitConst g.ilg.typ_SByte (mkLdcInt32 (int32 i)) + | Const.Int16 i -> emitAndBoxIfNeeded emitConst g.ilg.typ_Int16 (mkLdcInt32 (int32 i)) + | Const.Int32 i -> emitAndBoxIfNeeded emitConst g.ilg.typ_Int32 (mkLdcInt32 i) + | Const.Int64 i -> emitAndBoxIfNeeded emitInt64Constant g.ilg.typ_Int64 i + | Const.IntPtr i -> emitAndBoxIfNeeded emitConstI g.ilg.typ_IntPtr [ iLdcInt64 i; AI_conv DT_I ] + | Const.Byte i -> emitAndBoxIfNeeded emitConst g.ilg.typ_Byte (mkLdcInt32 (int32 i)) + | Const.UInt16 i -> emitAndBoxIfNeeded emitConst g.ilg.typ_UInt16 (mkLdcInt32 (int32 i)) + | Const.UInt32 i -> emitAndBoxIfNeeded emitConst g.ilg.typ_UInt32 (mkLdcInt32 (int32 i)) + | Const.UInt64 i -> emitAndBoxIfNeeded emitInt64Constant g.ilg.typ_UInt64 (int64 i) + | Const.UIntPtr i -> emitAndBoxIfNeeded emitConstI g.ilg.typ_UIntPtr [ iLdcInt64 (int64 i); AI_conv DT_U ] + | Const.Double f -> emitAndBoxIfNeeded emitConst g.ilg.typ_Double (AI_ldc(DT_R8, ILConst.R8 f)) + | Const.Single f -> emitAndBoxIfNeeded emitConst g.ilg.typ_Single (AI_ldc(DT_R4, ILConst.R4 f)) + | Const.Char c -> emitAndBoxIfNeeded emitConst g.ilg.typ_Char (mkLdcInt32 (int c)) | Const.String s -> GenString cenv cgbuf s | Const.Unit -> GenUnit cenv eenv m cgbuf | Const.Zero -> GenDefaultValue cenv cgbuf eenv (ty, m) @@ -3491,7 +3520,6 @@ and GenLinearExpr cenv cgbuf eenv expr sequel preSteps (contf: FakeUnit -> FakeU if preSteps && GenExprPreSteps cenv cgbuf eenv expr sequel then contf Fake else - // This case implemented here to get a guaranteed tailcall // Make sure we generate the debug point outside the scope of the variable let startMark, endMark as scopeMarks = StartDelayedLocalScope "let" cgbuf @@ -4509,6 +4537,7 @@ and CanTailcall // Can't tailcall with a .NET 2.0 generic constrained call since it involves a byref // Can't tailcall when there are pinned locals since the stack frame must remain alive let hasPinnedLocals = cgbuf.HasPinnedLocals() + let hasStackAllocatedLocals = cgbuf.HasStackAllocatedLocals() if not hasStructObjArg @@ -4519,6 +4548,7 @@ and CanTailcall && not isSelfInit && not makesNoCriticalTailcalls && not hasPinnedLocals + && not hasStackAllocatedLocals && // 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. @@ -4739,6 +4769,31 @@ and GenIndirectCall cenv cgbuf eenv (funcTy, tyargs, curriedArgs, m) sequel = // Generate try expressions //-------------------------------------------------------------------------- +/// Emit IL to cast a caught object to Exception, wrapping non-Exception objects +/// in RuntimeWrappedException. +and EmitCastOrWrapNonExceptionThrow (cenv: cenv) (cgbuf: CodeGenBuffer) = + let g = cenv.g + let iltyp_RuntimeWrappedException = g.iltyp_RuntimeWrappedException + + let tempLocal = cgbuf.AllocLocal([], g.ilg.typ_Object, false, true) |> uint16 + let afterWrap = CG.GenerateDelayMark cgbuf "afterWrap" + + CG.EmitInstr cgbuf (pop 1) Push0 (I_stloc tempLocal) + CG.EmitInstr cgbuf (pop 0) (Push [ g.ilg.typ_Object ]) (I_ldloc tempLocal) + CG.EmitInstr cgbuf (pop 1) (Push [ g.iltyp_Exception ]) (I_isinst g.iltyp_Exception) + CG.EmitInstr cgbuf (pop 0) (Push [ g.iltyp_Exception ]) AI_dup + CG.EmitInstr cgbuf (pop 1) Push0 (I_brcmp(BI_brtrue, afterWrap.CodeLabel)) + + CG.EmitInstr cgbuf (pop 1) Push0 AI_pop + CG.EmitInstr cgbuf (pop 0) (Push [ g.ilg.typ_Object ]) (I_ldloc tempLocal) + + let rweCtorSpec = + mkILCtorMethSpecForTy (iltyp_RuntimeWrappedException, [ g.ilg.typ_Object ]) + + CG.EmitInstr cgbuf (pop 1) (Push [ iltyp_RuntimeWrappedException ]) (I_newobj(rweCtorSpec, None)) + + CG.SetMarkToHere cgbuf afterWrap + and GenTry cenv cgbuf eenv scopeMarks (e1, m, resultTy, spTry) = let g = cenv.g @@ -4884,7 +4939,7 @@ and GenTryWith cenv cgbuf eenv (e1, valForFilter: Val, filterExpr, valForHandler let _, eenvinner = AllocLocalVal cenv cgbuf valForFilter eenvinner None (startOfFilter, afterFilter) - CG.EmitInstr cgbuf (pop 1) (Push [ g.iltyp_Exception ]) (I_castclass g.iltyp_Exception) + EmitCastOrWrapNonExceptionThrow cenv cgbuf GenStoreVal cgbuf eenvinner valForFilter.Range valForFilter @@ -4905,7 +4960,7 @@ and GenTryWith cenv cgbuf eenv (e1, valForFilter: Val, filterExpr, valForHandler let _, eenvinner = AllocLocalVal cenv cgbuf valForHandler eenvinner None (startOfHandler, afterHandler) - CG.EmitInstr cgbuf (pop 1) (Push [ g.iltyp_Exception ]) (I_castclass g.iltyp_Exception) + EmitCastOrWrapNonExceptionThrow cenv cgbuf GenStoreVal cgbuf eenvinner valForHandler.Range valForHandler let exitSequel = LeaveHandler(false, whereToSaveOpt, afterHandler, true) @@ -4926,7 +4981,7 @@ and GenTryWith cenv cgbuf eenv (e1, valForFilter: Val, filterExpr, valForHandler let _, eenvinner = AllocLocalVal cenv cgbuf valForHandler eenvinner None (startOfHandler, afterHandler) - CG.EmitInstr cgbuf (pop 1) (Push [ g.iltyp_Exception ]) (I_castclass g.iltyp_Exception) + EmitCastOrWrapNonExceptionThrow cenv cgbuf GenStoreVal cgbuf eenvinner m valForHandler @@ -5423,6 +5478,7 @@ and GenILCall (virt, valu, newobj, valUseFlags, isDllImport, ilMethRef: ILMethodRef, enclArgTys, methArgTys, argExprs, returnTys, m) sequel = + let g = cenv.g let hasByrefArg = ilMethRef.ArgTypes |> List.exists IsILTypeByref let isSuperInit = @@ -5445,6 +5501,24 @@ and GenILCall let makesNoCriticalTailcalls = (newobj || not virt) // Don't tailcall for 'newobj', or 'call' to IL code let hasStructObjArg = valu && ilMethRef.CallingConv.IsInstance + let ilEnclArgTys = GenTypeArgs cenv m eenv.tyenv enclArgTys + let ilMethArgTys = GenTypeArgs cenv m eenv.tyenv methArgTys + let ilReturnTys = GenTypes cenv m eenv.tyenv returnTys + let ilMethSpec = mkILMethSpec (ilMethRef, boxity, ilEnclArgTys, ilMethArgTys) + + let useICallVirt = + (virt || useCallVirt cenv boxity ilMethSpec isBaseCall) + && ilMethRef.CallingConv.IsInstance + + let ccallInfo = + ccallInfo + |> Option.orElseWith (fun () -> + match argExprs with + | objArgExpr :: _ when useICallVirt -> + let objArgTy = tyOfExpr g objArgExpr + if isStructTy g objArgTy then Some objArgTy else None + | _ -> None) + let tail = CanTailcall( hasStructObjArg, @@ -5459,15 +5533,6 @@ and GenILCall sequel ) - let ilEnclArgTys = GenTypeArgs cenv m eenv.tyenv enclArgTys - let ilMethArgTys = GenTypeArgs cenv m eenv.tyenv methArgTys - let ilReturnTys = GenTypes cenv m eenv.tyenv returnTys - let ilMethSpec = mkILMethSpec (ilMethRef, boxity, ilEnclArgTys, ilMethArgTys) - - let useICallVirt = - (virt || useCallVirt cenv boxity ilMethSpec isBaseCall) - && ilMethRef.CallingConv.IsInstance - // Load the 'this' pointer to pass to the superclass constructor. This argument is not // in the expression tree since it can't be treated like an ordinary value if isSuperInit then @@ -5840,6 +5905,29 @@ and GenFormalReturnType m cenv eenvFormal returnTy : ILReturn = and instSlotParam inst (TSlotParam(nm, ty, inFlag, fl2, fl3, attrs)) = TSlotParam(nm, instType inst ty, inFlag, fl2, fl3, attrs) +/// Check if a type contains nativeptr with a type parameter from the given set. +and containsNativePtrWithTypar (g: TcGlobals) (typars: Typar list) ty = + let rec check ty = + let ty = stripTyEqns g ty + + match ty with + | TType_app(tcref, tinst, _) when tyconRefEq g g.nativeptr_tcr tcref -> + tinst + |> List.exists (fun t -> + match stripTyEqns g t with + | TType_var(tp, _) -> typars |> List.exists (fun tp2 -> tp.Stamp = tp2.Stamp) + | _ -> false) + | TType_app(_, tinst, _) -> tinst |> List.exists check + | TType_fun(d, r, _) -> check d || check r + | TType_tuple(_, tys) -> tys |> List.exists check + | TType_anon(_, tys) -> tys |> List.exists check + | TType_forall(_, t) -> check t + | TType_var _ -> false + | TType_measure _ -> false + | TType_ucase _ -> false + + check ty + and GenActualSlotsig m cenv @@ -5848,14 +5936,33 @@ and GenActualSlotsig methTyparsOfOverridingMethod (methodParams: Val list) = + let g = cenv.g let ilSlotParams = List.concat ilSlotParams + let interfaceTypeArgs = argsOfAppTy g ty + let instForSlotSig = - mkTyparInst (ctps @ mtps) (argsOfAppTy cenv.g ty @ generalizeTypars methTyparsOfOverridingMethod) + mkTyparInst (ctps @ mtps) (interfaceTypeArgs @ generalizeTypars methTyparsOfOverridingMethod) + + let interfaceTypeArgsAreConcrete = + not ctps.IsEmpty + && (freeInTypes CollectTypars interfaceTypeArgs).FreeTypars.IsEmpty + + let slotHasNativePtrWithCtps = + interfaceTypeArgsAreConcrete + && (ilSlotParams + |> List.exists (fun (TSlotParam(_, ty, _, _, _, _)) -> containsNativePtrWithTypar g ctps ty) + || ilSlotRetTy |> Option.exists (containsNativePtrWithTypar g ctps)) + + let eenvForSlotGen = + if slotHasNativePtrWithCtps then + EnvForTypars ctps eenv + else + eenv let ilParams = ilSlotParams - |> List.map (instSlotParam instForSlotSig >> GenSlotParam m cenv eenv) + |> List.map (instSlotParam instForSlotSig >> GenSlotParam m cenv eenvForSlotGen) // Use the better names if available let ilParams = @@ -5866,7 +5973,7 @@ and GenActualSlotsig ilParams let ilRetTy = - GenReturnType cenv m eenv.tyenv (Option.map (instType instForSlotSig) ilSlotRetTy) + GenReturnType cenv m eenvForSlotGen.tyenv (Option.map (instType instForSlotSig) ilSlotRetTy) let iLRet = mkILReturn ilRetTy @@ -5874,7 +5981,7 @@ and GenActualSlotsig match ilSlotRetTy with | None -> iLRet | Some t -> - match GenAdditionalAttributesForTy cenv.g t with + match GenAdditionalAttributesForTy g t with | [] -> iLRet | attrs -> iLRet.WithCustomAttrs(mkILCustomAttrs attrs) @@ -6450,7 +6557,7 @@ and GenObjectExpr cenv cgbuf eenvouter objExpr (baseType, baseValOpt, basecall, GenWitnessArgsFromWitnessInfos cenv cgbuf eenvouter m cloinfo.cloWitnessInfos for fv in cloinfo.cloFreeVars do - GenGetLocalVal cenv cgbuf eenvouter m fv None + GenGetFreeVarForClosure cenv cgbuf eenvouter m fv CG.EmitInstr cgbuf @@ -6541,7 +6648,7 @@ and GenSequenceExpr if stateVarsSet.Contains fv then GenDefaultValue cenv cgbuf eenv (fv.Type, m) else - GenGetLocalVal cenv cgbuf eenv m fv None + GenGetFreeVarForClosure cenv cgbuf eenv m fv CG.EmitInstr cgbuf @@ -6653,7 +6760,7 @@ and GenSequenceExpr if stateVarsSet.Contains fv then GenDefaultValue cenv cgbuf eenvouter (fv.Type, m) else - GenGetLocalVal cenv cgbuf eenvouter m fv None + GenGetFreeVarForClosure cenv cgbuf eenvouter m fv CG.EmitInstr cgbuf (pop ilCloAllFreeVars.Length) (Push [ ilCloRetTyOuter ]) (I_newobj(ilxCloSpec.Constructor, None)) GenSequel cenv eenvouter.cloc cgbuf sequel @@ -6886,7 +6993,9 @@ and GenClosureAlloc cenv (cgbuf: CodeGenBuffer) eenv (cloinfo, m) = CG.EmitInstr cgbuf (pop 0) (Push [ EraseClosures.mkTyOfLambdas cenv.ilxPubCloEnv cloinfo.ilCloLambdas ]) (mkNormalLdsfld fspec) else GenWitnessArgsFromWitnessInfos cenv cgbuf eenv m cloinfo.cloWitnessInfos - GenGetLocalVals cenv cgbuf eenv m cloinfo.cloFreeVars + + for fv in cloinfo.cloFreeVars do + GenGetFreeVarForClosure cenv cgbuf eenv m fv CG.EmitInstr cgbuf @@ -6901,6 +7010,12 @@ and GenLambda cenv cgbuf eenv isLocalTypeFunc thisVars expr sequel = and GenTypeOfVal cenv eenv (v: Val) = GenType cenv v.Range eenv.tyenv v.Type +and capturedTypeForFreeVar (g: TcGlobals) (fv: Val) = + if isByrefTy g fv.Type then + destByrefTy g fv.Type + else + fv.Type + and GenFreevar cenv m eenvouter tyenvinner (fv: Val) = let g = cenv.g @@ -6915,7 +7030,7 @@ and GenFreevar cenv m eenvouter tyenvinner (fv: Val) = | Method _ | Null -> error (InternalError("GenFreevar: compiler error: unexpected unrealized value", fv.Range)) #endif - | _ -> GenType cenv m tyenvinner fv.Type + | _ -> GenType cenv m tyenvinner (capturedTypeForFreeVar g fv) and GetIlxClosureFreeVars cenv m (thisVars: ValRef list) boxity eenv takenNames expr = let g = cenv.g @@ -7276,7 +7391,9 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, IlxClosureSpec.Create(IlxClosureRef(ilDelegeeTypeRef, ilCloLambdas, ilCloAllFreeVars), ctxtGenericArgsForDelegee, false) GenWitnessArgsFromWitnessInfos cenv cgbuf eenvouter m cloWitnessInfos - GenGetLocalVals cenv cgbuf eenvouter m cloFreeVars + + for fv in cloFreeVars do + GenGetFreeVarForClosure cenv cgbuf eenvouter m fv CG.EmitInstr cgbuf @@ -8206,6 +8323,17 @@ and GenLetRecFixup cenv cgbuf eenv (ilxCloSpec: IlxClosureSpec, e, ilField: ILFi GenExpr cenv cgbuf eenv e2 Continue CG.EmitInstr cgbuf (pop 2) Push0 (mkNormalStfld (mkILFieldSpec (ilField.FieldRef, ilxCloSpec.ILType))) +and isLambdaBinding (TBind(_, expr, _)) = + match stripDebugPoints expr with + | Expr.Lambda _ + | Expr.TyLambda _ + | Expr.Obj _ -> true + | _ -> false + +and reorderBindingsLambdasFirst binds = + let lambdas, nonLambdas = binds |> List.partition isLambdaBinding + lambdas @ nonLambdas + /// Generate letrec bindings and GenLetRecBindings cenv (cgbuf: CodeGenBuffer) eenv (allBinds: Bindings, m) (dict: Dictionary option) = @@ -8299,8 +8427,11 @@ and GenLetRecBindings cenv (cgbuf: CodeGenBuffer) eenv (allBinds: Bindings, m) ( let recursiveVars = Zset.addList (bindsPossiblyRequiringFixup |> List.map (fun v -> v.Var)) (Zset.empty valOrder) + let reorderedBindsPossiblyRequiringFixup = + reorderBindingsLambdasFirst bindsPossiblyRequiringFixup + let _ = - (recursiveVars, bindsPossiblyRequiringFixup) + (recursiveVars, reorderedBindsPossiblyRequiringFixup) ||> List.fold (fun forwardReferenceSet (bind: Binding) -> // Compute fixups bind.Expr @@ -8344,6 +8475,8 @@ and GenLetRecBindings cenv (cgbuf: CodeGenBuffer) eenv (allBinds: Bindings, m) ( let _ = (recursiveVars, groupBinds) ||> List.fold (fun forwardReferenceSet (binds: Binding list) -> + let binds = reorderBindingsLambdasFirst binds + match dict, cenv.g.realsig, binds with | _, false, _ | None, _, _ @@ -8380,8 +8513,11 @@ and GenLetRecBindings cenv (cgbuf: CodeGenBuffer) eenv (allBinds: Bindings, m) ( and GenLetRec cenv cgbuf eenv (binds, body, m) sequel = let _, endMark as scopeMarks = StartLocalScope "letrec" cgbuf - let eenv = AllocStorageForBinds cenv cgbuf scopeMarks eenv binds - GenLetRecBindings cenv cgbuf eenv (binds, m) None + + let reorderedBinds = reorderBindingsLambdasFirst binds + + let eenv = AllocStorageForBinds cenv cgbuf scopeMarks eenv reorderedBinds + GenLetRecBindings cenv cgbuf eenv (reorderedBinds, m) None GenExpr cenv cgbuf eenv body (EndLocalScope(sequel, endMark)) //------------------------------------------------------------------------- @@ -8975,6 +9111,7 @@ and GenParams (argInfos: ArgReprInfo list) methArgTys (implValsOpt: Val list option) + (slotSigParamFlags: SlotParamFlags list option) = let g = cenv.g let ilWitnessParams = GenWitnessParams cenv eenv m witnessInfos @@ -8993,11 +9130,18 @@ and GenParams | _ -> List.map (fun x -> x, None) ilArgTysAndInfos let ilParams, _ = - (Set.empty, List.zip methArgTys ilArgTysAndInfoAndVals) - ||> List.mapFold (fun takenNames (methodArgTy, ((ilArgTy, topArgInfo), implValOpt)) -> + ((Set.empty, 0), List.zip methArgTys ilArgTysAndInfoAndVals) + ||> List.mapFold (fun (takenNames, paramIdx) (methodArgTy, ((ilArgTy, topArgInfo), implValOpt)) -> let inFlag, outFlag, optionalFlag, defaultParamValue, Marshal, attribs = GenParamAttribs cenv methodArgTy topArgInfo.Attribs + let inFlag, outFlag = + match slotSigParamFlags with + | Some flags when paramIdx < flags.Length -> + let slotFlags = flags[paramIdx] + (inFlag || slotFlags.IsIn, outFlag || slotFlags.IsOut) + | _ -> (inFlag, outFlag) + let idOpt = match topArgInfo.Name with | Some v -> Some v @@ -9036,7 +9180,7 @@ and GenParams MetadataIndex = NoMetadataIdx } - param, takenNames) + param, (takenNames, paramIdx + 1)) ilWitnessParams @ ilParams @@ -9389,8 +9533,18 @@ and GenMethodForBinding let ilTypars = GenGenericParams cenv eenvUnderMethLambdaTypars methLambdaTypars + let slotSigParamFlags = + match v.ImplementedSlotSigs with + | slotsig :: _ -> + let slotParams = slotsig.FormalParams |> List.concat + + slotParams + |> List.map (fun (TSlotParam(_, _, inFlag, outFlag, _, _)) -> { IsIn = inFlag; IsOut = outFlag }) + |> Some + | [] -> None + let ilParams = - GenParams cenv eenvUnderMethTypeTypars m mspec witnessInfos paramInfos argTys (Some nonUnitNonSelfMethodVars) + GenParams cenv eenvUnderMethTypeTypars m mspec witnessInfos paramInfos argTys (Some nonUnitNonSelfMethodVars) slotSigParamFlags let ilReturn = GenReturnInfo cenv eenvUnderMethTypeTypars (Some returnTy) mspec.FormalReturnType retInfo @@ -9850,8 +10004,14 @@ and GenGetStorageAndSequel (cenv: cenv) cgbuf eenv m (ty, ilTy) storage storeSeq CG.EmitInstrs cgbuf (pop 0) (Push [ ilTy ]) [ mkLdarg0; mkNormalLdfld ilField ] CommitGetStorageSequel cenv cgbuf eenv m ty localCloInfo storeSequel -and GenGetLocalVals cenv cgbuf eenvouter m fvs = - List.iter (fun v -> GenGetLocalVal cenv cgbuf eenvouter m v None) fvs +/// Load free variables for closure capture, dereferencing byrefs. +and GenGetFreeVarForClosure cenv cgbuf eenv m (fv: Val) = + let g = cenv.g + GenGetLocalVal cenv cgbuf eenv m fv None + + if isByrefTy g fv.Type then + let ilUnderlyingTy = GenType cenv m eenv.tyenv (capturedTypeForFreeVar g fv) + CG.EmitInstr cgbuf (pop 1) (Push [ ilUnderlyingTy ]) (mkNormalLdobj ilUnderlyingTy) and GenGetLocalVal cenv cgbuf eenv m (vspec: Val) storeSequel = GenGetStorageAndSequel cenv cgbuf eenv m (vspec.Type, GenTypeOfVal cenv eenv vspec) (StorageForVal m vspec eenv) storeSequel @@ -9979,6 +10139,7 @@ and AllocValReprWithinExpr cenv cgbuf endMark cloc v eenv = // Don't use shadow locals for things like functions which are not compiled as static values/properties && (not eenv.realsig) && IsCompiledAsStaticProperty cenv.g v + && Option.isNone v.LiteralValue let optShadowLocal, eenv = if useShadowLocal then @@ -10720,7 +10881,7 @@ and GenAbstractBinding cenv eenv tref (vref: ValRef) = let ilReturn = GenReturnInfo cenv eenvForMeth returnTy mspec.FormalReturnType retInfo - let ilParams = GenParams cenv eenvForMeth m mspec [] argInfos methArgTys None + let ilParams = GenParams cenv eenvForMeth m mspec [] argInfos methArgTys None None let compileAsInstance = ValRefIsCompiledAsInstanceMember g vref @@ -10750,6 +10911,12 @@ and GenAbstractBinding cenv eenv tref (vref: ValRef) = | SynMemberKind.Constructor | SynMemberKind.Member -> let mdef = mdef.With(customAttrs = mkILCustomAttrs ilAttrs) + let mdef = + if vref.Deref.val_flags.IsGeneratedEventVal then + mdef.WithSpecialName + else + mdef + [ mdef ], [], [] | SynMemberKind.PropertyGetSet -> error (Error(FSComp.SR.ilUnexpectedGetSetAnnotation (), m)) | SynMemberKind.PropertySet @@ -11768,6 +11935,17 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option // // Also discard the F#-compiler supplied implementation of the Empty, IsEmpty, Value and None properties. + let nullaryCaseNames = + if cuinfo.HasHelpers = AllHelpers || cuinfo.HasHelpers = NoHelpers then + cuinfo.UnionCases + |> Array.choose (fun alt -> if alt.IsNullary then Some alt.Name else None) + |> Set.ofArray + else + Set.empty + + let isNullaryCaseClash name = + not nullaryCaseNames.IsEmpty && nullaryCaseNames.Contains name + let tdefDiscards = Some( (fun (md: ILMethodDef) -> @@ -11776,7 +11954,11 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option || (cuinfo.HasHelpers = SpecialFSharpOptionHelpers && (md.Name = "get_Value" || md.Name = "get_None" || md.Name = "Some")) || (cuinfo.HasHelpers = AllHelpers - && (md.Name.StartsWith("get_Is") && not (tdef2.Methods.FindByName(md.Name).IsEmpty)))), + && (md.Name.StartsWith("get_Is") && not (tdef2.Methods.FindByName(md.Name).IsEmpty))) + || (md.Name.StartsWith("get_") + && md.Name.Length > 4 + && isNullaryCaseClash (md.Name.Substring(4)) + && not (tdef2.Methods.FindByName(md.Name).IsEmpty))), (fun (pd: ILPropertyDef) -> (cuinfo.HasHelpers = SpecialFSharpListHelpers @@ -11784,7 +11966,9 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option || (cuinfo.HasHelpers = SpecialFSharpOptionHelpers && (pd.Name = "Value" || pd.Name = "None")) || (cuinfo.HasHelpers = AllHelpers - && (pd.Name.StartsWith("Is") && not (tdef2.Properties.LookupByName(pd.Name).IsEmpty)))) + && (pd.Name.StartsWith("Is") && not (tdef2.Properties.LookupByName(pd.Name).IsEmpty))) + || (isNullaryCaseClash pd.Name + && not (tdef2.Properties.LookupByName(pd.Name).IsEmpty))) ) tdef2, tdefDiscards @@ -11908,6 +12092,49 @@ and GenExnDef cenv mgbuf eenv m (exnc: Tycon) : ILTypeRef option = match g.iltyp_SerializationInfo, g.iltyp_StreamingContext with | Some serializationInfoType, Some streamingContextType -> + let emitSerializationFieldIL emitPerField = + [ + for (ilPropName, ilFieldName, ilPropType, _) in fieldNamesAndTypes do + yield! emitPerField ilPropName ilFieldName ilPropType + ] + + let isILValueType (ty: ILType) = + ty.IsNominal && ty.Boxity = ILBoxity.AsValue + + let ilInstrsToRestoreFields = + emitSerializationFieldIL (fun ilPropName ilFieldName ilPropType -> + [ + mkLdarg0 + mkLdarg 1us + I_ldstr ilPropName + I_ldtoken(ILToken.ILType ilPropType) + + mkNormalCall ( + mkILNonGenericStaticMethSpecInTy ( + g.ilg.typ_Type, + "GetTypeFromHandle", + [ g.iltyp_RuntimeTypeHandle ], + g.ilg.typ_Type + ) + ) + + mkNormalCallvirt ( + mkILNonGenericInstanceMethSpecInTy ( + serializationInfoType, + "GetValue", + [ g.ilg.typ_String; g.ilg.typ_Type ], + g.ilg.typ_Object + ) + ) + + if isILValueType ilPropType then + I_unbox_any ilPropType + else + I_castclass ilPropType + + mkNormalStfld (mkILFieldSpecInTy (ilThisTy, ilFieldName, ilPropType)) + ]) + let ilInstrsForSerialization = [ mkLdarg0 @@ -11915,6 +12142,7 @@ and GenExnDef cenv mgbuf eenv m (exnc: Tycon) : ILTypeRef option = mkLdarg 2us mkNormalCall (mkILCtorMethSpecForTy (g.iltyp_Exception, [ serializationInfoType; streamingContextType ])) ] + @ ilInstrsToRestoreFields |> nonBranchingInstrsToCode let ilCtorDefForSerialization = @@ -11927,7 +12155,57 @@ and GenExnDef cenv mgbuf eenv m (exnc: Tycon) : ILTypeRef option = mkMethodBody (false, [], 8, ilInstrsForSerialization, None, eenv.imports) ) - [ ilCtorDefForSerialization ] + let ilInstrsToSaveFields = + emitSerializationFieldIL (fun ilPropName ilFieldName ilPropType -> + [ + mkLdarg 1us + I_ldstr ilPropName + mkLdarg0 + mkNormalLdfld (mkILFieldSpecInTy (ilThisTy, ilFieldName, ilPropType)) + + if isILValueType ilPropType then + I_box ilPropType + + mkNormalCallvirt ( + mkILNonGenericInstanceMethSpecInTy ( + serializationInfoType, + "AddValue", + [ g.ilg.typ_String; g.ilg.typ_Object ], + ILType.Void + ) + ) + ]) + + let ilInstrsForGetObjectData = + [ + mkLdarg0 + mkLdarg 1us + mkLdarg 2us + mkNormalCall ( + mkILNonGenericInstanceMethSpecInTy ( + g.iltyp_Exception, + "GetObjectData", + [ serializationInfoType; streamingContextType ], + ILType.Void + ) + ) + ] + @ ilInstrsToSaveFields + |> nonBranchingInstrsToCode + + let ilGetObjectDataDef = + mkILNonGenericVirtualInstanceMethod ( + "GetObjectData", + ILMemberAccess.Public, + [ + mkILParamNamed ("info", serializationInfoType) + mkILParamNamed ("context", streamingContextType) + ], + mkILReturn ILType.Void, + mkMethodBody (false, [], 8, ilInstrsForGetObjectData, None, eenv.imports) + ) + + [ ilCtorDefForSerialization; ilGetObjectDataDef ] | _ -> [] let ilTypeName = tref.Name diff --git a/src/Compiler/TypedTree/TcGlobals.fs b/src/Compiler/TypedTree/TcGlobals.fs index 3e0bdfd0905..12b88cbc193 100644 --- a/src/Compiler/TypedTree/TcGlobals.fs +++ b/src/Compiler/TypedTree/TcGlobals.fs @@ -128,6 +128,8 @@ let tname_IComparable = "System.IComparable" [] let tname_Exception = "System.Exception" [] +let tname_RuntimeWrappedException = "System.Runtime.CompilerServices.RuntimeWrappedException" +[] let tname_Missing = "System.Reflection.Missing" [] let tname_FormattableString = "System.FormattableString" @@ -1454,6 +1456,7 @@ type TcGlobals( member val iltyp_IAsyncResult = findSysILTypeRef tname_IAsyncResult |> mkILNonGenericBoxedTy member val iltyp_IComparable = findSysILTypeRef tname_IComparable |> mkILNonGenericBoxedTy member val iltyp_Exception = findSysILTypeRef tname_Exception |> mkILNonGenericBoxedTy + member val iltyp_RuntimeWrappedException = findSysILTypeRef tname_RuntimeWrappedException |> mkILNonGenericBoxedTy member val iltyp_ValueType = findSysILTypeRef tname_ValueType |> mkILNonGenericBoxedTy member val iltyp_RuntimeFieldHandle = findSysILTypeRef tname_RuntimeFieldHandle |> mkILNonGenericValueTy member val iltyp_RuntimeMethodHandle = findSysILTypeRef tname_RuntimeMethodHandle |> mkILNonGenericValueTy diff --git a/src/Compiler/TypedTree/TcGlobals.fsi b/src/Compiler/TypedTree/TcGlobals.fsi index e69bc7b5e80..4f1608d32ef 100644 --- a/src/Compiler/TypedTree/TcGlobals.fsi +++ b/src/Compiler/TypedTree/TcGlobals.fsi @@ -750,6 +750,8 @@ type internal TcGlobals = member iltyp_Exception: FSharp.Compiler.AbstractIL.IL.ILType + member iltyp_RuntimeWrappedException: FSharp.Compiler.AbstractIL.IL.ILType + member iltyp_IAsyncResult: FSharp.Compiler.AbstractIL.IL.ILType member iltyp_IComparable: FSharp.Compiler.AbstractIL.IL.ILType diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/CodeGenRegressions/CodeGenRegressions.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/CodeGenRegressions/CodeGenRegressions.fs new file mode 100644 index 00000000000..8feddd2aeae --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/CodeGenRegressions/CodeGenRegressions.fs @@ -0,0 +1,1900 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace EmittedIL + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler +open FSharp.Test.Utilities + +module CodeGenRegressions = + + let private getActualIL (result: CompilationResult) = + match result with + | CompilationResult.Success s -> + match s.OutputPath with + | Some p -> + let (_, _, actualIL) = ILChecker.verifyILAndReturnActual [] p [ "// dummy" ] + actualIL + | None -> failwith "No output path" + | _ -> failwith "Compilation failed" + + // https://github.com/dotnet/fsharp/issues/19068 + [] + let ``Issue_19068_StructObjectExprByrefField`` () = + let source = """ +module Test + +type Class(test : obj) = class end + +[] +type Struct(test : obj) = + member _.Test() = { + new Class(test) with + member _.ToString() = "" + } + +let run() = + let s = Struct("hello") + s.Test() |> ignore + printfn "Success" + +run() +""" + FSharp source + |> asExe + |> ignoreWarnings + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/18956 + [] + let ``Issue_18956_DecimalConstantInvalidProgram`` () = + let source = """ +module A = + [] + let B = 42m + +[] +let main args = + printfn "%M" A.B + 0 +""" + FSharp source + |> asExe + |> withDebug + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/18953 + [] + let ``Issue_18953_ActionFuncCapturesExtraExpressions`` () = + let source = """ +module Test + +let mutable callCount = 0 + +let x (f: System.Action) = + f.Invoke 99 + f.Invoke 98 + +let y () = + callCount <- callCount + 1 + fun num -> printfn "%d" num + +x (y ()) + +if callCount <> 1 then + failwithf "Expected 1 call, got %d" callCount +""" + FSharp source + |> asExe + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/18868 + [] + let ``Issue_18868_CallerInfoInDelegates`` () = + let source = """ +module Test + +type A = delegate of [] ?a: string -> unit +type B = delegate of [] ?line: int -> unit +type C = delegate of [] ?name: string -> unit +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/18753 + [] + let ``Issue_18753_CEInliningPreventedByDU`` () = + let source = """ +module Test + +type IntOrString = + | I of int + | S of string + +type IntOrStringBuilder() = + member inline _.Zero() = ignore + member inline _.Yield(x: int) = fun (xs: ResizeArray) -> xs.Add(I x) + member inline _.Yield(x: string) = fun (xs: ResizeArray) -> xs.Add(S x) + member inline _.Yield(x: IntOrString) = fun (xs: ResizeArray) -> xs.Add(x) + member inline _.Run([] f: ResizeArray -> unit) = + let xs = ResizeArray() + f xs + xs + member inline _.Delay([] f: unit -> ResizeArray -> unit) = + fun (xs: ResizeArray) -> f () xs + member inline _.Combine + ( + [] f1: ResizeArray -> unit, + [] f2: ResizeArray -> unit + ) = + fun (xs: ResizeArray) -> + f1 xs + f2 xs + +let builder = IntOrStringBuilder() + +let test1 () = + builder { + 1 + "two" + 3 + "four" + } + +let test2 () = + builder { + I 1 + "two" + 3 + "four" + } + +""" + let actualIL = FSharp source |> asLibrary |> withOptimize |> compile |> shouldSucceed |> getActualIL + + Assert.Contains("test1", actualIL) + Assert.Contains("test2", actualIL) + + // https://github.com/dotnet/fsharp/issues/18672 + [] + let ``Issue_18672_ResumableCodeTopLevelValue`` () = + let source = """ +module Test + +let topLevelTask = task { return "result from top-level" } + +type Container() = + member val TaskInClass = task { return "result from class" } + +[] +let main _ = + let classResult = Container().TaskInClass.Result + let topLevelResult = topLevelTask.Result + + if topLevelResult <> "result from top-level" then + printfn "BUG: Top-level task returned: %A" topLevelResult + 1 + elif classResult <> "result from class" then + printfn "BUG: Class task returned: %A" classResult + 1 + else + printfn "SUCCESS: Both top-level and class state machines work correctly" + 0 +""" + FSharp source + |> asExe + |> withOptimize + |> compileExeAndRun + |> shouldSucceed + + // https://github.com/dotnet/fsharp/issues/18374 + [] + let ``Issue_18374_RuntimeWrappedExceptionCannotBeCaught`` () = + let source = """ +module Test + +open System + +[] +let main _ = + let mutable caught1 = false + try + raise (InvalidOperationException("test")) + with + | e -> caught1 <- true + + if not caught1 then failwith "Normal exception not caught" + + let mutable caught2 = false + try + raise (ArgumentException("test")) + with + | :? ArgumentException as ae -> caught2 <- true + | e -> failwith "Wrong exception type caught" + + if not caught2 then failwith "Specific exception not caught" + + let rweType = typeof + if rweType = null then failwith "RuntimeWrappedException type not found" + + printfn "All exception tests passed" + 0 +""" + FSharp source + |> asExe + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/18374 + // Tests that non-Exception objects thrown from IL are wrapped in RuntimeWrappedException + [] + let ``Issue_18374_RuntimeWrappedExceptionNonExceptionThrow`` () = + let csCode = """ +using System; +using System.Reflection; +using System.Reflection.Emit; + +namespace CSharpHelper { + public static class NonExceptionThrower { + public static Action CreateStringThrower() { + var dm = new DynamicMethod("ThrowString", typeof(void), Type.EmptyTypes); + var il = dm.GetILGenerator(); + il.Emit(OpCodes.Ldstr, "non-exception payload"); + il.Emit(OpCodes.Throw); + il.Emit(OpCodes.Ret); + return (Action)dm.CreateDelegate(typeof(Action)); + } + } +}""" + let csLib = CSharp csCode |> withName "CSharpHelper" + let fsCode = """ +module Test +open System.Runtime.CompilerServices + +[] +let main _ = + let thrower = CSharpHelper.NonExceptionThrower.CreateStringThrower() + let mutable caught = false + try + thrower.Invoke() + with + | :? RuntimeWrappedException as rwe -> + caught <- true + let payload = rwe.WrappedException :?> string + if payload <> "non-exception payload" then + failwithf "Wrong payload: %s" payload + | e -> + caught <- true + printfn "Caught as %s: %s" (e.GetType().Name) e.Message + + if not caught then failwith "Non-exception throw was not caught" + printfn "SUCCESS: Non-exception throw caught correctly" + 0 +""" + FSharp fsCode + |> withReferences [csLib] + |> asExe + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/18374 + [] + let ``Issue_18374_RuntimeWrappedExceptionIL`` () = + let source = """ +module Test +let catchAll () = + try + failwith "test" + with + | e -> e.Message +""" + let actualIL = FSharp source |> asLibrary |> compile |> shouldSucceed |> getActualIL + Assert.Contains("isinst", actualIL) + Assert.DoesNotContain("castclass", actualIL) + + // https://github.com/dotnet/fsharp/issues/18319 + [] + let ``Issue_18319_LiteralUpcastMissingBox`` () = + let source = """ +module Test + +[] +let badobj: System.ValueType = 1 + +[] +let main _ = + System.Console.WriteLine(badobj) + 0 +""" + FSharp source + |> asExe + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/18263 + [] + let ``Issue_18263_DUIsPropertiesDuplicateMethod`` () = + let source = """ +namespace FSharpClassLibrary + +module Say = + let hello name = + printfn "Hello %s" name + + type Foo = + | SZ + | STZ + | ZS + | ASZ +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/18140 + [] + let ``Issue_18140_CallvirtOnValueType`` () = + let source = """ +module Test + +[] +type MyRange = + val Value: int + new(v) = { Value = v } + +let comparer = + { new System.Collections.Generic.IEqualityComparer with + member _.Equals(x1, x2) = x1.Value = x2.Value + member _.GetHashCode o = o.GetHashCode() + } + +let test() = + let s = MyRange(42) + comparer.GetHashCode(s) +""" + let actualIL = + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> getActualIL + + Assert.Contains("constrained.", actualIL) + + // https://github.com/dotnet/fsharp/issues/18135 + [] + let ``Issue_18135_StaticAbstractByrefParams`` () = + let source = """ +module Test + +#nowarn "3535" + +[] +type I = + static abstract Foo: int inref -> int + +type T = + interface I with + static member Foo i = i + +let f<'T when 'T :> I>() = + let x = 123 + printfn "%d" ('T.Foo &x) + +[] +let main _ = + f() + 0 +""" + FSharp source + |> asExe + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/18125 + // Tests letrec lambda reordering: lambdas must be allocated before non-lambda bindings + // that reference them, to avoid null closure references in mutual recursion. + [] + let ``Issue_18125_LetRecLambdaReordering`` () = + let source = """ +module Test + +// Mutual recursion where lambdas reference record values and vice versa. +// The compiler must reorder bindings so closures are allocated before records that capture them. +[] +type Node = { Value: int; GetLabel: unit -> string } + +let test () = + let rec a = { Value = 1; GetLabel = labelA } + and b = { Value = 2; GetLabel = labelB } + and labelA () = sprintf "A(%d)->B(%d)" a.Value b.Value + and labelB () = sprintf "B(%d)->A(%d)" b.Value a.Value + + if a.GetLabel() <> "A(1)->B(2)" then failwithf "Expected A(1)->B(2), got %s" (a.GetLabel()) + if b.GetLabel() <> "B(2)->A(1)" then failwithf "Expected B(2)->A(1), got %s" (b.GetLabel()) + printfn "SUCCESS" + +[] +let main _ = + test() + 0 +""" + FSharp source + |> asExe + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/17692 + [] + let ``Issue_17692_MutualRecursionDuplicateParamName`` () = + let source = """ +module Test + +let rec caller x = callee (x - 1) +and callee y = if y > 0 then caller y else 0 + +let rec f1 a = f2 (a - 1) + f3 (a - 2) +and f2 b = if b > 0 then f1 b else 1 +and f3 c = if c > 0 then f2 c else 2 + +let result1 = caller 5 +let result2 = f1 5 +printfn "Results: %d %d" result1 result2 +""" + FSharp source + |> asExe + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/17641 + [] + let ``Issue_17641_IsMethodIsPropertyIncorrectForGenerated`` () = + let source = """ +module Test + +type MyUnion = + | CaseA of int + | CaseB of string + +let x = CaseA 1 +let isA = match x with CaseA _ -> true | _ -> false +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/16565 + [] + let ``Issue_16565_DefaultAugmentationFalseDuplicateEntry`` () = + let source = """ +module Test + +open System + +[] +type Option<'T> = + | Some of Value: 'T + | None + + member x.Value = + match x with + | Some x -> x + | None -> raise (new InvalidOperationException("Option.Value")) + + static member None : Option<'T> = None + +and 'T option = Option<'T> +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/16378 + [] + let ``Issue_16378_DULoggingAllocations`` () = + let source = """ +module Test + +open System + +[] +type StoreError = + | Exception of exn + | ErrorDuringReadingChannelFromDatabase of channel: string + | AlreadyExists of Guid + | NotFound of Guid + member this.SerializeError(): obj = + match this with + | Exception ex -> ex + | ErrorDuringReadingChannelFromDatabase channel -> $"ErrorDuringReadingChannelFromDatabase: {channel}" + | AlreadyExists id -> $"AlreadyExists: {id}" + | NotFound id -> $"NotFound: {id}" + +let sampleNotFound = NotFound(Guid.NewGuid()) + +let logDirect() = + String.Format("Error: {0}", sampleNotFound) |> ignore + +let logSerialized() = + String.Format("Error: {0}", sampleNotFound.SerializeError()) |> ignore + +logDirect() +logSerialized() +printfn "Test completed" +""" + let actualIL = FSharp source |> asExe |> compile |> shouldSucceed |> getActualIL + + Assert.Contains("logDirect", actualIL) + Assert.Contains("logSerialized", actualIL) + Assert.Contains("box", actualIL) + + // https://github.com/dotnet/fsharp/issues/16245 + [] + let ``Issue_16245_SpanDoubleGetItem`` () = + let source = """ +module Test + +open System + +let incrementSpan (span: Span) = + for i = 0 to span.Length - 1 do + span[i] <- span[i] + 1uy + +let test() = + let arr = [| 1uy; 2uy; 3uy |] + incrementSpan (arr.AsSpan()) + printfn "%A" arr + +test() +""" + let actualIL = FSharp source |> asExe |> compile |> shouldSucceed |> getActualIL + + Assert.Contains("incrementSpan", actualIL) + Assert.Contains("get_Item", actualIL) + + // https://github.com/dotnet/fsharp/issues/16037 + [] + let ``Issue_16037_TuplePatternLambdaSuboptimal`` () = + let source = """ +module Test + +let data = Map.ofList [ + "1", (true, 1) + "2", (true, 2) +] + +let foldWithPattern () = + (data, []) + ||> Map.foldBack (fun _ (x, _) state -> x :: state) + +let foldWithFst () = + (data, []) + ||> Map.foldBack (fun _ v state -> fst v :: state) + +let foldWithPattern2 () = + (data, []) + ||> Map.foldBack (fun _ v state -> + let x, _ = v + x :: state) + +let test() = + let r1 = foldWithPattern() + let r2 = foldWithFst() + let r3 = foldWithPattern2() + printfn "Results: %A %A %A" r1 r2 r3 + +test() +""" + let actualIL = FSharp source |> asExe |> compile |> shouldSucceed |> getActualIL + + Assert.Contains("foldWithPattern", actualIL) + Assert.Contains("foldWithFst", actualIL) + Assert.Contains("FSharpFunc", actualIL) + + // https://github.com/dotnet/fsharp/issues/15627 + [] + let ``Issue_15627_AsyncBeforeEntryPointHangs`` () = + let source = """ +module Test + +open System.IO + +let deployPath = Path.GetFullPath "deploy" + +printfn "1" + +async { + printfn "2 %s" deployPath +} +|> Async.RunSynchronously + +printfn "After async" + +[] +let main args = + printfn "3" + 0 +""" + FSharp source + |> asExe + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/15467 + [] + let ``Issue_15467_LanguageVersionInMetadata`` () = + let source = """ +module Test + +type MyRecord = { Value: int } +let test = { Value = 42 } +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> ignore + + [] + let ``Issue_15352_ClosuresStillHaveCompilerGeneratedAttribute`` () = + let source = """ +module Test + +open System +open System.Reflection +open System.Runtime.CompilerServices + +let makeAdder x = + fun y -> x + y + +let adder5 = makeAdder 5 +printfn "Result: %d" (adder5 10) + +let testModule = + Assembly.GetExecutingAssembly().GetTypes() + |> Array.find (fun t -> t.Name = "Test") +let asm = testModule.Assembly + +let closureTypes = + asm.GetTypes() + |> Array.filter (fun t -> + t.FullName.Contains("@") && + t.IsClass && + not (t.Name.StartsWith("<"))) + +printfn "Found %d potential closure types" closureTypes.Length + +let markedClosures = + closureTypes + |> Array.filter (fun t -> t.GetCustomAttribute() <> null) + +for closureType in markedClosures do + printfn "OK: Type '%s' has CompilerGeneratedAttribute" closureType.FullName + +printfn "Closure check complete - found %d marked closure types" markedClosures.Length +""" + FSharp source + |> asExe + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + [] + let ``Issue_15352_UserPropertiesNoCompilerGeneratedAttribute`` () = + let source = """ +module Test + +open System +open System.Reflection +open System.Runtime.CompilerServices + +type MyClass() = + let mutable _value = 0 + + member _.Value + with get() = _value + and set(v) = _value <- v + + member val AutoProp = 42 with get, set + + member _.DoSomething() = printfn "Doing something" + +let checkProperties() = + let t = typeof + + let valueProp = t.GetProperty("Value") + if valueProp <> null then + let getter = valueProp.GetGetMethod() + if getter <> null then + let hasAttr = getter.GetCustomAttribute() <> null + if hasAttr then + failwith "Bug: User-defined property getter 'Value' has CompilerGeneratedAttribute" + else + printfn "OK: No CompilerGeneratedAttribute on user property getter 'Value'" + + let doMethod = t.GetMethod("DoSomething") + if doMethod <> null then + let hasAttr = doMethod.GetCustomAttribute() <> null + if hasAttr then + failwith "Bug: User-defined method 'DoSomething' has CompilerGeneratedAttribute" + else + printfn "OK: No CompilerGeneratedAttribute on user method 'DoSomething'" + else + failwith "Method 'DoSomething' not found" + +checkProperties() +""" + FSharp source + |> asExe + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/15326 + [] + let ``Issue_15326_InlineIfLambdaDelegateRegression`` () = + let source = """ +module Test + +open System + +type SystemAction<'a when 'a: struct and 'a :> IConvertible> = + delegate of byref<'a> -> unit + +let inline doAction (span: Span<'a>) ([] action: SystemAction<'a>) = + for i = 0 to span.Length - 1 do + let batch = &span[i] + action.Invoke &batch + +[] +let main args = + let array = Array.zeroCreate 100 + doAction (array.AsSpan()) (SystemAction(fun batch -> batch <- batch + 1)) + printfn "Sum: %d" (Array.sum array) + 0 +""" + let actualIL = FSharp source |> asExe |> withOptimize |> compile |> shouldSucceed |> getActualIL + + Assert.Contains("main", actualIL) + Assert.Contains("doAction", actualIL) + + // https://github.com/dotnet/fsharp/issues/15092 + [] + let ``Issue_15092_DebuggerProxiesInRelease`` () = + let source = """ +module Test + +type MyRecord = { Name: string; Value: int } +let result = { Name = "test"; Value = 42 } +""" + FSharp source + |> asExe + |> withOptimize + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/14712 + [] + let ``Issue_14712_SignatureFileTypeAlias`` () = + let source = """ +module Test + +let add (x:int) (y:int) = x + y + +let concat (a:string) (b:string) = a + b + +let isValid (b:bool) = b + +let multiply (x:float) (y:float) = x * y +""" + let signature = FSharp source |> printSignatures + + Assert.DoesNotContain("System.Int32", signature) + Assert.DoesNotContain("System.String", signature) + Assert.DoesNotContain("System.Boolean", signature) + Assert.DoesNotContain("System.Double", signature) + + Assert.Contains("val add: x: int -> y: int -> int", signature) + Assert.Contains("val concat: a: string -> b: string -> string", signature) + Assert.Contains("val isValid: b: bool -> bool", signature) + Assert.Contains("val multiply: x: float -> y: float -> float", signature) + + [] + let ``Issue_14712_SignatureFileTypeAlias_AllTypes`` () = + let source = """ +module Test + +let useInt (x:int) = x +let useInt16 (x:int16) = x +let useInt32 (x:int32) = x +let useInt64 (x:int64) = x +let useUint16 (x:uint16) = x +let useUint32 (x:uint32) = x +let useUint64 (x:uint64) = x +let useByte (x:byte) = x +let useSbyte (x:sbyte) = x +let useFloat (x:float) = x +let useFloat32 (x:float32) = x +let useDecimal (x:decimal) = x +let useChar (x:char) = x +let useNativeint (x:nativeint) = x +let useUnativeint (x:unativeint) = x + +let useString (x:string) = x +let useBool (x:bool) = x +let useUnit () = () +""" + let signature = FSharp source |> printSignatures + + Assert.DoesNotContain("System.Int16", signature) + Assert.DoesNotContain("System.Int32", signature) + Assert.DoesNotContain("System.Int64", signature) + Assert.DoesNotContain("System.UInt16", signature) + Assert.DoesNotContain("System.UInt32", signature) + Assert.DoesNotContain("System.UInt64", signature) + Assert.DoesNotContain("System.Byte", signature) + Assert.DoesNotContain("System.SByte", signature) + Assert.DoesNotContain("System.Double", signature) + Assert.DoesNotContain("System.Single", signature) + Assert.DoesNotContain("System.Decimal", signature) + Assert.DoesNotContain("System.Char", signature) + Assert.DoesNotContain("System.IntPtr", signature) + Assert.DoesNotContain("System.UIntPtr", signature) + Assert.DoesNotContain("System.String", signature) + Assert.DoesNotContain("System.Boolean", signature) + + Assert.Contains("val useInt: x: int -> int", signature) + Assert.Contains("val useInt16: x: int16 -> int16", signature) + Assert.Contains("val useInt32: x: int32 -> int32", signature) + Assert.Contains("val useInt64: x: int64 -> int64", signature) + Assert.Contains("val useUint16: x: uint16 -> uint16", signature) + Assert.Contains("val useUint32: x: uint32 -> uint32", signature) + Assert.Contains("val useUint64: x: uint64 -> uint64", signature) + Assert.Contains("val useByte: x: byte -> byte", signature) + Assert.Contains("val useSbyte: x: sbyte -> sbyte", signature) + Assert.Contains("val useFloat: x: float -> float", signature) + Assert.Contains("val useFloat32: x: float32 -> float32", signature) + Assert.Contains("val useDecimal: x: decimal -> decimal", signature) + Assert.Contains("val useChar: x: char -> char", signature) + Assert.Contains("val useNativeint: x: nativeint -> nativeint", signature) + Assert.Contains("val useUnativeint: x: unativeint -> unativeint", signature) + Assert.Contains("val useString: x: string -> string", signature) + Assert.Contains("val useBool: x: bool -> bool", signature) + Assert.Contains("val useUnit: unit -> unit", signature) + + [] + let ``Issue_14712_SignatureFileTypeAlias_NoAliasTypes`` () = + let source = """ +module Test + +open System + +let useGuid (x:Guid) = x +let useDateTime (x:DateTime) = x +let useTimeSpan (x:TimeSpan) = x +""" + let signature = FSharp source |> printSignatures + + Assert.Contains("Guid", signature) + Assert.Contains("DateTime", signature) + Assert.Contains("TimeSpan", signature) + + // https://github.com/dotnet/fsharp/issues/14706 + [] + let ``Issue_14706_SignatureWhereTypar`` () = + let source = """ +module Test + +type IProvider = interface end + +type Tainted<'T> = class end + +type ConstructB = + static member ComputeDefinitionLocationOfProvidedItem<'T when 'T :> IProvider>(p: Tainted<'T>) : obj option = None +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/14508 + [] + let ``Issue_14508_NativeptrInInterfaces_CompileOnly`` () = + let source = """ +module Test + +open Microsoft.FSharp.NativeInterop + +type IFoo<'T when 'T : unmanaged> = + abstract member Pointer : nativeptr<'T> + +type Broken() = + member x.Pointer : nativeptr = Unchecked.defaultof<_> + interface IFoo with + member x.Pointer = x.Pointer + +type Working<'T when 'T : unmanaged>() = + member x.Pointer : nativeptr<'T> = Unchecked.defaultof<_> + interface IFoo<'T> with + member x.Pointer = x.Pointer +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/14508 + [] + let ``Issue_14508_NativeptrInInterfaces_RuntimeWorking`` () = + let source = """ +open Microsoft.FSharp.NativeInterop + +type IFoo<'T when 'T : unmanaged> = + abstract member Pointer : nativeptr<'T> + +type Working<'T when 'T : unmanaged>() = + member x.Pointer : nativeptr<'T> = Unchecked.defaultof<_> + interface IFoo<'T> with + member x.Pointer = x.Pointer + +printfn "Working type loaded successfully" +""" + FSharp source + |> asExe + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/14492 + [] + let ``Issue_14492_ReleaseConfigError`` () = + let source = """ +module Test + +let inline refEquals<'a when 'a : not struct> (a : 'a) (b : 'a) = obj.ReferenceEquals (a, b) + +let inline tee f x = + f x + x + +let memoizeLatestRef (f: 'a -> 'b) = + let cell = ref None + let f' (x: 'a) = + match cell.Value with + | Some (x', value) when refEquals x' x -> value + | _ -> f x |> tee (fun y -> cell.Value <- Some (x, y)) + f' + +module BugInReleaseConfig = + let test f x = + printfn "%s" (f x) + + let f: string -> string = memoizeLatestRef id + + let run () = test f "ok" + +[] +let main _ = + BugInReleaseConfig.run () + 0 +""" + FSharp source + |> asExe + |> withOptimize + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/14392 + [] + let ``Issue_14392_OpenApiSupport`` () = + let source = """ +module Test + +type MyDto = { Name: string; Value: int } + +let dto = { Name = "test"; Value = 42 } +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/14321 + [] + let ``Issue_14321_DuAndIWSAMNames`` () = + let source = """ +module Test + +#nowarn "3535" // IWSAM warning + +type EngineError<'e> = + static abstract Overheated : 'e + static abstract LowOil : 'e + +type CarError = + | Overheated + | LowOil + | DeviceNotPaired + + interface EngineError with + static member Overheated = Overheated + static member LowOil = LowOil +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/14321 + // Runtime test: type must load without "duplicate entry in method table" + [] + let ``Issue_14321_DuAndIWSAMNames_Runtime`` () = + let source = """ +module Test + +#nowarn "3535" + +type EngineError<'e> = + static abstract Overheated : 'e + static abstract LowOil : 'e + +type CarError = + | Overheated + | LowOil + | DeviceNotPaired + + interface EngineError with + static member Overheated = Overheated + static member LowOil = LowOil + +[] +let main _ = + let err = CarError.Overheated + match err with + | Overheated -> printfn "Got Overheated" + | LowOil -> printfn "Got LowOil" + | DeviceNotPaired -> printfn "Got DeviceNotPaired" + 0 +""" + FSharp source + |> asExe + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/13468 + [] + let ``Issue_13468_OutrefAsByref_IL`` () = + let csCode = "namespace CSharpLib { public interface IOutTest { void TryGet(string k, out int v); } }" + let csLib = CSharp csCode |> withName "CSharpLib" + let fsCode = "module Test\nopen CSharpLib\ntype MyImpl() =\n interface IOutTest with\n member this.TryGet(k, v) = v <- 42" + let actualIL = + FSharp fsCode + |> withReferences [csLib] + |> asLibrary + |> compile + |> shouldSucceed + |> getActualIL + Assert.Contains("[out]", actualIL) + + // https://github.com/dotnet/fsharp/issues/13468 + [] + let ``Issue_13468_OutrefAsByref_Runtime`` () = + let csCode = """ +namespace CSharpLib { + public interface IOutTest { bool TryGet(string k, out int v); } + public static class OutTestHelper { + public static string Run(IOutTest impl) { + int v; + bool ok = impl.TryGet("key", out v); + return ok ? v.ToString() : "fail"; + } + } +}""" + let csLib = CSharp csCode |> withName "CSharpLib" + let fsCode = """ +module Test +open CSharpLib +type MyImpl() = + interface IOutTest with + member this.TryGet(k, v) = v <- 42; true + +[] +let main _ = + let result = OutTestHelper.Run(MyImpl()) + if result <> "42" then failwithf "Expected 42, got %s" result + printfn "Success: %s" result + 0 +""" + FSharp fsCode + |> withReferences [csLib] + |> asExe + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/13447 + [] + let ``Issue_13447_TailInstructionCorruption`` () = + let source = """ +module Test +open System +open Microsoft.FSharp.NativeInterop + +#nowarn "9" // Uses of this construct may result in the generation of unverifiable .NET IL code + +[] +type MyResult<'T, 'E> = + | Ok of value: 'T + | Error of error: 'E + +let useStackAlloc () : MyResult = + let ptr = NativePtr.stackalloc 100 + let span = Span(NativePtr.toVoidPtr ptr, 100) + span.[0] <- 42uy + Ok (int span.[0]) + +let test () = + match useStackAlloc () with + | Ok v -> v + | Error _ -> -1 +""" + let actualIL = + FSharp source + |> asLibrary + |> withOptimize + |> compile + |> shouldSucceed + |> getActualIL + + let useStackAllocIdx = actualIL.IndexOf("useStackAlloc") + Assert.True(useStackAllocIdx >= 0, "useStackAlloc method not found in IL") + let methodEnd = actualIL.IndexOf("\n } ", useStackAllocIdx) + let methodIL = if methodEnd > 0 then actualIL.Substring(useStackAllocIdx, methodEnd - useStackAllocIdx) else actualIL.Substring(useStackAllocIdx) + Assert.DoesNotContain("tail.", methodIL) + + // https://github.com/dotnet/fsharp/issues/13223 + [] + let ``Issue_13223_ReferenceAssemblies`` () = + let source = """ +module Test + +let f x = x + 1 +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/13108 + [] + let ``Issue_13108_StaticLinkingWarnings`` () = + let source = """ +module StaticLinkTest + +let value = List.iter (fun x -> printfn "%d" x) [1; 2; 3] + +[] +let main _ = 0 +""" + FSharp source + |> asExe + |> withOptions ["--standalone"] + |> compile + |> shouldSucceed + |> withDiagnostics [] + |> ignore + + // https://github.com/dotnet/fsharp/issues/13100 + [] + let ``Issue_13100_PlatformCharacteristic`` () = + let source = """ +module PlatformTest + +[] +let main _ = 0 +""" + FSharp source + |> asExe + |> withPlatform ExecutionPlatform.X64 + |> compile + |> shouldSucceed + |> withPeReader (fun rdr -> + let characteristics = rdr.PEHeaders.CoffHeader.Characteristics + if not (characteristics.HasFlag(System.Reflection.PortableExecutable.Characteristics.LargeAddressAware)) then + failwith $"x64 binary should have LargeAddressAware flag. Found: {characteristics}" + if characteristics.HasFlag(System.Reflection.PortableExecutable.Characteristics.Bit32Machine) then + failwith $"x64 binary should NOT have Bit32Machine flag. Found: {characteristics}") + |> ignore + + // https://github.com/dotnet/fsharp/issues/12546 + [] + let ``Issue_12546_BoxingClosure`` () = + let source = """ +module BoxingClosureTest + +let foo (ob: obj) = box(fun () -> ob.ToString()) :?> (unit -> string) + +let go() = foo "hi" + +let goFixed() = foo(box "hi") +""" + let actualIL = FSharp source |> asLibrary |> withOptimize |> compile |> shouldSucceed |> getActualIL + + Assert.Contains("go", actualIL) + Assert.Contains("goFixed", actualIL) + Assert.Contains("FSharpFunc", actualIL) + + // https://github.com/dotnet/fsharp/issues/12460 + [] + let ``Issue_12460_VersionInfoDifference`` () = + let source = """ +module VersionInfoTest + +open System.Reflection + +[] +[] +do () + +let value = 42 +""" + FSharp source + |> asLibrary + |> withName "VersionInfoTest" + |> compile + |> shouldSucceed + |> fun result -> + match result with + | CompilationResult.Success s -> + match s.OutputPath with + | Some path -> + let fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(path) + if System.String.IsNullOrEmpty(fvi.InternalName) then + failwith $"InternalName should not be empty. Expected filename, got: '{fvi.InternalName}'" + if fvi.ProductVersion <> "5.6.7" then + failwith $"ProductVersion should be '5.6.7' (from AssemblyInformationalVersion), got: '{fvi.ProductVersion}'" + if fvi.FileVersion <> "1.2.3.4" then + failwith $"FileVersion should be '1.2.3.4', got: '{fvi.FileVersion}'" + result + | None -> failwith "Output path not found" + | _ -> failwith "Compilation failed" + |> ignore + + [] + let ``Issue_12460_VersionInfoFallback`` () = + let source = """ +module VersionInfoFallbackTest + +open System.Reflection + +[] +do () + +let value = 42 +""" + FSharp source + |> asLibrary + |> withName "VersionInfoFallbackTest" + |> compile + |> shouldSucceed + |> fun result -> + match result with + | CompilationResult.Success s -> + match s.OutputPath with + | Some path -> + let fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(path) + if System.String.IsNullOrEmpty(fvi.InternalName) then + failwith $"InternalName should not be empty, got: '{fvi.InternalName}'" + if fvi.FileVersion <> "2.3.4.5" then + failwith $"FileVersion should be '2.3.4.5', got: '{fvi.FileVersion}'" + if System.String.IsNullOrEmpty(fvi.OriginalFilename) then + failwith $"OriginalFilename should not be empty, got: '{fvi.OriginalFilename}'" + result + | None -> failwith "Output path not found" + | _ -> failwith "Compilation failed" + |> ignore + + // https://github.com/dotnet/fsharp/issues/12416 + [] + let ``Issue_12416_PipeInlining`` () = + let source = """ +module PipeInliningTest + +type 'T PushStream = ('T -> bool) -> bool + +let inline ofArray (vs : _ array) : _ PushStream = fun ([] r) -> + let mutable i = 0 + while i < vs.Length && r vs.[i] do i <- i + 1 + i = vs.Length + +let inline fold ([] f) z ([] ps : _ PushStream) = + let mutable s = z + let _ = ps (fun v -> s <- f s v; true) + s + +let inline (|>>) ([] v : _ -> _) ([] f : _ -> _) = f v + +let values = [|0..100|] + +let thisIsInlined1 () = ofArray values |>> fold (+) 0 + +let thisIsInlined2 () = + let vs = [|0..100|] + ofArray vs |>> fold (+) 0 + +let thisIsNotInlined () = ofArray [|0..100|] |>> fold (+) 0 +""" + FSharp source + |> asLibrary + |> withOptimize + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/12384 + [] + let ``Issue_12384_MutRecInitOrder`` () = + let source = """ +module MutRecInitTest + +type Node = { Next: Node; Prev: Node; Value: int } + +let rec zero = { Next = zero; Prev = zero; Value = 0 } + +let rec one = { Next = two; Prev = two; Value = 1 } +and two = { Next = one; Prev = one; Value = 2 } + +[] +let main _ = + let zeroOk = obj.ReferenceEquals(zero.Next, zero) && obj.ReferenceEquals(zero.Prev, zero) + let oneNextOk = obj.ReferenceEquals(one.Next, two) + let onePrevOk = obj.ReferenceEquals(one.Prev, two) + let twoNextOk = obj.ReferenceEquals(two.Next, one) + let twoPrevOk = obj.ReferenceEquals(two.Prev, one) + + if zeroOk && oneNextOk && onePrevOk && twoNextOk && twoPrevOk then + 0 + else + failwith (sprintf "Mutual recursion initialization failed: zero=%b one.Next=%b one.Prev=%b two.Next=%b two.Prev=%b" + zeroOk oneNextOk onePrevOk twoNextOk twoPrevOk) +""" + FSharp source + |> asExe + |> compileAndRun + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/12366 + [] + let ``Issue_12366_ClosureNaming`` () = + let source = """ +module ClosureNamingTest + +let processData items = + items + |> List.map (fun x -> x * 2) + |> List.filter (fun x -> x > 2) + +let outerFunc a = + let innerFunc b = + fun c -> a + b + c + innerFunc +""" + let actualIL = FSharp source |> asLibrary |> compile |> shouldSucceed |> getActualIL + + Assert.Contains("outerFunc@", actualIL) + Assert.DoesNotContain("'clo@", actualIL) + + [] + let ``Issue_12366_ClosureNaming_Capturing`` () = + let source = """ +module CapturingClosureTest + +let makeAdder n = + fun x -> x + n + +let makeMultiplier n = + let multiply x = x * n + multiply +""" + let actualIL = FSharp source |> asLibrary |> compile |> shouldSucceed |> getActualIL + + Assert.Contains("makeMultiplier@", actualIL) + Assert.DoesNotContain("'clo@", actualIL) + + [] + let ``Issue_12366_ClosureNaming_DeepNesting`` () = + let source = """ +module DeepNestingTest + +let outermost x = + let middle y = + let innermost z = + fun w -> x + y + z + w + innermost + middle +""" + let actualIL = FSharp source |> asLibrary |> compile |> shouldSucceed |> getActualIL + + Assert.Contains("outermost@", actualIL) + Assert.DoesNotContain("'clo@", actualIL) + + // https://github.com/dotnet/fsharp/issues/12139 + [] + let ``Issue_12139_StringNullCheck`` () = + let source = """ +module StringNullCheckTest + +open System + +let isNullString (s: string) = s = null + +let isNotNullString (s: string) = s <> null + +let test() = + while Console.ReadLine() <> null do + Console.WriteLine(1) +""" + FSharp source + |> asLibrary + |> withOptimize + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/12137 + [] + let ``Issue_12137_TailEmitReduction`` () = + let source = """ +module TailEmitTest + +let inline fold (f: 'S -> 'T -> 'S) (state: 'S) (items: 'T list) = + let mutable s = state + for item in items do + s <- f s item + s + +let sumLocal () = fold (+) 0 [1; 2; 3] +""" + FSharp source + |> asLibrary + |> withOptimize + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/11935 + [] + let ``Issue_11935_UnmanagedConstraintInterop`` () = + let source = """ +module Test + +let test<'T when 'T : unmanaged> (x: 'T) = x +""" + FSharp source + |> asLibrary + |> withLangVersion10 + |> compile + |> shouldSucceed + |> verifyIL [""" + .method public static !!T test(!!T x) cil managed + { + .param type T + .custom instance void [runtime]System.Runtime.CompilerServices.IsUnmanagedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + }"""] + + [] + let ``Issue_11935_UnmanagedConstraintInterop_ClassType`` () = + let source = """ +module Test + +type Container<'T when 'T : unmanaged>() = + member _.GetDefault() : 'T = Unchecked.defaultof<'T> +""" + FSharp source + |> asLibrary + |> withLangVersion10 + |> compile + |> shouldSucceed + |> verifyILContains [ + "Container`1" + ".custom instance void [runtime]System.Runtime.CompilerServices.IsUnmanagedAttribute::.ctor() = ( 01 00 00 00 )" + ] + |> shouldSucceed + + [] + let ``Issue_11935_UnmanagedConstraintInterop_StructType`` () = + let source = """ +module Test + +[] +type StructContainer<'T when 'T : unmanaged> = + val Value : 'T + new(v) = { Value = v } +""" + FSharp source + |> asLibrary + |> withLangVersion10 + |> compile + |> shouldSucceed + |> verifyILContains [ + "StructContainer`1" + ".custom instance void [runtime]System.Runtime.CompilerServices.IsUnmanagedAttribute::.ctor() = ( 01 00 00 00 )" + ] + |> shouldSucceed + + [] + let ``Issue_11935_UnmanagedConstraintInterop_InstanceMethod`` () = + let source = """ +module Test + +type Processor() = + member _.Process<'T when 'T : unmanaged>(x: 'T) = x +""" + FSharp source + |> asLibrary + |> withLangVersion10 + |> compile + |> shouldSucceed + |> verifyIL [""" + .method public hidebysig instance !!T + Process(!!T x) cil managed + { + .param type T + .custom instance void [runtime]System.Runtime.CompilerServices.IsUnmanagedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ret + }"""] + + [] + let ``Issue_11935_UnmanagedConstraintInterop_MultipleTypeParams`` () = + let source = """ +module Test + +let combine<'T, 'U when 'T : unmanaged and 'U : unmanaged> (x: 'T) (y: 'U) = struct(x, y) +""" + FSharp source + |> asLibrary + |> withLangVersion10 + |> compile + |> shouldSucceed + |> verifyILContains [ + "combine(!!T x, !!U y) cil managed" + ] + |> shouldSucceed + + // https://github.com/dotnet/fsharp/issues/11132 + [] + let ``Issue_11132_VoidptrDelegate`` () = + let source = """ +module Test +#nowarn "9" + +open System + +type MyDelegate = delegate of voidptr -> unit + +let method (ptr: voidptr) = () + +let getDelegate (m: voidptr -> unit) : MyDelegate = MyDelegate(m) + +let test() = + let d = getDelegate method + d.Invoke(IntPtr.Zero.ToPointer()) + +do test() +""" + FSharp source + |> asExe + |> withOptimize + |> compileAndRun + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/9348 + [] + let ``Issue_9348_ComparePerformance`` () = + let source = """ +module Test + +type T = { X: int } +let compare (a: T) (b: T) = compare a.X b.X +""" + let actualIL = FSharp source |> asLibrary |> compile |> shouldSucceed |> getActualIL + + Assert.Contains("compare", actualIL) + Assert.Contains("ldfld", actualIL) + + // https://github.com/dotnet/fsharp/issues/9176 + [] + let ``Issue_9176_InlineAttributes`` () = + let source = """ +module Test + +let inline f x = x + 1 + +let g y = f y + f y +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/7861 + [] + let ``Issue_7861_AttributeTypeReference`` () = + let source = """ +module Test + +open System + +type TypedAttribute(t: Type) = + inherit Attribute() + member _.TargetType = t + +[)>] +type MyClass() = class end +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> verifyILContains [ + ".assembly extern System.Xml.ReaderWriter" + ] + |> shouldSucceed + + [] + let ``Issue_7861_NamedAttributeArgument`` () = + let source = """ +module Test + +open System + +type TypePropertyAttribute() = + inherit Attribute() + member val TargetType : Type = null with get, set + +[)>] +type MyClass() = class end +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> verifyILContains [ + ".assembly extern System.Xml.ReaderWriter" + ] + |> shouldSucceed + + [] + let ``Issue_7861_AttributeOnMethod`` () = + let source = """ +module Test + +open System + +type TypedAttribute(t: Type) = + inherit Attribute() + member _.TargetType = t + +type MyClass() = + [)>] + member _.MyMethod() = () +""" + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + |> verifyILContains [ + ".assembly extern System.Xml.ReaderWriter" + ] + |> shouldSucceed + + // https://github.com/dotnet/fsharp/issues/5834 + [] + let ``Issue_5834_ObsoleteSpecialname`` () = + let source = """ +module Test + +open System +open System.Reflection + +[] +type AbstractWithEvent() = + [] + [] + abstract member MyEvent : IEvent + +type ConcreteWithEvent() = + let evt = new Event() + [] + member this.MyEvent = evt.Publish + +[] +let main _ = + let abstractType = typeof + let concreteType = typeof + + let abstractAddMethod = abstractType.GetMethod("add_MyEvent") + let abstractRemoveMethod = abstractType.GetMethod("remove_MyEvent") + + let concreteAddMethod = concreteType.GetMethod("add_MyEvent") + + printfn "AbstractWithEvent.add_MyEvent.IsSpecialName = %b" abstractAddMethod.IsSpecialName + printfn "AbstractWithEvent.remove_MyEvent.IsSpecialName = %b" abstractRemoveMethod.IsSpecialName + printfn "ConcreteWithEvent.add_MyEvent.IsSpecialName = %b" concreteAddMethod.IsSpecialName + + if not abstractAddMethod.IsSpecialName || not abstractRemoveMethod.IsSpecialName then + printfn "BUG: Abstract event accessors missing specialname flag" + printfn "Expected: IsSpecialName = true" + printfn "Actual: IsSpecialName = false" + 1 + else + printfn "SUCCESS: All event accessors have specialname" + 0 +""" + FSharp source + |> asExe + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore + + // https://github.com/dotnet/fsharp/issues/878 + [] + let ``Issue_878_ExceptionSerialization`` () = + let source = """ +module Test + +exception Foo of x:string * y:int +""" + let result = + FSharp source + |> asLibrary + |> compile + |> shouldSucceed + + result + |> verifyIL [ + ".method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed" + "call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo," + ".method family specialname rtspecialname instance void .ctor(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed" + ] + |> ignore + + let actualIL = getActualIL result + Assert.Contains("AddValue", actualIL) + + // https://github.com/dotnet/fsharp/issues/878 + // Runtime roundtrip test using SerializationInfo directly (BinaryFormatter removed in .NET 10) + [] + let ``Issue_878_ExceptionSerialization_Roundtrip`` () = + let source = """ +module Test +open System +open System.Runtime.Serialization + +#nowarn "44" // Serialization types are obsolete but needed for testing ISerializable +#nowarn "67" + +exception Foo of x:string * y:int + +let roundtrip (e: Exception) = + let info = SerializationInfo(e.GetType(), FormatterConverter()) + let ctx = StreamingContext(StreamingContextStates.All) + e.GetObjectData(info, ctx) + let ctor = + e.GetType().GetConstructor( + System.Reflection.BindingFlags.Instance ||| System.Reflection.BindingFlags.NonPublic ||| System.Reflection.BindingFlags.Public, + null, + [| typeof; typeof |], + null) + if ctor = null then failwith "Deserialization constructor not found" + ctor.Invoke([| info :> obj; ctx :> obj |]) :?> Exception + +[] +let main _ = + let original = Foo("value", 42) + // Check GetObjectData actually writes our fields + let info = SerializationInfo(original.GetType(), FormatterConverter()) + let ctx = StreamingContext(StreamingContextStates.All) + original.GetObjectData(info, ctx) + let xVal = info.GetString("x") + let yVal = info.GetInt32("y") + if xVal <> "value" then failwithf "GetObjectData: Expected x='value', got '%s'" xVal + if yVal <> 42 then failwithf "GetObjectData: Expected y=42, got %d" yVal + + // Check full roundtrip + let cloned = roundtrip original + // Access fields via internal backing fields using reflection + let xField = cloned.GetType().GetField("x@", System.Reflection.BindingFlags.Instance ||| System.Reflection.BindingFlags.NonPublic) + let yField = cloned.GetType().GetField("y@", System.Reflection.BindingFlags.Instance ||| System.Reflection.BindingFlags.NonPublic) + if xField = null then failwith "Field x@ not found" + if yField = null then failwith "Field y@ not found" + let xCloned = xField.GetValue(cloned) :?> string + let yCloned = yField.GetValue(cloned) :?> int + if xCloned <> "value" then failwithf "Roundtrip: Expected x='value', got '%s'" xCloned + if yCloned <> 42 then failwithf "Roundtrip: Expected y=42, got %d" yCloned + printfn "SUCCESS: Foo(value, 42) roundtripped correctly" + 0 +""" + FSharp source + |> asExe + |> ignoreWarnings + |> compile + |> shouldSucceed + |> run + |> shouldSucceed + |> ignore diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/TryWith_NoFilterBlocks01.fs.RealInternalSignatureOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/TryWith_NoFilterBlocks01.fs.RealInternalSignatureOff.il.bsl index fae41598e5d..0d1478068b5 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/TryWith_NoFilterBlocks01.fs.RealInternalSignatureOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/TryWith_NoFilterBlocks01.fs.RealInternalSignatureOff.il.bsl @@ -16,16 +16,6 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.exe @@ -58,34 +48,43 @@ .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.Exception V_1, - class [runtime]System.Exception V_2) + object V_1, + class [runtime]System.Exception V_2, + class [runtime]System.Exception V_3) .try { IL_0000: nop - IL_0001: leave.s IL_001c + IL_0001: leave.s IL_0028 } catch [runtime]System.Object { - IL_0003: castclass [runtime]System.Exception - IL_0008: stloc.0 - IL_0009: ldloc.0 - IL_000a: stloc.1 - IL_000b: ldloc.1 - IL_000c: callvirt instance int32 [runtime]System.Object::GetHashCode() - IL_0011: ldc.i4.0 - IL_0012: ceq - IL_0014: brfalse.s IL_001a - - IL_0016: ldloc.0 - IL_0017: stloc.2 - IL_0018: leave.s IL_001c - - IL_001a: leave.s IL_001c + IL_0003: stloc.1 + IL_0004: ldloc.1 + IL_0005: isinst [runtime]System.Exception + IL_000a: dup + IL_000b: brtrue.s IL_0014 + + IL_000d: pop + IL_000e: ldloc.1 + IL_000f: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0014: stloc.0 + IL_0015: ldloc.0 + IL_0016: stloc.2 + IL_0017: ldloc.2 + IL_0018: callvirt instance int32 [runtime]System.Object::GetHashCode() + IL_001d: ldc.i4.0 + IL_001e: ceq + IL_0020: brfalse.s IL_0026 + + IL_0022: ldloc.0 + IL_0023: stloc.3 + IL_0024: leave.s IL_0028 + + IL_0026: leave.s IL_0028 } - IL_001c: ret + IL_0028: ret } } @@ -94,4 +93,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/TryWith_NoFilterBlocks01.fs.RealInternalSignatureOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/TryWith_NoFilterBlocks01.fs.RealInternalSignatureOn.il.bsl index 5439b839899..5ad75628ca2 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/TryWith_NoFilterBlocks01.fs.RealInternalSignatureOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/TryWith_NoFilterBlocks01.fs.RealInternalSignatureOn.il.bsl @@ -16,16 +16,6 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.exe @@ -59,34 +49,43 @@ .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.Exception V_1, - class [runtime]System.Exception V_2) + object V_1, + class [runtime]System.Exception V_2, + class [runtime]System.Exception V_3) .try { IL_0000: nop - IL_0001: leave.s IL_001c + IL_0001: leave.s IL_0028 } catch [runtime]System.Object { - IL_0003: castclass [runtime]System.Exception - IL_0008: stloc.0 - IL_0009: ldloc.0 - IL_000a: stloc.1 - IL_000b: ldloc.1 - IL_000c: callvirt instance int32 [runtime]System.Object::GetHashCode() - IL_0011: ldc.i4.0 - IL_0012: ceq - IL_0014: brfalse.s IL_001a - - IL_0016: ldloc.0 - IL_0017: stloc.2 - IL_0018: leave.s IL_001c - - IL_001a: leave.s IL_001c + IL_0003: stloc.1 + IL_0004: ldloc.1 + IL_0005: isinst [runtime]System.Exception + IL_000a: dup + IL_000b: brtrue.s IL_0014 + + IL_000d: pop + IL_000e: ldloc.1 + IL_000f: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0014: stloc.0 + IL_0015: ldloc.0 + IL_0016: stloc.2 + IL_0017: ldloc.2 + IL_0018: callvirt instance int32 [runtime]System.Object::GetHashCode() + IL_001d: ldc.i4.0 + IL_001e: ceq + IL_0020: brfalse.s IL_0026 + + IL_0022: ldloc.0 + IL_0023: stloc.3 + IL_0024: leave.s IL_0028 + + IL_0026: leave.s IL_0028 } - IL_001c: ret + IL_0028: ret } } @@ -113,4 +112,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ExceptionType.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ExceptionType.fs.il.netcore.bsl index 2a8a0c50d27..f2e6ff73712 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ExceptionType.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ExceptionType.fs.il.netcore.bsl @@ -62,7 +62,34 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "Data0" + IL_000f: ldtoken [runtime]System.String + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: castclass [runtime]System.String + IL_0023: stfld string MyLibrary/JustStringE::Data0@ + IL_0028: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "Data0" + IL_000e: ldarg.0 + IL_000f: ldfld string MyLibrary/JustStringE::Data0@ + IL_0014: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_0019: ret } .method public hidebysig specialname instance string get_Data0() cil managed @@ -137,7 +164,49 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "M1" + IL_000f: ldtoken [runtime]System.String + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: castclass [runtime]System.String + IL_0023: stfld string MyLibrary/TwoStrings::M1@ + IL_0028: ldarg.0 + IL_0029: ldarg.1 + IL_002a: ldstr "M2" + IL_002f: ldtoken [runtime]System.String + IL_0034: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0039: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_003e: castclass [runtime]System.String + IL_0043: stfld string MyLibrary/TwoStrings::M2@ + IL_0048: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "M1" + IL_000e: ldarg.0 + IL_000f: ldfld string MyLibrary/TwoStrings::M1@ + IL_0014: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_0019: ldarg.1 + IL_001a: ldstr "M2" + IL_001f: ldarg.0 + IL_0020: ldfld string MyLibrary/TwoStrings::M2@ + IL_0025: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_002a: ret } .method public hidebysig specialname instance string get_M1() cil managed @@ -226,7 +295,34 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "Data0" + IL_000f: ldtoken [runtime]System.String + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: castclass [runtime]System.String + IL_0023: stfld string MyLibrary/NullableStringE::Data0@ + IL_0028: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "Data0" + IL_000e: ldarg.0 + IL_000f: ldfld string MyLibrary/NullableStringE::Data0@ + IL_0014: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_0019: ret } .method public hidebysig specialname instance string get_Data0() cil managed @@ -300,7 +396,34 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "Message" + IL_000f: ldtoken [runtime]System.String + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: castclass [runtime]System.String + IL_0023: stfld string MyLibrary/NullableMessage::Message@ + IL_0028: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "Message" + IL_000e: ldarg.0 + IL_000f: ldfld string MyLibrary/NullableMessage::Message@ + IL_0014: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_0019: ret } .method public hidebysig specialname virtual instance string get_Message() cil managed @@ -334,4 +457,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest05.fs.RealInternalSignatureOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest05.fs.RealInternalSignatureOff.il.bsl index c9c71515526..1743de543db 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest05.fs.RealInternalSignatureOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest05.fs.RealInternalSignatureOff.il.bsl @@ -16,16 +16,6 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.exe @@ -198,7 +188,8 @@ .maxstack 7 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.Exception V_1) + class [runtime]System.Exception V_1, + object V_2) IL_0000: ldarg.0 IL_0001: ldfld int32 SeqExpressionSteppingTest5/SeqExpressionSteppingTest5/f4@6::pc IL_0006: ldc.i4.4 @@ -208,7 +199,7 @@ IL_0011: br.s IL_0019 IL_0013: nop - IL_0014: br IL_009f + IL_0014: br IL_00ab IL_0019: nop .try @@ -265,28 +256,36 @@ IL_0086: ldarg.0 IL_0087: ldc.i4.0 IL_0088: stfld int32 SeqExpressionSteppingTest5/SeqExpressionSteppingTest5/f4@6::current - IL_008d: leave.s IL_0099 + IL_008d: leave.s IL_00a5 } catch [runtime]System.Object { - IL_008f: castclass [runtime]System.Exception - IL_0094: stloc.1 - IL_0095: ldloc.1 - IL_0096: stloc.0 - IL_0097: leave.s IL_0099 + IL_008f: stloc.2 + IL_0090: ldloc.2 + IL_0091: isinst [runtime]System.Exception + IL_0096: dup + IL_0097: brtrue.s IL_00a0 + + IL_0099: pop + IL_009a: ldloc.2 + IL_009b: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_00a0: stloc.1 + IL_00a1: ldloc.1 + IL_00a2: stloc.0 + IL_00a3: leave.s IL_00a5 } - IL_0099: nop - IL_009a: br IL_0000 + IL_00a5: nop + IL_00a6: br IL_0000 - IL_009f: ldloc.0 - IL_00a0: brfalse.s IL_00a4 + IL_00ab: ldloc.0 + IL_00ac: brfalse.s IL_00b0 - IL_00a2: ldloc.0 - IL_00a3: throw + IL_00ae: ldloc.0 + IL_00af: throw - IL_00a4: ret + IL_00b0: ret } .method public strict virtual instance bool get_CheckClose() cil managed @@ -408,4 +407,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest05.fs.RealInternalSignatureOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest05.fs.RealInternalSignatureOn.il.bsl index 0bc58b2d8f8..c1dcacb1f09 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest05.fs.RealInternalSignatureOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest05.fs.RealInternalSignatureOn.il.bsl @@ -16,16 +16,6 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.exe @@ -198,7 +188,8 @@ .maxstack 7 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.Exception V_1) + class [runtime]System.Exception V_1, + object V_2) IL_0000: ldarg.0 IL_0001: ldfld int32 SeqExpressionSteppingTest5/SeqExpressionSteppingTest5/f4@6::pc IL_0006: ldc.i4.4 @@ -208,7 +199,7 @@ IL_0011: br.s IL_0019 IL_0013: nop - IL_0014: br IL_009f + IL_0014: br IL_00ab IL_0019: nop .try @@ -265,28 +256,36 @@ IL_0086: ldarg.0 IL_0087: ldc.i4.0 IL_0088: stfld int32 SeqExpressionSteppingTest5/SeqExpressionSteppingTest5/f4@6::current - IL_008d: leave.s IL_0099 + IL_008d: leave.s IL_00a5 } catch [runtime]System.Object { - IL_008f: castclass [runtime]System.Exception - IL_0094: stloc.1 - IL_0095: ldloc.1 - IL_0096: stloc.0 - IL_0097: leave.s IL_0099 + IL_008f: stloc.2 + IL_0090: ldloc.2 + IL_0091: isinst [runtime]System.Exception + IL_0096: dup + IL_0097: brtrue.s IL_00a0 + + IL_0099: pop + IL_009a: ldloc.2 + IL_009b: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_00a0: stloc.1 + IL_00a1: ldloc.1 + IL_00a2: stloc.0 + IL_00a3: leave.s IL_00a5 } - IL_0099: nop - IL_009a: br IL_0000 + IL_00a5: nop + IL_00a6: br IL_0000 - IL_009f: ldloc.0 - IL_00a0: brfalse.s IL_00a4 + IL_00ab: ldloc.0 + IL_00ac: brfalse.s IL_00b0 - IL_00a2: ldloc.0 - IL_00a3: throw + IL_00ae: ldloc.0 + IL_00af: throw - IL_00a4: ret + IL_00b0: ret } .method public strict virtual instance bool get_CheckClose() cil managed @@ -446,4 +445,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest06.fs.RealInternalSignatureOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest06.fs.RealInternalSignatureOff.il.bsl index 3835b9fa0d5..1b5f501a1e4 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest06.fs.RealInternalSignatureOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest06.fs.RealInternalSignatureOff.il.bsl @@ -16,16 +16,6 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.exe @@ -223,7 +213,8 @@ .maxstack 6 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.Exception V_1) + class [runtime]System.Exception V_1, + object V_2) IL_0000: ldarg.0 IL_0001: ldfld int32 SeqExpressionSteppingTest6/SeqExpressionSteppingTest6/f7@6::pc IL_0006: ldc.i4.5 @@ -233,7 +224,7 @@ IL_0011: br.s IL_0019 IL_0013: nop - IL_0014: br IL_009e + IL_0014: br IL_00aa IL_0019: nop .try @@ -294,28 +285,36 @@ IL_0085: ldarg.0 IL_0086: ldc.i4.0 IL_0087: stfld int32 SeqExpressionSteppingTest6/SeqExpressionSteppingTest6/f7@6::current - IL_008c: leave.s IL_0098 + IL_008c: leave.s IL_00a4 } catch [runtime]System.Object { - IL_008e: castclass [runtime]System.Exception - IL_0093: stloc.1 - IL_0094: ldloc.1 - IL_0095: stloc.0 - IL_0096: leave.s IL_0098 + IL_008e: stloc.2 + IL_008f: ldloc.2 + IL_0090: isinst [runtime]System.Exception + IL_0095: dup + IL_0096: brtrue.s IL_009f + + IL_0098: pop + IL_0099: ldloc.2 + IL_009a: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_009f: stloc.1 + IL_00a0: ldloc.1 + IL_00a1: stloc.0 + IL_00a2: leave.s IL_00a4 } - IL_0098: nop - IL_0099: br IL_0000 + IL_00a4: nop + IL_00a5: br IL_0000 - IL_009e: ldloc.0 - IL_009f: brfalse.s IL_00a3 + IL_00aa: ldloc.0 + IL_00ab: brfalse.s IL_00af - IL_00a1: ldloc.0 - IL_00a2: throw + IL_00ad: ldloc.0 + IL_00ae: throw - IL_00a3: ret + IL_00af: ret } .method public strict virtual instance bool get_CheckClose() cil managed @@ -474,4 +473,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest06.fs.RealInternalSignatureOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest06.fs.RealInternalSignatureOn.il.bsl index 5170c5d889c..2f60f1702a0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest06.fs.RealInternalSignatureOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest06.fs.RealInternalSignatureOn.il.bsl @@ -16,16 +16,6 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.exe @@ -223,7 +213,8 @@ .maxstack 6 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.Exception V_1) + class [runtime]System.Exception V_1, + object V_2) IL_0000: ldarg.0 IL_0001: ldfld int32 SeqExpressionSteppingTest6/SeqExpressionSteppingTest6/f7@6::pc IL_0006: ldc.i4.5 @@ -233,7 +224,7 @@ IL_0011: br.s IL_0019 IL_0013: nop - IL_0014: br IL_009e + IL_0014: br IL_00aa IL_0019: nop .try @@ -294,28 +285,36 @@ IL_0085: ldarg.0 IL_0086: ldc.i4.0 IL_0087: stfld int32 SeqExpressionSteppingTest6/SeqExpressionSteppingTest6/f7@6::current - IL_008c: leave.s IL_0098 + IL_008c: leave.s IL_00a4 } catch [runtime]System.Object { - IL_008e: castclass [runtime]System.Exception - IL_0093: stloc.1 - IL_0094: ldloc.1 - IL_0095: stloc.0 - IL_0096: leave.s IL_0098 + IL_008e: stloc.2 + IL_008f: ldloc.2 + IL_0090: isinst [runtime]System.Exception + IL_0095: dup + IL_0096: brtrue.s IL_009f + + IL_0098: pop + IL_0099: ldloc.2 + IL_009a: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_009f: stloc.1 + IL_00a0: ldloc.1 + IL_00a1: stloc.0 + IL_00a2: leave.s IL_00a4 } - IL_0098: nop - IL_0099: br IL_0000 + IL_00a4: nop + IL_00a5: br IL_0000 - IL_009e: ldloc.0 - IL_009f: brfalse.s IL_00a3 + IL_00aa: ldloc.0 + IL_00ab: brfalse.s IL_00af - IL_00a1: ldloc.0 - IL_00a2: throw + IL_00ad: ldloc.0 + IL_00ae: throw - IL_00a3: ret + IL_00af: ret } .method public strict virtual instance bool get_CheckClose() cil managed @@ -509,4 +508,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest07.fs.RealInternalSignatureOff.il.netcore.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest07.fs.RealInternalSignatureOff.il.netcore.release.bsl index ef8c6021f6b..4b482f6c0f5 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest07.fs.RealInternalSignatureOff.il.netcore.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest07.fs.RealInternalSignatureOff.il.netcore.release.bsl @@ -739,7 +739,8 @@ .locals init (class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,class [FSharp.Core]Microsoft.FSharp.Core.Unit> V_0, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_1, class [runtime]System.Exception V_2, - class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 V_3) + object V_3, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 V_4) IL_0000: ldc.i4.0 IL_0001: stsfld int32 ''.$SeqExpressionSteppingTest7::r@4 IL_0006: ldstr "res = %A" @@ -750,38 +751,46 @@ { IL_0016: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 SeqExpressionSteppingTest7::f() IL_001b: stloc.1 - IL_001c: leave.s IL_004b + IL_001c: leave.s IL_0059 } catch [runtime]System.Object { - IL_001e: castclass [runtime]System.Exception - IL_0023: stloc.2 - IL_0024: ldloc.2 - IL_0025: call class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailurePattern(class [runtime]System.Exception) - IL_002a: stloc.3 - IL_002b: ldloc.3 - IL_002c: brfalse.s IL_0040 - - IL_002e: call int32 SeqExpressionSteppingTest7::get_r() - IL_0033: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() - IL_0038: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::Cons(!0, + IL_001e: stloc.3 + IL_001f: ldloc.3 + IL_0020: isinst [runtime]System.Exception + IL_0025: dup + IL_0026: brtrue.s IL_002f + + IL_0028: pop + IL_0029: ldloc.3 + IL_002a: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_002f: stloc.2 + IL_0030: ldloc.2 + IL_0031: call class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailurePattern(class [runtime]System.Exception) + IL_0036: stloc.s V_4 + IL_0038: ldloc.s V_4 + IL_003a: brfalse.s IL_004e + + IL_003c: call int32 SeqExpressionSteppingTest7::get_r() + IL_0041: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0046: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::Cons(!0, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1) - IL_003d: stloc.1 - IL_003e: leave.s IL_004b + IL_004b: stloc.1 + IL_004c: leave.s IL_0059 - IL_0040: rethrow - IL_0042: ldnull - IL_0043: unbox.any class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 - IL_0048: stloc.1 - IL_0049: leave.s IL_004b + IL_004e: rethrow + IL_0050: ldnull + IL_0051: unbox.any class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + IL_0056: stloc.1 + IL_0057: leave.s IL_0059 } - IL_004b: ldloc.0 - IL_004c: ldloc.1 - IL_004d: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,class [FSharp.Core]Microsoft.FSharp.Core.Unit>::Invoke(!0) - IL_0052: pop - IL_0053: ret + IL_0059: ldloc.0 + IL_005a: ldloc.1 + IL_005b: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,class [FSharp.Core]Microsoft.FSharp.Core.Unit>::Invoke(!0) + IL_0060: pop + IL_0061: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest07.fs.RealInternalSignatureOn.il.netcore.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest07.fs.RealInternalSignatureOn.il.netcore.release.bsl index 8ed4541528d..0b167fd5d3d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest07.fs.RealInternalSignatureOn.il.netcore.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SeqExpressionStepping/SeqExpressionSteppingTest07.fs.RealInternalSignatureOn.il.netcore.release.bsl @@ -734,7 +734,8 @@ .locals init (class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,class [FSharp.Core]Microsoft.FSharp.Core.Unit> V_0, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_1, class [runtime]System.Exception V_2, - class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 V_3) + object V_3, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 V_4) IL_0000: ldc.i4.0 IL_0001: stsfld int32 SeqExpressionSteppingTest7::r@4 IL_0006: ldstr "res = %A" @@ -745,38 +746,46 @@ { IL_0016: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 SeqExpressionSteppingTest7::f() IL_001b: stloc.1 - IL_001c: leave.s IL_004b + IL_001c: leave.s IL_0059 } catch [runtime]System.Object { - IL_001e: castclass [runtime]System.Exception - IL_0023: stloc.2 - IL_0024: ldloc.2 - IL_0025: call class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailurePattern(class [runtime]System.Exception) - IL_002a: stloc.3 - IL_002b: ldloc.3 - IL_002c: brfalse.s IL_0040 - - IL_002e: call int32 SeqExpressionSteppingTest7::get_r() - IL_0033: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() - IL_0038: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::Cons(!0, + IL_001e: stloc.3 + IL_001f: ldloc.3 + IL_0020: isinst [runtime]System.Exception + IL_0025: dup + IL_0026: brtrue.s IL_002f + + IL_0028: pop + IL_0029: ldloc.3 + IL_002a: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_002f: stloc.2 + IL_0030: ldloc.2 + IL_0031: call class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailurePattern(class [runtime]System.Exception) + IL_0036: stloc.s V_4 + IL_0038: ldloc.s V_4 + IL_003a: brfalse.s IL_004e + + IL_003c: call int32 SeqExpressionSteppingTest7::get_r() + IL_0041: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0046: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::Cons(!0, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1) - IL_003d: stloc.1 - IL_003e: leave.s IL_004b + IL_004b: stloc.1 + IL_004c: leave.s IL_0059 - IL_0040: rethrow - IL_0042: ldnull - IL_0043: unbox.any class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 - IL_0048: stloc.1 - IL_0049: leave.s IL_004b + IL_004e: rethrow + IL_0050: ldnull + IL_0051: unbox.any class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + IL_0056: stloc.1 + IL_0057: leave.s IL_0059 } - IL_004b: ldloc.0 - IL_004c: ldloc.1 - IL_004d: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,class [FSharp.Core]Microsoft.FSharp.Core.Unit>::Invoke(!0) - IL_0052: pop - IL_0053: ret + IL_0059: ldloc.0 + IL_005a: ldloc.1 + IL_005b: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,class [FSharp.Core]Microsoft.FSharp.Core.Unit>::Invoke(!0) + IL_0060: pop + IL_0061: ret } .property int32 r() diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelModule.fs.RealInternalSignatureOff.il.netcore.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelModule.fs.RealInternalSignatureOff.il.netcore.release.bsl index 9c163b8ec4e..50410ebe0e5 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelModule.fs.RealInternalSignatureOff.il.netcore.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelModule.fs.RealInternalSignatureOff.il.netcore.release.bsl @@ -480,7 +480,35 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "Data0" + IL_000f: ldtoken [runtime]System.Int32 + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: unbox.any [runtime]System.Int32 + IL_0023: stfld int32 ABC/MyExn::Data0@ + IL_0028: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "Data0" + IL_000e: ldarg.0 + IL_000f: ldfld int32 ABC/MyExn::Data0@ + IL_0014: box [runtime]System.Int32 + IL_0019: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_001e: ret } .method public hidebysig specialname instance int32 get_Data0() cil managed @@ -1180,7 +1208,35 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "Data0" + IL_000f: ldtoken [runtime]System.Int32 + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: unbox.any [runtime]System.Int32 + IL_0023: stfld int32 ABC/ABC/MyExn::Data0@ + IL_0028: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "Data0" + IL_000e: ldarg.0 + IL_000f: ldfld int32 ABC/ABC/MyExn::Data0@ + IL_0014: box [runtime]System.Int32 + IL_0019: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_001e: ret } .method public hidebysig specialname instance int32 get_Data0() cil managed @@ -1512,4 +1568,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelModule.fs.RealInternalSignatureOn.il.netcore.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelModule.fs.RealInternalSignatureOn.il.netcore.release.bsl index e9375f2d0f3..6adebd24f77 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelModule.fs.RealInternalSignatureOn.il.netcore.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelModule.fs.RealInternalSignatureOn.il.netcore.release.bsl @@ -480,7 +480,35 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "Data0" + IL_000f: ldtoken [runtime]System.Int32 + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: unbox.any [runtime]System.Int32 + IL_0023: stfld int32 ABC/MyExn::Data0@ + IL_0028: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "Data0" + IL_000e: ldarg.0 + IL_000f: ldfld int32 ABC/MyExn::Data0@ + IL_0014: box [runtime]System.Int32 + IL_0019: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_001e: ret } .method public hidebysig specialname instance int32 get_Data0() cil managed @@ -1180,7 +1208,35 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "Data0" + IL_000f: ldtoken [runtime]System.Int32 + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: unbox.any [runtime]System.Int32 + IL_0023: stfld int32 ABC/ABC/MyExn::Data0@ + IL_0028: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "Data0" + IL_000e: ldarg.0 + IL_000f: ldfld int32 ABC/ABC/MyExn::Data0@ + IL_0014: box [runtime]System.Int32 + IL_0019: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_001e: ret } .method public hidebysig specialname instance int32 get_Data0() cil managed @@ -1502,4 +1558,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelNamespace.fs.RealInternalSignatureOff.il.netcore.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelNamespace.fs.RealInternalSignatureOff.il.netcore.release.bsl index 36d2089b286..f967c51988c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelNamespace.fs.RealInternalSignatureOff.il.netcore.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelNamespace.fs.RealInternalSignatureOff.il.netcore.release.bsl @@ -476,7 +476,35 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "Data0" + IL_000f: ldtoken [runtime]System.Int32 + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: unbox.any [runtime]System.Int32 + IL_0023: stfld int32 XYZ.MyExn::Data0@ + IL_0028: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "Data0" + IL_000e: ldarg.0 + IL_000f: ldfld int32 XYZ.MyExn::Data0@ + IL_0014: box [runtime]System.Int32 + IL_0019: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_001e: ret } .method public hidebysig specialname instance int32 get_Data0() cil managed @@ -1176,7 +1204,35 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "Data0" + IL_000f: ldtoken [runtime]System.Int32 + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: unbox.any [runtime]System.Int32 + IL_0023: stfld int32 XYZ.ABC/MyExn::Data0@ + IL_0028: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "Data0" + IL_000e: ldarg.0 + IL_000f: ldfld int32 XYZ.ABC/MyExn::Data0@ + IL_0014: box [runtime]System.Int32 + IL_0019: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_001e: ret } .method public hidebysig specialname instance int32 get_Data0() cil managed @@ -1876,7 +1932,35 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "Data0" + IL_000f: ldtoken [runtime]System.Int32 + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: unbox.any [runtime]System.Int32 + IL_0023: stfld int32 XYZ.ABC/ABC/MyExn::Data0@ + IL_0028: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "Data0" + IL_000e: ldarg.0 + IL_000f: ldfld int32 XYZ.ABC/ABC/MyExn::Data0@ + IL_0014: box [runtime]System.Int32 + IL_0019: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_001e: ret } .method public hidebysig specialname instance int32 get_Data0() cil managed @@ -2208,4 +2292,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelNamespace.fs.RealInternalSignatureOn.il.netcore.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelNamespace.fs.RealInternalSignatureOn.il.netcore.release.bsl index d166fc2f2ff..5b8492fbd4b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelNamespace.fs.RealInternalSignatureOn.il.netcore.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/SerializableAttribute/ToplevelNamespace.fs.RealInternalSignatureOn.il.netcore.release.bsl @@ -476,7 +476,35 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "Data0" + IL_000f: ldtoken [runtime]System.Int32 + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: unbox.any [runtime]System.Int32 + IL_0023: stfld int32 XYZ.MyExn::Data0@ + IL_0028: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "Data0" + IL_000e: ldarg.0 + IL_000f: ldfld int32 XYZ.MyExn::Data0@ + IL_0014: box [runtime]System.Int32 + IL_0019: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_001e: ret } .method public hidebysig specialname instance int32 get_Data0() cil managed @@ -1176,7 +1204,35 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "Data0" + IL_000f: ldtoken [runtime]System.Int32 + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: unbox.any [runtime]System.Int32 + IL_0023: stfld int32 XYZ.ABC/MyExn::Data0@ + IL_0028: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "Data0" + IL_000e: ldarg.0 + IL_000f: ldfld int32 XYZ.ABC/MyExn::Data0@ + IL_0014: box [runtime]System.Int32 + IL_0019: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_001e: ret } .method public hidebysig specialname instance int32 get_Data0() cil managed @@ -1876,7 +1932,35 @@ IL_0002: ldarg.2 IL_0003: call instance void [runtime]System.Exception::.ctor(class [runtime]System.Runtime.Serialization.SerializationInfo, valuetype [runtime]System.Runtime.Serialization.StreamingContext) - IL_0008: ret + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: ldstr "Data0" + IL_000f: ldtoken [runtime]System.Int32 + IL_0014: call class [runtime]System.Type [runtime]System.Type::GetTypeFromHandle(valuetype [runtime]System.RuntimeTypeHandle) + IL_0019: callvirt instance object [runtime]System.Runtime.Serialization.SerializationInfo::GetValue(string, + class [runtime]System.Type) + IL_001e: unbox.any [runtime]System.Int32 + IL_0023: stfld int32 XYZ.ABC/ABC/MyExn::Data0@ + IL_0028: ret + } + + .method public strict virtual instance void GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo info, valuetype [runtime]System.Runtime.Serialization.StreamingContext context) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: call instance void [runtime]System.Exception::GetObjectData(class [runtime]System.Runtime.Serialization.SerializationInfo, + valuetype [runtime]System.Runtime.Serialization.StreamingContext) + IL_0008: ldarg.1 + IL_0009: ldstr "Data0" + IL_000e: ldarg.0 + IL_000f: ldfld int32 XYZ.ABC/ABC/MyExn::Data0@ + IL_0014: box [runtime]System.Int32 + IL_0019: callvirt instance void [runtime]System.Runtime.Serialization.SerializationInfo::AddValue(string, + object) + IL_001e: ret } .method public hidebysig specialname instance int32 get_Data0() cil managed @@ -2198,4 +2282,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/StaticOptimizations/String_Enum.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/StaticOptimizations/String_Enum.fs.il.bsl index 740505ce6a7..1af36573396 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/StaticOptimizations/String_Enum.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/StaticOptimizations/String_Enum.fs.il.bsl @@ -540,4 +540,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03.fs.OptimizeOff.il.bsl index dd6e6ab1b40..53c1e4802f7 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03.fs.OptimizeOff.il.bsl @@ -16,16 +16,6 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.exe @@ -64,9 +54,10 @@ .method public static void TestFunction3() cil managed { - .maxstack 3 + .maxstack 4 .locals init (int32 V_0, - class [runtime]System.Exception V_1) + class [runtime]System.Exception V_1, + object V_2) .try { IL_0000: nop @@ -76,21 +67,29 @@ IL_000c: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) IL_0011: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) IL_0016: pop - IL_0017: leave.s IL_0031 + IL_0017: leave.s IL_003d } catch [runtime]System.Object { - IL_0019: castclass [runtime]System.Exception - IL_001e: stloc.1 - IL_001f: ldstr "World" - IL_0024: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) - IL_0029: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) - IL_002e: pop - IL_002f: leave.s IL_0031 + IL_0019: stloc.2 + IL_001a: ldloc.2 + IL_001b: isinst [runtime]System.Exception + IL_0020: dup + IL_0021: brtrue.s IL_002a + + IL_0023: pop + IL_0024: ldloc.2 + IL_0025: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_002a: stloc.1 + IL_002b: ldstr "World" + IL_0030: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) + IL_0035: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_003a: pop + IL_003b: leave.s IL_003d } - IL_0031: ret + IL_003d: ret } } @@ -112,4 +111,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03.fs.OptimizeOn.il.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03.fs.OptimizeOn.il.release.bsl index d360b2a91eb..aba81342383 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03.fs.OptimizeOn.il.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03.fs.OptimizeOn.il.release.bsl @@ -69,7 +69,8 @@ .maxstack 4 .locals init (int32 V_0, class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 V_1, - class [runtime]System.Exception V_2) + class [runtime]System.Exception V_2, + object V_3) .try { IL_0000: nop @@ -83,25 +84,33 @@ IL_0018: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(class [runtime]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) IL_001d: pop - IL_001e: leave.s IL_003f + IL_001e: leave.s IL_004b } catch [runtime]System.Object { - IL_0020: castclass [runtime]System.Exception - IL_0025: stloc.2 - IL_0026: ldstr "World" - IL_002b: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) - IL_0030: stloc.1 - IL_0031: call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out() - IL_0036: ldloc.1 - IL_0037: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(class [runtime]System.IO.TextWriter, + IL_0020: stloc.3 + IL_0021: ldloc.3 + IL_0022: isinst [runtime]System.Exception + IL_0027: dup + IL_0028: brtrue.s IL_0031 + + IL_002a: pop + IL_002b: ldloc.3 + IL_002c: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0031: stloc.2 + IL_0032: ldstr "World" + IL_0037: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) + IL_003c: stloc.1 + IL_003d: call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out() + IL_0042: ldloc.1 + IL_0043: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(class [runtime]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) - IL_003c: pop - IL_003d: leave.s IL_003f + IL_0048: pop + IL_0049: leave.s IL_004b } - IL_003f: ret + IL_004b: ret } } @@ -123,4 +132,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03b.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03b.fs.OptimizeOff.il.bsl index 6b0f2cd2642..686142f8a7f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03b.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03b.fs.OptimizeOff.il.bsl @@ -16,16 +16,6 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.exe @@ -64,11 +54,12 @@ .method public static void TestFunction3b() cil managed { - .maxstack 3 + .maxstack 4 .locals init (int32 V_0, string V_1, class [runtime]System.Exception V_2, - class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 V_3) + object V_3, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 V_4) .try { IL_0000: nop @@ -83,28 +74,36 @@ } catch [runtime]System.Object { - IL_0014: castclass [runtime]System.Exception - IL_0019: stloc.2 - IL_001a: ldloc.2 - IL_001b: call class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailurePattern(class [runtime]System.Exception) - IL_0020: stloc.3 - IL_0021: ldloc.3 - IL_0022: brfalse.s IL_0036 - - IL_0024: ldstr "World" - IL_0029: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) - IL_002e: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) - IL_0033: pop - IL_0034: leave.s IL_0041 - - IL_0036: rethrow - IL_0038: ldnull - IL_0039: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_003e: pop - IL_003f: leave.s IL_0041 + IL_0014: stloc.3 + IL_0015: ldloc.3 + IL_0016: isinst [runtime]System.Exception + IL_001b: dup + IL_001c: brtrue.s IL_0025 + + IL_001e: pop + IL_001f: ldloc.3 + IL_0020: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0025: stloc.2 + IL_0026: ldloc.2 + IL_0027: call class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailurePattern(class [runtime]System.Exception) + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_0044 + + IL_0032: ldstr "World" + IL_0037: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) + IL_003c: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_0041: pop + IL_0042: leave.s IL_004f + + IL_0044: rethrow + IL_0046: ldnull + IL_0047: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_004c: pop + IL_004d: leave.s IL_004f } - IL_0041: ret + IL_004f: ret } } @@ -126,4 +125,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03b.fs.OptimizeOn.il.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03b.fs.OptimizeOn.il.release.bsl index 0a3ae50e3e0..42f9aa56472 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03b.fs.OptimizeOn.il.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03b.fs.OptimizeOn.il.release.bsl @@ -69,8 +69,9 @@ .maxstack 4 .locals init (int32 V_0, class [runtime]System.Exception V_1, - class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 V_2, - class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 V_3) + object V_2, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 V_3, + class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 V_4) .try { IL_0000: nop @@ -83,32 +84,40 @@ } catch [runtime]System.Object { - IL_0012: castclass [runtime]System.Exception - IL_0017: stloc.1 - IL_0018: ldloc.1 - IL_0019: call class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailurePattern(class [runtime]System.Exception) - IL_001e: stloc.2 - IL_001f: ldloc.2 - IL_0020: brfalse.s IL_003b - - IL_0022: ldstr "World" - IL_0027: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) - IL_002c: stloc.3 - IL_002d: call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out() - IL_0032: ldloc.3 - IL_0033: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(class [runtime]System.IO.TextWriter, + IL_0012: stloc.2 + IL_0013: ldloc.2 + IL_0014: isinst [runtime]System.Exception + IL_0019: dup + IL_001a: brtrue.s IL_0023 + + IL_001c: pop + IL_001d: ldloc.2 + IL_001e: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0023: stloc.1 + IL_0024: ldloc.1 + IL_0025: call class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailurePattern(class [runtime]System.Exception) + IL_002a: stloc.3 + IL_002b: ldloc.3 + IL_002c: brfalse.s IL_0049 + + IL_002e: ldstr "World" + IL_0033: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) + IL_0038: stloc.s V_4 + IL_003a: call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out() + IL_003f: ldloc.s V_4 + IL_0041: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(class [runtime]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) - IL_0038: pop - IL_0039: leave.s IL_0046 + IL_0046: pop + IL_0047: leave.s IL_0054 - IL_003b: rethrow - IL_003d: ldnull - IL_003e: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_0043: pop - IL_0044: leave.s IL_0046 + IL_0049: rethrow + IL_004b: ldnull + IL_004c: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_0051: pop + IL_0052: leave.s IL_0054 } - IL_0046: ret + IL_0054: ret } } @@ -130,4 +139,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03c.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03c.fs.OptimizeOff.il.bsl index 0eeedf099d9..874369edcad 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03c.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03c.fs.OptimizeOff.il.bsl @@ -8,7 +8,7 @@ .assembly extern netstandard { .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) - .ver 2:0:0:0 + .ver 2:1:0:0 } .assembly assembly { @@ -21,16 +21,6 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.exe @@ -73,9 +63,10 @@ .locals init (int32 V_0, string V_1, class [runtime]System.Exception V_2, - class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 V_3, - string V_4, - string V_5) + object V_3, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 V_4, + string V_5, + string V_6) .try { IL_0000: nop @@ -90,40 +81,48 @@ } catch [runtime]System.Object { - IL_0014: castclass [runtime]System.Exception - IL_0019: stloc.2 - IL_001a: ldloc.2 - IL_001b: call class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailurePattern(class [runtime]System.Exception) - IL_0020: stloc.3 - IL_0021: ldloc.3 - IL_0022: brfalse.s IL_0054 - - IL_0024: ldloc.3 - IL_0025: call instance !0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1::get_Value() - IL_002a: stloc.s V_4 - IL_002c: ldloc.s V_4 - IL_002e: ldstr "hello" - IL_0033: call bool [netstandard]System.String::Equals(string, + IL_0014: stloc.3 + IL_0015: ldloc.3 + IL_0016: isinst [runtime]System.Exception + IL_001b: dup + IL_001c: brtrue.s IL_0025 + + IL_001e: pop + IL_001f: ldloc.3 + IL_0020: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0025: stloc.2 + IL_0026: ldloc.2 + IL_0027: call class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailurePattern(class [runtime]System.Exception) + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_0064 + + IL_0032: ldloc.s V_4 + IL_0034: call instance !0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1::get_Value() + IL_0039: stloc.s V_5 + IL_003b: ldloc.s V_5 + IL_003d: ldstr "hello" + IL_0042: call bool [netstandard]System.String::Equals(string, string) - IL_0038: brfalse.s IL_0054 - - IL_003a: ldloc.3 - IL_003b: call instance !0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1::get_Value() - IL_0040: stloc.s V_5 - IL_0042: ldstr "World" - IL_0047: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) - IL_004c: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) - IL_0051: pop - IL_0052: leave.s IL_005f - - IL_0054: rethrow - IL_0056: ldnull - IL_0057: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_005c: pop - IL_005d: leave.s IL_005f + IL_0047: brfalse.s IL_0064 + + IL_0049: ldloc.s V_4 + IL_004b: call instance !0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1::get_Value() + IL_0050: stloc.s V_6 + IL_0052: ldstr "World" + IL_0057: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) + IL_005c: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_0061: pop + IL_0062: leave.s IL_006f + + IL_0064: rethrow + IL_0066: ldnull + IL_0067: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_006c: pop + IL_006d: leave.s IL_006f } - IL_005f: ret + IL_006f: ret } } @@ -145,4 +144,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03c.fs.OptimizeOn.il.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03c.fs.OptimizeOn.il.release.bsl index ad3903afb89..81ed78377b1 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03c.fs.OptimizeOn.il.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction03c.fs.OptimizeOn.il.release.bsl @@ -69,9 +69,10 @@ .maxstack 4 .locals init (int32 V_0, class [runtime]System.Exception V_1, - class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 V_2, - string V_3, - class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 V_4) + object V_2, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 V_3, + string V_4, + class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 V_5) .try { IL_0000: nop @@ -84,42 +85,50 @@ } catch [runtime]System.Object { - IL_0012: castclass [runtime]System.Exception - IL_0017: stloc.1 - IL_0018: ldloc.1 - IL_0019: call class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailurePattern(class [runtime]System.Exception) - IL_001e: stloc.2 - IL_001f: ldloc.2 - IL_0020: brfalse.s IL_0056 - - IL_0022: ldloc.2 - IL_0023: call instance !0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1::get_Value() - IL_0028: ldstr "hello" - IL_002d: call bool [netstandard]System.String::Equals(string, + IL_0012: stloc.2 + IL_0013: ldloc.2 + IL_0014: isinst [runtime]System.Exception + IL_0019: dup + IL_001a: brtrue.s IL_0023 + + IL_001c: pop + IL_001d: ldloc.2 + IL_001e: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0023: stloc.1 + IL_0024: ldloc.1 + IL_0025: call class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailurePattern(class [runtime]System.Exception) + IL_002a: stloc.3 + IL_002b: ldloc.3 + IL_002c: brfalse.s IL_0063 + + IL_002e: ldloc.3 + IL_002f: call instance !0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1::get_Value() + IL_0034: ldstr "hello" + IL_0039: call bool [netstandard]System.String::Equals(string, string) - IL_0032: brfalse.s IL_0056 - - IL_0034: ldloc.2 - IL_0035: call instance !0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1::get_Value() - IL_003a: stloc.3 - IL_003b: ldstr "World" - IL_0040: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) - IL_0045: stloc.s V_4 - IL_0047: call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out() - IL_004c: ldloc.s V_4 - IL_004e: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(class [runtime]System.IO.TextWriter, + IL_003e: brfalse.s IL_0063 + + IL_0040: ldloc.3 + IL_0041: call instance !0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1::get_Value() + IL_0046: stloc.s V_4 + IL_0048: ldstr "World" + IL_004d: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) + IL_0052: stloc.s V_5 + IL_0054: call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out() + IL_0059: ldloc.s V_5 + IL_005b: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(class [runtime]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) - IL_0053: pop - IL_0054: leave.s IL_0061 + IL_0060: pop + IL_0061: leave.s IL_006e - IL_0056: rethrow - IL_0058: ldnull - IL_0059: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_005e: pop - IL_005f: leave.s IL_0061 + IL_0063: rethrow + IL_0065: ldnull + IL_0066: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_006b: pop + IL_006c: leave.s IL_006e } - IL_0061: ret + IL_006e: ret } } @@ -141,4 +150,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOff.OptimizeOff.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOff.OptimizeOff.il.netcore.bsl index 0a339bb2ae3..85bc9432bed 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOff.OptimizeOff.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOff.OptimizeOff.il.netcore.bsl @@ -37,272 +37,344 @@ .method public static void test1() cil managed { - .maxstack 3 - .locals init (class [runtime]System.Exception V_0) + .maxstack 4 + .locals init (class [runtime]System.Exception V_0, + object V_1) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_0015 + IL_0006: leave.s IL_0021 } catch [runtime]System.Object { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: call void [runtime]System.Console::WriteLine() - IL_0013: leave.s IL_0015 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: call void [runtime]System.Console::WriteLine() + IL_001f: leave.s IL_0021 } - IL_0015: ret + IL_0021: ret } .method public static void test2() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.ArgumentException V_1, - class [runtime]System.Exception V_2, - class [runtime]System.ArgumentException V_3) + object V_1, + class [runtime]System.ArgumentException V_2, + class [runtime]System.Exception V_3, + object V_4, + class [runtime]System.ArgumentException V_5) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_0042 + IL_0006: leave.s IL_005f } filter { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [runtime]System.ArgumentException - IL_0014: stloc.1 - IL_0015: ldloc.1 - IL_0016: brfalse.s IL_001c - - IL_0018: ldc.i4.1 - IL_0019: nop - IL_001a: br.s IL_001e - - IL_001c: ldc.i4.0 - IL_001d: nop - IL_001e: endfilter + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: isinst [runtime]System.ArgumentException + IL_0020: stloc.2 + IL_0021: ldloc.2 + IL_0022: brfalse.s IL_0028 + + IL_0024: ldc.i4.1 + IL_0025: nop + IL_0026: br.s IL_002a + + IL_0028: ldc.i4.0 + IL_0029: nop + IL_002a: endfilter } { - IL_0020: castclass [runtime]System.Exception - IL_0025: stloc.2 - IL_0026: ldloc.2 - IL_0027: isinst [runtime]System.ArgumentException - IL_002c: stloc.3 - IL_002d: ldloc.3 - IL_002e: brfalse.s IL_0037 - - IL_0030: call void [runtime]System.Console::WriteLine() - IL_0035: leave.s IL_0042 - - IL_0037: rethrow - IL_0039: ldnull - IL_003a: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_003f: pop - IL_0040: leave.s IL_0042 + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: isinst [runtime]System.Exception + IL_0035: dup + IL_0036: brtrue.s IL_0040 + + IL_0038: pop + IL_0039: ldloc.s V_4 + IL_003b: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0040: stloc.3 + IL_0041: ldloc.3 + IL_0042: isinst [runtime]System.ArgumentException + IL_0047: stloc.s V_5 + IL_0049: ldloc.s V_5 + IL_004b: brfalse.s IL_0054 + + IL_004d: call void [runtime]System.Console::WriteLine() + IL_0052: leave.s IL_005f + + IL_0054: rethrow + IL_0056: ldnull + IL_0057: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_005c: pop + IL_005d: leave.s IL_005f } - IL_0042: ret + IL_005f: ret } .method public static void test3() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.ArgumentException V_1, + object V_1, class [runtime]System.ArgumentException V_2, - class [runtime]System.Exception V_3, - class [runtime]System.ArgumentException V_4, - class [runtime]System.ArgumentException V_5) + class [runtime]System.ArgumentException V_3, + class [runtime]System.Exception V_4, + object V_5, + class [runtime]System.ArgumentException V_6, + class [runtime]System.ArgumentException V_7) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_0051 + IL_0006: leave.s IL_006e } filter { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [runtime]System.ArgumentException - IL_0014: stloc.1 - IL_0015: ldloc.1 - IL_0016: brfalse.s IL_001e - - IL_0018: ldloc.1 - IL_0019: stloc.2 - IL_001a: ldc.i4.1 - IL_001b: nop - IL_001c: br.s IL_0020 - - IL_001e: ldc.i4.0 - IL_001f: nop - IL_0020: endfilter + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: isinst [runtime]System.ArgumentException + IL_0020: stloc.2 + IL_0021: ldloc.2 + IL_0022: brfalse.s IL_002a + + IL_0024: ldloc.2 + IL_0025: stloc.3 + IL_0026: ldc.i4.1 + IL_0027: nop + IL_0028: br.s IL_002c + + IL_002a: ldc.i4.0 + IL_002b: nop + IL_002c: endfilter } { - IL_0022: castclass [runtime]System.Exception - IL_0027: stloc.3 - IL_0028: ldloc.3 - IL_0029: isinst [runtime]System.ArgumentException - IL_002e: stloc.s V_4 - IL_0030: ldloc.s V_4 - IL_0032: brfalse.s IL_0046 - - IL_0034: ldloc.s V_4 - IL_0036: stloc.s V_5 - IL_0038: ldloc.s V_5 - IL_003a: callvirt instance string [runtime]System.Exception::get_Message() - IL_003f: call void [runtime]System.Console::WriteLine(string) - IL_0044: leave.s IL_0051 - - IL_0046: rethrow - IL_0048: ldnull - IL_0049: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_004e: pop - IL_004f: leave.s IL_0051 + IL_002e: stloc.s V_5 + IL_0030: ldloc.s V_5 + IL_0032: isinst [runtime]System.Exception + IL_0037: dup + IL_0038: brtrue.s IL_0042 + + IL_003a: pop + IL_003b: ldloc.s V_5 + IL_003d: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0042: stloc.s V_4 + IL_0044: ldloc.s V_4 + IL_0046: isinst [runtime]System.ArgumentException + IL_004b: stloc.s V_6 + IL_004d: ldloc.s V_6 + IL_004f: brfalse.s IL_0063 + + IL_0051: ldloc.s V_6 + IL_0053: stloc.s V_7 + IL_0055: ldloc.s V_7 + IL_0057: callvirt instance string [runtime]System.Exception::get_Message() + IL_005c: call void [runtime]System.Console::WriteLine(string) + IL_0061: leave.s IL_006e + + IL_0063: rethrow + IL_0065: ldnull + IL_0066: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_006b: pop + IL_006c: leave.s IL_006e } - IL_0051: ret + IL_006e: ret } .method public static void test4() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException V_1, - string V_2, - class [runtime]System.Exception V_3, - class [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException V_4, - string V_5) + object V_1, + class [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException V_2, + string V_3, + class [runtime]System.Exception V_4, + object V_5, + class [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException V_6, + string V_7) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_005f + IL_0006: leave IL_0080 } filter { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0014: stloc.1 - IL_0015: ldloc.1 - IL_0016: brfalse.s IL_0028 - - IL_0018: ldloc.0 - IL_0019: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_001e: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_000b: stloc.1 + IL_000c: ldloc.1 + IL_000d: isinst [runtime]System.Exception + IL_0012: dup + IL_0013: brtrue.s IL_001c + + IL_0015: pop + IL_0016: ldloc.1 + IL_0017: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_001c: stloc.0 + IL_001d: ldloc.0 + IL_001e: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException IL_0023: stloc.2 - IL_0024: ldc.i4.1 - IL_0025: nop - IL_0026: br.s IL_002a - - IL_0028: ldc.i4.0 - IL_0029: nop - IL_002a: endfilter + IL_0024: ldloc.2 + IL_0025: brfalse.s IL_0037 + + IL_0027: ldloc.0 + IL_0028: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_002d: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_0032: stloc.3 + IL_0033: ldc.i4.1 + IL_0034: nop + IL_0035: br.s IL_0039 + + IL_0037: ldc.i4.0 + IL_0038: nop + IL_0039: endfilter } { - IL_002c: castclass [runtime]System.Exception - IL_0031: stloc.3 - IL_0032: ldloc.3 - IL_0033: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0038: stloc.s V_4 - IL_003a: ldloc.s V_4 - IL_003c: brfalse.s IL_0054 - - IL_003e: ldloc.3 - IL_003f: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0044: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() - IL_0049: stloc.s V_5 - IL_004b: ldloc.s V_5 - IL_004d: call void [runtime]System.Console::WriteLine(string) - IL_0052: leave.s IL_005f - - IL_0054: rethrow - IL_0056: ldnull - IL_0057: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_005c: pop - IL_005d: leave.s IL_005f + IL_003b: stloc.s V_5 + IL_003d: ldloc.s V_5 + IL_003f: isinst [runtime]System.Exception + IL_0044: dup + IL_0045: brtrue.s IL_004f + + IL_0047: pop + IL_0048: ldloc.s V_5 + IL_004a: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_004f: stloc.s V_4 + IL_0051: ldloc.s V_4 + IL_0053: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0058: stloc.s V_6 + IL_005a: ldloc.s V_6 + IL_005c: brfalse.s IL_0075 + + IL_005e: ldloc.s V_4 + IL_0060: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0065: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_006a: stloc.s V_7 + IL_006c: ldloc.s V_7 + IL_006e: call void [runtime]System.Console::WriteLine(string) + IL_0073: leave.s IL_0080 + + IL_0075: rethrow + IL_0077: ldnull + IL_0078: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_007d: pop + IL_007e: leave.s IL_0080 } - IL_005f: ret + IL_0080: ret } .method public static void test5() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, object V_1, object V_2, - class [runtime]System.ArgumentException V_3, - string V_4) + object V_3, + class [runtime]System.ArgumentException V_4, + string V_5) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_005f + IL_0006: leave.s IL_006d } catch [runtime]System.Object { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: stloc.1 - IL_0010: ldloc.1 - IL_0011: isinst [runtime]System.ArgumentException - IL_0016: ldnull - IL_0017: cgt.un - IL_0019: brtrue.s IL_002a - - IL_001b: ldloc.0 - IL_001c: stloc.2 - IL_001d: ldloc.2 - IL_001e: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0023: ldnull - IL_0024: cgt.un - IL_0026: brfalse.s IL_0054 - - IL_0028: br.s IL_003e - - IL_002a: ldloc.0 - IL_002b: unbox.any [runtime]System.ArgumentException - IL_0030: stloc.3 - IL_0031: ldloc.3 - IL_0032: callvirt instance string [runtime]System.Exception::get_Message() - IL_0037: call void [runtime]System.Console::WriteLine(string) - IL_003c: leave.s IL_005f - - IL_003e: ldloc.0 - IL_003f: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0044: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() - IL_0049: stloc.s V_4 - IL_004b: ldloc.s V_4 - IL_004d: call void [runtime]System.Console::WriteLine(string) - IL_0052: leave.s IL_005f - - IL_0054: rethrow - IL_0056: ldnull - IL_0057: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_005c: pop - IL_005d: leave.s IL_005f + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: stloc.2 + IL_001c: ldloc.2 + IL_001d: isinst [runtime]System.ArgumentException + IL_0022: ldnull + IL_0023: cgt.un + IL_0025: brtrue.s IL_0036 + + IL_0027: ldloc.0 + IL_0028: stloc.3 + IL_0029: ldloc.3 + IL_002a: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_002f: ldnull + IL_0030: cgt.un + IL_0032: brfalse.s IL_0062 + + IL_0034: br.s IL_004c + + IL_0036: ldloc.0 + IL_0037: unbox.any [runtime]System.ArgumentException + IL_003c: stloc.s V_4 + IL_003e: ldloc.s V_4 + IL_0040: callvirt instance string [runtime]System.Exception::get_Message() + IL_0045: call void [runtime]System.Console::WriteLine(string) + IL_004a: leave.s IL_006d + + IL_004c: ldloc.0 + IL_004d: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0052: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_0057: stloc.s V_5 + IL_0059: ldloc.s V_5 + IL_005b: call void [runtime]System.Console::WriteLine(string) + IL_0060: leave.s IL_006d + + IL_0062: rethrow + IL_0064: ldnull + IL_0065: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_006a: pop + IL_006b: leave.s IL_006d } - IL_005f: ret + IL_006d: ret } } @@ -324,4 +396,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOff.OptimizeOn.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOff.OptimizeOn.il.netcore.bsl index a73fda88e58..0c53e0105fb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOff.OptimizeOn.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOff.OptimizeOn.il.netcore.bsl @@ -37,254 +37,326 @@ .method public static void test1() cil managed { - .maxstack 3 - .locals init (class [runtime]System.Exception V_0) + .maxstack 4 + .locals init (class [runtime]System.Exception V_0, + object V_1) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_0015 + IL_0006: leave.s IL_0021 } catch [runtime]System.Object { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: call void [runtime]System.Console::WriteLine() - IL_0013: leave.s IL_0015 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: call void [runtime]System.Console::WriteLine() + IL_001f: leave.s IL_0021 } - IL_0015: ret + IL_0021: ret } .method public static void test2() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.ArgumentException V_1, - class [runtime]System.Exception V_2) + object V_1, + class [runtime]System.ArgumentException V_2, + class [runtime]System.Exception V_3, + object V_4) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_0042 + IL_0006: leave.s IL_005d } filter { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [runtime]System.ArgumentException - IL_0014: stloc.1 - IL_0015: ldloc.1 - IL_0016: brfalse.s IL_001c - - IL_0018: ldc.i4.1 - IL_0019: nop - IL_001a: br.s IL_001e - - IL_001c: ldc.i4.0 - IL_001d: nop - IL_001e: endfilter + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: isinst [runtime]System.ArgumentException + IL_0020: stloc.2 + IL_0021: ldloc.2 + IL_0022: brfalse.s IL_0028 + + IL_0024: ldc.i4.1 + IL_0025: nop + IL_0026: br.s IL_002a + + IL_0028: ldc.i4.0 + IL_0029: nop + IL_002a: endfilter } { - IL_0020: castclass [runtime]System.Exception - IL_0025: stloc.2 - IL_0026: ldloc.2 - IL_0027: isinst [runtime]System.ArgumentException - IL_002c: stloc.1 - IL_002d: ldloc.1 - IL_002e: brfalse.s IL_0037 - - IL_0030: call void [runtime]System.Console::WriteLine() - IL_0035: leave.s IL_0042 - - IL_0037: rethrow - IL_0039: ldnull - IL_003a: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_003f: pop - IL_0040: leave.s IL_0042 + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: isinst [runtime]System.Exception + IL_0035: dup + IL_0036: brtrue.s IL_0040 + + IL_0038: pop + IL_0039: ldloc.s V_4 + IL_003b: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0040: stloc.3 + IL_0041: ldloc.3 + IL_0042: isinst [runtime]System.ArgumentException + IL_0047: stloc.2 + IL_0048: ldloc.2 + IL_0049: brfalse.s IL_0052 + + IL_004b: call void [runtime]System.Console::WriteLine() + IL_0050: leave.s IL_005d + + IL_0052: rethrow + IL_0054: ldnull + IL_0055: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_005a: pop + IL_005b: leave.s IL_005d } - IL_0042: ret + IL_005d: ret } .method public static void test3() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.ArgumentException V_1, + object V_1, class [runtime]System.ArgumentException V_2, - class [runtime]System.Exception V_3) + class [runtime]System.ArgumentException V_3, + class [runtime]System.Exception V_4, + object V_5) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_004c + IL_0006: leave.s IL_0069 } filter { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [runtime]System.ArgumentException - IL_0014: stloc.1 - IL_0015: ldloc.1 - IL_0016: brfalse.s IL_001e - - IL_0018: ldloc.1 - IL_0019: stloc.2 - IL_001a: ldc.i4.1 - IL_001b: nop - IL_001c: br.s IL_0020 - - IL_001e: ldc.i4.0 - IL_001f: nop - IL_0020: endfilter + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: isinst [runtime]System.ArgumentException + IL_0020: stloc.2 + IL_0021: ldloc.2 + IL_0022: brfalse.s IL_002a + + IL_0024: ldloc.2 + IL_0025: stloc.3 + IL_0026: ldc.i4.1 + IL_0027: nop + IL_0028: br.s IL_002c + + IL_002a: ldc.i4.0 + IL_002b: nop + IL_002c: endfilter } { - IL_0022: castclass [runtime]System.Exception - IL_0027: stloc.3 - IL_0028: ldloc.3 - IL_0029: isinst [runtime]System.ArgumentException - IL_002e: stloc.1 - IL_002f: ldloc.1 - IL_0030: brfalse.s IL_0041 - - IL_0032: ldloc.1 - IL_0033: stloc.2 - IL_0034: ldloc.2 - IL_0035: callvirt instance string [runtime]System.Exception::get_Message() - IL_003a: call void [runtime]System.Console::WriteLine(string) - IL_003f: leave.s IL_004c - - IL_0041: rethrow - IL_0043: ldnull - IL_0044: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_0049: pop - IL_004a: leave.s IL_004c + IL_002e: stloc.s V_5 + IL_0030: ldloc.s V_5 + IL_0032: isinst [runtime]System.Exception + IL_0037: dup + IL_0038: brtrue.s IL_0042 + + IL_003a: pop + IL_003b: ldloc.s V_5 + IL_003d: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0042: stloc.s V_4 + IL_0044: ldloc.s V_4 + IL_0046: isinst [runtime]System.ArgumentException + IL_004b: stloc.2 + IL_004c: ldloc.2 + IL_004d: brfalse.s IL_005e + + IL_004f: ldloc.2 + IL_0050: stloc.3 + IL_0051: ldloc.3 + IL_0052: callvirt instance string [runtime]System.Exception::get_Message() + IL_0057: call void [runtime]System.Console::WriteLine(string) + IL_005c: leave.s IL_0069 + + IL_005e: rethrow + IL_0060: ldnull + IL_0061: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_0066: pop + IL_0067: leave.s IL_0069 } - IL_004c: ret + IL_0069: ret } .method public static void test4() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException V_1, - string V_2, - class [runtime]System.Exception V_3) + object V_1, + class [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException V_2, + string V_3, + class [runtime]System.Exception V_4, + object V_5) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_005b + IL_0006: leave IL_007c } filter { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0014: stloc.1 - IL_0015: ldloc.1 - IL_0016: brfalse.s IL_0028 - - IL_0018: ldloc.0 - IL_0019: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_001e: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_000b: stloc.1 + IL_000c: ldloc.1 + IL_000d: isinst [runtime]System.Exception + IL_0012: dup + IL_0013: brtrue.s IL_001c + + IL_0015: pop + IL_0016: ldloc.1 + IL_0017: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_001c: stloc.0 + IL_001d: ldloc.0 + IL_001e: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException IL_0023: stloc.2 - IL_0024: ldc.i4.1 - IL_0025: nop - IL_0026: br.s IL_002a - - IL_0028: ldc.i4.0 - IL_0029: nop - IL_002a: endfilter + IL_0024: ldloc.2 + IL_0025: brfalse.s IL_0037 + + IL_0027: ldloc.0 + IL_0028: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_002d: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_0032: stloc.3 + IL_0033: ldc.i4.1 + IL_0034: nop + IL_0035: br.s IL_0039 + + IL_0037: ldc.i4.0 + IL_0038: nop + IL_0039: endfilter } { - IL_002c: castclass [runtime]System.Exception - IL_0031: stloc.3 - IL_0032: ldloc.3 - IL_0033: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0038: stloc.1 - IL_0039: ldloc.1 - IL_003a: brfalse.s IL_0050 - - IL_003c: ldloc.3 - IL_003d: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0042: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() - IL_0047: stloc.2 - IL_0048: ldloc.2 - IL_0049: call void [runtime]System.Console::WriteLine(string) - IL_004e: leave.s IL_005b - - IL_0050: rethrow - IL_0052: ldnull - IL_0053: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_0058: pop - IL_0059: leave.s IL_005b + IL_003b: stloc.s V_5 + IL_003d: ldloc.s V_5 + IL_003f: isinst [runtime]System.Exception + IL_0044: dup + IL_0045: brtrue.s IL_004f + + IL_0047: pop + IL_0048: ldloc.s V_5 + IL_004a: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_004f: stloc.s V_4 + IL_0051: ldloc.s V_4 + IL_0053: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0058: stloc.2 + IL_0059: ldloc.2 + IL_005a: brfalse.s IL_0071 + + IL_005c: ldloc.s V_4 + IL_005e: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0063: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_0068: stloc.3 + IL_0069: ldloc.3 + IL_006a: call void [runtime]System.Console::WriteLine(string) + IL_006f: leave.s IL_007c + + IL_0071: rethrow + IL_0073: ldnull + IL_0074: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_0079: pop + IL_007a: leave.s IL_007c } - IL_005b: ret + IL_007c: ret } .method public static void test5() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.ArgumentException V_1) + object V_1, + class [runtime]System.ArgumentException V_2) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_0051 + IL_0006: leave.s IL_005d } catch [runtime]System.Object { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [runtime]System.ArgumentException - IL_0014: brtrue.s IL_0020 - - IL_0016: ldloc.0 - IL_0017: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_001c: brfalse.s IL_0046 - - IL_001e: br.s IL_0034 - - IL_0020: ldloc.0 - IL_0021: unbox.any [runtime]System.ArgumentException - IL_0026: stloc.1 - IL_0027: ldloc.1 - IL_0028: callvirt instance string [runtime]System.Exception::get_Message() - IL_002d: call void [runtime]System.Console::WriteLine(string) - IL_0032: leave.s IL_0051 - - IL_0034: ldloc.0 - IL_0035: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_003a: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() - IL_003f: call void [runtime]System.Console::WriteLine(string) - IL_0044: leave.s IL_0051 - - IL_0046: rethrow - IL_0048: ldnull - IL_0049: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_004e: pop - IL_004f: leave.s IL_0051 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: isinst [runtime]System.ArgumentException + IL_0020: brtrue.s IL_002c + + IL_0022: ldloc.0 + IL_0023: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0028: brfalse.s IL_0052 + + IL_002a: br.s IL_0040 + + IL_002c: ldloc.0 + IL_002d: unbox.any [runtime]System.ArgumentException + IL_0032: stloc.2 + IL_0033: ldloc.2 + IL_0034: callvirt instance string [runtime]System.Exception::get_Message() + IL_0039: call void [runtime]System.Console::WriteLine(string) + IL_003e: leave.s IL_005d + + IL_0040: ldloc.0 + IL_0041: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0046: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_004b: call void [runtime]System.Console::WriteLine(string) + IL_0050: leave.s IL_005d + + IL_0052: rethrow + IL_0054: ldnull + IL_0055: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_005a: pop + IL_005b: leave.s IL_005d } - IL_0051: ret + IL_005d: ret } } @@ -306,4 +378,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOn.OptimizeOff.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOn.OptimizeOff.il.netcore.bsl index 0a339bb2ae3..85bc9432bed 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOn.OptimizeOff.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOn.OptimizeOff.il.netcore.bsl @@ -37,272 +37,344 @@ .method public static void test1() cil managed { - .maxstack 3 - .locals init (class [runtime]System.Exception V_0) + .maxstack 4 + .locals init (class [runtime]System.Exception V_0, + object V_1) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_0015 + IL_0006: leave.s IL_0021 } catch [runtime]System.Object { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: call void [runtime]System.Console::WriteLine() - IL_0013: leave.s IL_0015 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: call void [runtime]System.Console::WriteLine() + IL_001f: leave.s IL_0021 } - IL_0015: ret + IL_0021: ret } .method public static void test2() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.ArgumentException V_1, - class [runtime]System.Exception V_2, - class [runtime]System.ArgumentException V_3) + object V_1, + class [runtime]System.ArgumentException V_2, + class [runtime]System.Exception V_3, + object V_4, + class [runtime]System.ArgumentException V_5) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_0042 + IL_0006: leave.s IL_005f } filter { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [runtime]System.ArgumentException - IL_0014: stloc.1 - IL_0015: ldloc.1 - IL_0016: brfalse.s IL_001c - - IL_0018: ldc.i4.1 - IL_0019: nop - IL_001a: br.s IL_001e - - IL_001c: ldc.i4.0 - IL_001d: nop - IL_001e: endfilter + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: isinst [runtime]System.ArgumentException + IL_0020: stloc.2 + IL_0021: ldloc.2 + IL_0022: brfalse.s IL_0028 + + IL_0024: ldc.i4.1 + IL_0025: nop + IL_0026: br.s IL_002a + + IL_0028: ldc.i4.0 + IL_0029: nop + IL_002a: endfilter } { - IL_0020: castclass [runtime]System.Exception - IL_0025: stloc.2 - IL_0026: ldloc.2 - IL_0027: isinst [runtime]System.ArgumentException - IL_002c: stloc.3 - IL_002d: ldloc.3 - IL_002e: brfalse.s IL_0037 - - IL_0030: call void [runtime]System.Console::WriteLine() - IL_0035: leave.s IL_0042 - - IL_0037: rethrow - IL_0039: ldnull - IL_003a: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_003f: pop - IL_0040: leave.s IL_0042 + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: isinst [runtime]System.Exception + IL_0035: dup + IL_0036: brtrue.s IL_0040 + + IL_0038: pop + IL_0039: ldloc.s V_4 + IL_003b: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0040: stloc.3 + IL_0041: ldloc.3 + IL_0042: isinst [runtime]System.ArgumentException + IL_0047: stloc.s V_5 + IL_0049: ldloc.s V_5 + IL_004b: brfalse.s IL_0054 + + IL_004d: call void [runtime]System.Console::WriteLine() + IL_0052: leave.s IL_005f + + IL_0054: rethrow + IL_0056: ldnull + IL_0057: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_005c: pop + IL_005d: leave.s IL_005f } - IL_0042: ret + IL_005f: ret } .method public static void test3() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.ArgumentException V_1, + object V_1, class [runtime]System.ArgumentException V_2, - class [runtime]System.Exception V_3, - class [runtime]System.ArgumentException V_4, - class [runtime]System.ArgumentException V_5) + class [runtime]System.ArgumentException V_3, + class [runtime]System.Exception V_4, + object V_5, + class [runtime]System.ArgumentException V_6, + class [runtime]System.ArgumentException V_7) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_0051 + IL_0006: leave.s IL_006e } filter { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [runtime]System.ArgumentException - IL_0014: stloc.1 - IL_0015: ldloc.1 - IL_0016: brfalse.s IL_001e - - IL_0018: ldloc.1 - IL_0019: stloc.2 - IL_001a: ldc.i4.1 - IL_001b: nop - IL_001c: br.s IL_0020 - - IL_001e: ldc.i4.0 - IL_001f: nop - IL_0020: endfilter + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: isinst [runtime]System.ArgumentException + IL_0020: stloc.2 + IL_0021: ldloc.2 + IL_0022: brfalse.s IL_002a + + IL_0024: ldloc.2 + IL_0025: stloc.3 + IL_0026: ldc.i4.1 + IL_0027: nop + IL_0028: br.s IL_002c + + IL_002a: ldc.i4.0 + IL_002b: nop + IL_002c: endfilter } { - IL_0022: castclass [runtime]System.Exception - IL_0027: stloc.3 - IL_0028: ldloc.3 - IL_0029: isinst [runtime]System.ArgumentException - IL_002e: stloc.s V_4 - IL_0030: ldloc.s V_4 - IL_0032: brfalse.s IL_0046 - - IL_0034: ldloc.s V_4 - IL_0036: stloc.s V_5 - IL_0038: ldloc.s V_5 - IL_003a: callvirt instance string [runtime]System.Exception::get_Message() - IL_003f: call void [runtime]System.Console::WriteLine(string) - IL_0044: leave.s IL_0051 - - IL_0046: rethrow - IL_0048: ldnull - IL_0049: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_004e: pop - IL_004f: leave.s IL_0051 + IL_002e: stloc.s V_5 + IL_0030: ldloc.s V_5 + IL_0032: isinst [runtime]System.Exception + IL_0037: dup + IL_0038: brtrue.s IL_0042 + + IL_003a: pop + IL_003b: ldloc.s V_5 + IL_003d: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0042: stloc.s V_4 + IL_0044: ldloc.s V_4 + IL_0046: isinst [runtime]System.ArgumentException + IL_004b: stloc.s V_6 + IL_004d: ldloc.s V_6 + IL_004f: brfalse.s IL_0063 + + IL_0051: ldloc.s V_6 + IL_0053: stloc.s V_7 + IL_0055: ldloc.s V_7 + IL_0057: callvirt instance string [runtime]System.Exception::get_Message() + IL_005c: call void [runtime]System.Console::WriteLine(string) + IL_0061: leave.s IL_006e + + IL_0063: rethrow + IL_0065: ldnull + IL_0066: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_006b: pop + IL_006c: leave.s IL_006e } - IL_0051: ret + IL_006e: ret } .method public static void test4() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException V_1, - string V_2, - class [runtime]System.Exception V_3, - class [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException V_4, - string V_5) + object V_1, + class [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException V_2, + string V_3, + class [runtime]System.Exception V_4, + object V_5, + class [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException V_6, + string V_7) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_005f + IL_0006: leave IL_0080 } filter { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0014: stloc.1 - IL_0015: ldloc.1 - IL_0016: brfalse.s IL_0028 - - IL_0018: ldloc.0 - IL_0019: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_001e: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_000b: stloc.1 + IL_000c: ldloc.1 + IL_000d: isinst [runtime]System.Exception + IL_0012: dup + IL_0013: brtrue.s IL_001c + + IL_0015: pop + IL_0016: ldloc.1 + IL_0017: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_001c: stloc.0 + IL_001d: ldloc.0 + IL_001e: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException IL_0023: stloc.2 - IL_0024: ldc.i4.1 - IL_0025: nop - IL_0026: br.s IL_002a - - IL_0028: ldc.i4.0 - IL_0029: nop - IL_002a: endfilter + IL_0024: ldloc.2 + IL_0025: brfalse.s IL_0037 + + IL_0027: ldloc.0 + IL_0028: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_002d: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_0032: stloc.3 + IL_0033: ldc.i4.1 + IL_0034: nop + IL_0035: br.s IL_0039 + + IL_0037: ldc.i4.0 + IL_0038: nop + IL_0039: endfilter } { - IL_002c: castclass [runtime]System.Exception - IL_0031: stloc.3 - IL_0032: ldloc.3 - IL_0033: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0038: stloc.s V_4 - IL_003a: ldloc.s V_4 - IL_003c: brfalse.s IL_0054 - - IL_003e: ldloc.3 - IL_003f: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0044: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() - IL_0049: stloc.s V_5 - IL_004b: ldloc.s V_5 - IL_004d: call void [runtime]System.Console::WriteLine(string) - IL_0052: leave.s IL_005f - - IL_0054: rethrow - IL_0056: ldnull - IL_0057: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_005c: pop - IL_005d: leave.s IL_005f + IL_003b: stloc.s V_5 + IL_003d: ldloc.s V_5 + IL_003f: isinst [runtime]System.Exception + IL_0044: dup + IL_0045: brtrue.s IL_004f + + IL_0047: pop + IL_0048: ldloc.s V_5 + IL_004a: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_004f: stloc.s V_4 + IL_0051: ldloc.s V_4 + IL_0053: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0058: stloc.s V_6 + IL_005a: ldloc.s V_6 + IL_005c: brfalse.s IL_0075 + + IL_005e: ldloc.s V_4 + IL_0060: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0065: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_006a: stloc.s V_7 + IL_006c: ldloc.s V_7 + IL_006e: call void [runtime]System.Console::WriteLine(string) + IL_0073: leave.s IL_0080 + + IL_0075: rethrow + IL_0077: ldnull + IL_0078: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_007d: pop + IL_007e: leave.s IL_0080 } - IL_005f: ret + IL_0080: ret } .method public static void test5() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, object V_1, object V_2, - class [runtime]System.ArgumentException V_3, - string V_4) + object V_3, + class [runtime]System.ArgumentException V_4, + string V_5) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_005f + IL_0006: leave.s IL_006d } catch [runtime]System.Object { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: stloc.1 - IL_0010: ldloc.1 - IL_0011: isinst [runtime]System.ArgumentException - IL_0016: ldnull - IL_0017: cgt.un - IL_0019: brtrue.s IL_002a - - IL_001b: ldloc.0 - IL_001c: stloc.2 - IL_001d: ldloc.2 - IL_001e: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0023: ldnull - IL_0024: cgt.un - IL_0026: brfalse.s IL_0054 - - IL_0028: br.s IL_003e - - IL_002a: ldloc.0 - IL_002b: unbox.any [runtime]System.ArgumentException - IL_0030: stloc.3 - IL_0031: ldloc.3 - IL_0032: callvirt instance string [runtime]System.Exception::get_Message() - IL_0037: call void [runtime]System.Console::WriteLine(string) - IL_003c: leave.s IL_005f - - IL_003e: ldloc.0 - IL_003f: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0044: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() - IL_0049: stloc.s V_4 - IL_004b: ldloc.s V_4 - IL_004d: call void [runtime]System.Console::WriteLine(string) - IL_0052: leave.s IL_005f - - IL_0054: rethrow - IL_0056: ldnull - IL_0057: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_005c: pop - IL_005d: leave.s IL_005f + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: stloc.2 + IL_001c: ldloc.2 + IL_001d: isinst [runtime]System.ArgumentException + IL_0022: ldnull + IL_0023: cgt.un + IL_0025: brtrue.s IL_0036 + + IL_0027: ldloc.0 + IL_0028: stloc.3 + IL_0029: ldloc.3 + IL_002a: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_002f: ldnull + IL_0030: cgt.un + IL_0032: brfalse.s IL_0062 + + IL_0034: br.s IL_004c + + IL_0036: ldloc.0 + IL_0037: unbox.any [runtime]System.ArgumentException + IL_003c: stloc.s V_4 + IL_003e: ldloc.s V_4 + IL_0040: callvirt instance string [runtime]System.Exception::get_Message() + IL_0045: call void [runtime]System.Console::WriteLine(string) + IL_004a: leave.s IL_006d + + IL_004c: ldloc.0 + IL_004d: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0052: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_0057: stloc.s V_5 + IL_0059: ldloc.s V_5 + IL_005b: call void [runtime]System.Console::WriteLine(string) + IL_0060: leave.s IL_006d + + IL_0062: rethrow + IL_0064: ldnull + IL_0065: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_006a: pop + IL_006b: leave.s IL_006d } - IL_005f: ret + IL_006d: ret } } @@ -324,4 +396,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOn.OptimizeOn.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOn.OptimizeOn.il.netcore.bsl index a73fda88e58..0c53e0105fb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOn.OptimizeOn.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction22h.fs.RealInternalSignatureOn.OptimizeOn.il.netcore.bsl @@ -37,254 +37,326 @@ .method public static void test1() cil managed { - .maxstack 3 - .locals init (class [runtime]System.Exception V_0) + .maxstack 4 + .locals init (class [runtime]System.Exception V_0, + object V_1) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_0015 + IL_0006: leave.s IL_0021 } catch [runtime]System.Object { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: call void [runtime]System.Console::WriteLine() - IL_0013: leave.s IL_0015 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: call void [runtime]System.Console::WriteLine() + IL_001f: leave.s IL_0021 } - IL_0015: ret + IL_0021: ret } .method public static void test2() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.ArgumentException V_1, - class [runtime]System.Exception V_2) + object V_1, + class [runtime]System.ArgumentException V_2, + class [runtime]System.Exception V_3, + object V_4) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_0042 + IL_0006: leave.s IL_005d } filter { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [runtime]System.ArgumentException - IL_0014: stloc.1 - IL_0015: ldloc.1 - IL_0016: brfalse.s IL_001c - - IL_0018: ldc.i4.1 - IL_0019: nop - IL_001a: br.s IL_001e - - IL_001c: ldc.i4.0 - IL_001d: nop - IL_001e: endfilter + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: isinst [runtime]System.ArgumentException + IL_0020: stloc.2 + IL_0021: ldloc.2 + IL_0022: brfalse.s IL_0028 + + IL_0024: ldc.i4.1 + IL_0025: nop + IL_0026: br.s IL_002a + + IL_0028: ldc.i4.0 + IL_0029: nop + IL_002a: endfilter } { - IL_0020: castclass [runtime]System.Exception - IL_0025: stloc.2 - IL_0026: ldloc.2 - IL_0027: isinst [runtime]System.ArgumentException - IL_002c: stloc.1 - IL_002d: ldloc.1 - IL_002e: brfalse.s IL_0037 - - IL_0030: call void [runtime]System.Console::WriteLine() - IL_0035: leave.s IL_0042 - - IL_0037: rethrow - IL_0039: ldnull - IL_003a: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_003f: pop - IL_0040: leave.s IL_0042 + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: isinst [runtime]System.Exception + IL_0035: dup + IL_0036: brtrue.s IL_0040 + + IL_0038: pop + IL_0039: ldloc.s V_4 + IL_003b: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0040: stloc.3 + IL_0041: ldloc.3 + IL_0042: isinst [runtime]System.ArgumentException + IL_0047: stloc.2 + IL_0048: ldloc.2 + IL_0049: brfalse.s IL_0052 + + IL_004b: call void [runtime]System.Console::WriteLine() + IL_0050: leave.s IL_005d + + IL_0052: rethrow + IL_0054: ldnull + IL_0055: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_005a: pop + IL_005b: leave.s IL_005d } - IL_0042: ret + IL_005d: ret } .method public static void test3() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.ArgumentException V_1, + object V_1, class [runtime]System.ArgumentException V_2, - class [runtime]System.Exception V_3) + class [runtime]System.ArgumentException V_3, + class [runtime]System.Exception V_4, + object V_5) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_004c + IL_0006: leave.s IL_0069 } filter { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [runtime]System.ArgumentException - IL_0014: stloc.1 - IL_0015: ldloc.1 - IL_0016: brfalse.s IL_001e - - IL_0018: ldloc.1 - IL_0019: stloc.2 - IL_001a: ldc.i4.1 - IL_001b: nop - IL_001c: br.s IL_0020 - - IL_001e: ldc.i4.0 - IL_001f: nop - IL_0020: endfilter + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: isinst [runtime]System.ArgumentException + IL_0020: stloc.2 + IL_0021: ldloc.2 + IL_0022: brfalse.s IL_002a + + IL_0024: ldloc.2 + IL_0025: stloc.3 + IL_0026: ldc.i4.1 + IL_0027: nop + IL_0028: br.s IL_002c + + IL_002a: ldc.i4.0 + IL_002b: nop + IL_002c: endfilter } { - IL_0022: castclass [runtime]System.Exception - IL_0027: stloc.3 - IL_0028: ldloc.3 - IL_0029: isinst [runtime]System.ArgumentException - IL_002e: stloc.1 - IL_002f: ldloc.1 - IL_0030: brfalse.s IL_0041 - - IL_0032: ldloc.1 - IL_0033: stloc.2 - IL_0034: ldloc.2 - IL_0035: callvirt instance string [runtime]System.Exception::get_Message() - IL_003a: call void [runtime]System.Console::WriteLine(string) - IL_003f: leave.s IL_004c - - IL_0041: rethrow - IL_0043: ldnull - IL_0044: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_0049: pop - IL_004a: leave.s IL_004c + IL_002e: stloc.s V_5 + IL_0030: ldloc.s V_5 + IL_0032: isinst [runtime]System.Exception + IL_0037: dup + IL_0038: brtrue.s IL_0042 + + IL_003a: pop + IL_003b: ldloc.s V_5 + IL_003d: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0042: stloc.s V_4 + IL_0044: ldloc.s V_4 + IL_0046: isinst [runtime]System.ArgumentException + IL_004b: stloc.2 + IL_004c: ldloc.2 + IL_004d: brfalse.s IL_005e + + IL_004f: ldloc.2 + IL_0050: stloc.3 + IL_0051: ldloc.3 + IL_0052: callvirt instance string [runtime]System.Exception::get_Message() + IL_0057: call void [runtime]System.Console::WriteLine(string) + IL_005c: leave.s IL_0069 + + IL_005e: rethrow + IL_0060: ldnull + IL_0061: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_0066: pop + IL_0067: leave.s IL_0069 } - IL_004c: ret + IL_0069: ret } .method public static void test4() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException V_1, - string V_2, - class [runtime]System.Exception V_3) + object V_1, + class [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException V_2, + string V_3, + class [runtime]System.Exception V_4, + object V_5) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_005b + IL_0006: leave IL_007c } filter { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0014: stloc.1 - IL_0015: ldloc.1 - IL_0016: brfalse.s IL_0028 - - IL_0018: ldloc.0 - IL_0019: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_001e: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_000b: stloc.1 + IL_000c: ldloc.1 + IL_000d: isinst [runtime]System.Exception + IL_0012: dup + IL_0013: brtrue.s IL_001c + + IL_0015: pop + IL_0016: ldloc.1 + IL_0017: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_001c: stloc.0 + IL_001d: ldloc.0 + IL_001e: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException IL_0023: stloc.2 - IL_0024: ldc.i4.1 - IL_0025: nop - IL_0026: br.s IL_002a - - IL_0028: ldc.i4.0 - IL_0029: nop - IL_002a: endfilter + IL_0024: ldloc.2 + IL_0025: brfalse.s IL_0037 + + IL_0027: ldloc.0 + IL_0028: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_002d: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_0032: stloc.3 + IL_0033: ldc.i4.1 + IL_0034: nop + IL_0035: br.s IL_0039 + + IL_0037: ldc.i4.0 + IL_0038: nop + IL_0039: endfilter } { - IL_002c: castclass [runtime]System.Exception - IL_0031: stloc.3 - IL_0032: ldloc.3 - IL_0033: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0038: stloc.1 - IL_0039: ldloc.1 - IL_003a: brfalse.s IL_0050 - - IL_003c: ldloc.3 - IL_003d: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_0042: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() - IL_0047: stloc.2 - IL_0048: ldloc.2 - IL_0049: call void [runtime]System.Console::WriteLine(string) - IL_004e: leave.s IL_005b - - IL_0050: rethrow - IL_0052: ldnull - IL_0053: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_0058: pop - IL_0059: leave.s IL_005b + IL_003b: stloc.s V_5 + IL_003d: ldloc.s V_5 + IL_003f: isinst [runtime]System.Exception + IL_0044: dup + IL_0045: brtrue.s IL_004f + + IL_0047: pop + IL_0048: ldloc.s V_5 + IL_004a: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_004f: stloc.s V_4 + IL_0051: ldloc.s V_4 + IL_0053: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0058: stloc.2 + IL_0059: ldloc.2 + IL_005a: brfalse.s IL_0071 + + IL_005c: ldloc.s V_4 + IL_005e: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0063: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_0068: stloc.3 + IL_0069: ldloc.3 + IL_006a: call void [runtime]System.Console::WriteLine(string) + IL_006f: leave.s IL_007c + + IL_0071: rethrow + IL_0073: ldnull + IL_0074: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_0079: pop + IL_007a: leave.s IL_007c } - IL_005b: ret + IL_007c: ret } .method public static void test5() cil managed { - .maxstack 3 + .maxstack 4 .locals init (class [runtime]System.Exception V_0, - class [runtime]System.ArgumentException V_1) + object V_1, + class [runtime]System.ArgumentException V_2) .try { IL_0000: nop IL_0001: call void [runtime]System.Console::WriteLine() - IL_0006: leave.s IL_0051 + IL_0006: leave.s IL_005d } catch [runtime]System.Object { - IL_0008: castclass [runtime]System.Exception - IL_000d: stloc.0 - IL_000e: ldloc.0 - IL_000f: isinst [runtime]System.ArgumentException - IL_0014: brtrue.s IL_0020 - - IL_0016: ldloc.0 - IL_0017: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_001c: brfalse.s IL_0046 - - IL_001e: br.s IL_0034 - - IL_0020: ldloc.0 - IL_0021: unbox.any [runtime]System.ArgumentException - IL_0026: stloc.1 - IL_0027: ldloc.1 - IL_0028: callvirt instance string [runtime]System.Exception::get_Message() - IL_002d: call void [runtime]System.Console::WriteLine(string) - IL_0032: leave.s IL_0051 - - IL_0034: ldloc.0 - IL_0035: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException - IL_003a: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() - IL_003f: call void [runtime]System.Console::WriteLine(string) - IL_0044: leave.s IL_0051 - - IL_0046: rethrow - IL_0048: ldnull - IL_0049: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit - IL_004e: pop - IL_004f: leave.s IL_0051 + IL_0008: stloc.1 + IL_0009: ldloc.1 + IL_000a: isinst [runtime]System.Exception + IL_000f: dup + IL_0010: brtrue.s IL_0019 + + IL_0012: pop + IL_0013: ldloc.1 + IL_0014: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0019: stloc.0 + IL_001a: ldloc.0 + IL_001b: isinst [runtime]System.ArgumentException + IL_0020: brtrue.s IL_002c + + IL_0022: ldloc.0 + IL_0023: isinst [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0028: brfalse.s IL_0052 + + IL_002a: br.s IL_0040 + + IL_002c: ldloc.0 + IL_002d: unbox.any [runtime]System.ArgumentException + IL_0032: stloc.2 + IL_0033: ldloc.2 + IL_0034: callvirt instance string [runtime]System.Exception::get_Message() + IL_0039: call void [runtime]System.Console::WriteLine(string) + IL_003e: leave.s IL_005d + + IL_0040: ldloc.0 + IL_0041: castclass [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException + IL_0046: call instance string [FSharp.Core]Microsoft.FSharp.Core.MatchFailureException::get_Data0() + IL_004b: call void [runtime]System.Console::WriteLine(string) + IL_0050: leave.s IL_005d + + IL_0052: rethrow + IL_0054: ldnull + IL_0055: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit + IL_005a: pop + IL_005b: leave.s IL_005d } - IL_0051: ret + IL_005d: ret } } @@ -306,4 +378,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/ActivePatternRecoverableException.fs.generateFilterBlocks.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/ActivePatternRecoverableException.fs.generateFilterBlocks.il.bsl index 170695eb40f..5b62a1fc622 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/ActivePatternRecoverableException.fs.generateFilterBlocks.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/ActivePatternRecoverableException.fs.generateFilterBlocks.il.bsl @@ -58,70 +58,88 @@ .maxstack 4 .locals init (int32 V_0, class [runtime]System.Exception V_1, - valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1 V_2, - class [runtime]System.Exception V_3, + object V_2, + valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1 V_3, class [runtime]System.Exception V_4, - valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1 V_5, - class [runtime]System.Exception V_6) + class [runtime]System.Exception V_5, + object V_6, + valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1 V_7, + class [runtime]System.Exception V_8) .try { IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: div IL_0003: stloc.0 - IL_0004: leave.s IL_005f + IL_0004: leave IL_007e } filter { - IL_0006: castclass [runtime]System.Exception - IL_000b: stloc.1 - IL_000c: ldloc.1 - IL_000d: call valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1 ActivePatternTestCase::'|RecoverableException|_|'(class [runtime]System.Exception) - IL_0012: stloc.2 - IL_0013: ldloca.s V_2 - IL_0015: call instance int32 valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1::get_Tag() - IL_001a: ldc.i4.1 - IL_001b: bne.un.s IL_0028 - - IL_001d: ldloca.s V_2 - IL_001f: call instance !0 valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1::get_Item() - IL_0024: stloc.3 - IL_0025: ldc.i4.1 - IL_0026: br.s IL_0029 - - IL_0028: ldc.i4.0 - IL_0029: endfilter + IL_0009: stloc.2 + IL_000a: ldloc.2 + IL_000b: isinst [runtime]System.Exception + IL_0010: dup + IL_0011: brtrue.s IL_001a + + IL_0013: pop + IL_0014: ldloc.2 + IL_0015: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_001a: stloc.1 + IL_001b: ldloc.1 + IL_001c: call valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1 ActivePatternTestCase::'|RecoverableException|_|'(class [runtime]System.Exception) + IL_0021: stloc.3 + IL_0022: ldloca.s V_3 + IL_0024: call instance int32 valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1::get_Tag() + IL_0029: ldc.i4.1 + IL_002a: bne.un.s IL_0038 + + IL_002c: ldloca.s V_3 + IL_002e: call instance !0 valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1::get_Item() + IL_0033: stloc.s V_4 + IL_0035: ldc.i4.1 + IL_0036: br.s IL_0039 + + IL_0038: ldc.i4.0 + IL_0039: endfilter } { - IL_002b: castclass [runtime]System.Exception - IL_0030: stloc.s V_4 - IL_0032: ldloc.s V_4 - IL_0034: call valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1 ActivePatternTestCase::'|RecoverableException|_|'(class [runtime]System.Exception) - IL_0039: stloc.s V_5 - IL_003b: ldloca.s V_5 - IL_003d: call instance int32 valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1::get_Tag() - IL_0042: ldc.i4.1 - IL_0043: bne.un.s IL_0054 - - IL_0045: ldloca.s V_5 - IL_0047: call instance !0 valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1::get_Item() - IL_004c: stloc.s V_6 - IL_004e: ldarg.0 - IL_004f: ldarg.1 - IL_0050: add - IL_0051: stloc.0 - IL_0052: leave.s IL_005f - - IL_0054: rethrow - IL_0056: ldnull - IL_0057: unbox.any [runtime]System.Int32 - IL_005c: stloc.0 - IL_005d: leave.s IL_005f + IL_003b: stloc.s V_6 + IL_003d: ldloc.s V_6 + IL_003f: isinst [runtime]System.Exception + IL_0044: dup + IL_0045: brtrue.s IL_004f + + IL_0047: pop + IL_0048: ldloc.s V_6 + IL_004a: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_004f: stloc.s V_5 + IL_0051: ldloc.s V_5 + IL_0053: call valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1 ActivePatternTestCase::'|RecoverableException|_|'(class [runtime]System.Exception) + IL_0058: stloc.s V_7 + IL_005a: ldloca.s V_7 + IL_005c: call instance int32 valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1::get_Tag() + IL_0061: ldc.i4.1 + IL_0062: bne.un.s IL_0073 + + IL_0064: ldloca.s V_7 + IL_0066: call instance !0 valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1::get_Item() + IL_006b: stloc.s V_8 + IL_006d: ldarg.0 + IL_006e: ldarg.1 + IL_006f: add + IL_0070: stloc.0 + IL_0071: leave.s IL_007e + + IL_0073: rethrow + IL_0075: ldnull + IL_0076: unbox.any [runtime]System.Int32 + IL_007b: stloc.0 + IL_007c: leave.s IL_007e } - IL_005f: ldloc.0 - IL_0060: ret + IL_007e: ldloc.0 + IL_007f: ret } } @@ -143,4 +161,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/ActivePatternRecoverableException.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/ActivePatternRecoverableException.fs.il.bsl index 3dd52e246c0..141fb2f9a51 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/ActivePatternRecoverableException.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/ActivePatternRecoverableException.fs.il.bsl @@ -58,47 +58,56 @@ .maxstack 4 .locals init (int32 V_0, class [runtime]System.Exception V_1, - valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1 V_2, - class [runtime]System.Exception V_3) + object V_2, + valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1 V_3, + class [runtime]System.Exception V_4) .try { IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: div IL_0003: stloc.0 - IL_0004: leave.s IL_0036 + IL_0004: leave.s IL_0043 } catch [runtime]System.Object { - IL_0006: castclass [runtime]System.Exception - IL_000b: stloc.1 - IL_000c: ldloc.1 - IL_000d: call valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1 ActivePatternTestCase::'|RecoverableException|_|'(class [runtime]System.Exception) - IL_0012: stloc.2 - IL_0013: ldloca.s V_2 - IL_0015: call instance int32 valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1::get_Tag() - IL_001a: ldc.i4.1 - IL_001b: bne.un.s IL_002b - - IL_001d: ldloca.s V_2 - IL_001f: call instance !0 valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1::get_Item() - IL_0024: stloc.3 - IL_0025: ldarg.0 - IL_0026: ldarg.1 - IL_0027: add - IL_0028: stloc.0 - IL_0029: leave.s IL_0036 - - IL_002b: rethrow - IL_002d: ldnull - IL_002e: unbox.any [runtime]System.Int32 - IL_0033: stloc.0 - IL_0034: leave.s IL_0036 + IL_0006: stloc.2 + IL_0007: ldloc.2 + IL_0008: isinst [runtime]System.Exception + IL_000d: dup + IL_000e: brtrue.s IL_0017 + + IL_0010: pop + IL_0011: ldloc.2 + IL_0012: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0017: stloc.1 + IL_0018: ldloc.1 + IL_0019: call valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1 ActivePatternTestCase::'|RecoverableException|_|'(class [runtime]System.Exception) + IL_001e: stloc.3 + IL_001f: ldloca.s V_3 + IL_0021: call instance int32 valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1::get_Tag() + IL_0026: ldc.i4.1 + IL_0027: bne.un.s IL_0038 + + IL_0029: ldloca.s V_3 + IL_002b: call instance !0 valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1::get_Item() + IL_0030: stloc.s V_4 + IL_0032: ldarg.0 + IL_0033: ldarg.1 + IL_0034: add + IL_0035: stloc.0 + IL_0036: leave.s IL_0043 + + IL_0038: rethrow + IL_003a: ldnull + IL_003b: unbox.any [runtime]System.Int32 + IL_0040: stloc.0 + IL_0041: leave.s IL_0043 } - IL_0036: ldloc.0 - IL_0037: ret + IL_0043: ldloc.0 + IL_0044: ret } } @@ -120,4 +129,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/TryWithExplicitGuard.fs.generateFilterBlocks.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/TryWithExplicitGuard.fs.generateFilterBlocks.il.bsl index 9b04438a731..e7765be7ef6 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/TryWithExplicitGuard.fs.generateFilterBlocks.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/TryWithExplicitGuard.fs.generateFilterBlocks.il.bsl @@ -39,88 +39,106 @@ .maxstack 4 .locals init (int32 V_0, class [runtime]System.Exception V_1, - class [runtime]System.Exception V_2, - class [runtime]System.Type V_3, + object V_2, + class [runtime]System.Exception V_3, class [runtime]System.Type V_4, - class [runtime]System.Exception V_5, + class [runtime]System.Type V_5, class [runtime]System.Exception V_6, class [runtime]System.Exception V_7, - class [runtime]System.Type V_8, - class [runtime]System.Type V_9, - class [runtime]System.Exception V_10) + object V_8, + class [runtime]System.Exception V_9, + class [runtime]System.Type V_10, + class [runtime]System.Type V_11, + class [runtime]System.Exception V_12) .try { IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: div IL_0003: stloc.0 - IL_0004: leave IL_007d + IL_0004: leave IL_009a } filter { - IL_0009: castclass [runtime]System.Exception - IL_000e: stloc.1 - IL_000f: ldloc.1 - IL_0010: stloc.2 - IL_0011: ldloc.2 - IL_0012: callvirt instance class [runtime]System.Type [runtime]System.Exception::GetType() - IL_0017: stloc.3 - IL_0018: ldtoken [runtime]System.OperationCanceledException - IL_001d: call class [netstandard]System.Type [netstandard]System.Type::GetTypeFromHandle(valuetype [netstandard]System.RuntimeTypeHandle) - IL_0022: stloc.s V_4 - IL_0024: ldloc.3 - IL_0025: ldloc.s V_4 - IL_0027: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/HashCompare::GenericEqualityIntrinsic(!!0, - !!0) - IL_002c: ldc.i4.0 - IL_002d: ceq - IL_002f: brfalse.s IL_0037 - - IL_0031: ldloc.1 - IL_0032: stloc.s V_5 - IL_0034: ldc.i4.1 - IL_0035: br.s IL_0038 - - IL_0037: ldc.i4.0 - IL_0038: endfilter + IL_0009: stloc.2 + IL_000a: ldloc.2 + IL_000b: isinst [runtime]System.Exception + IL_0010: dup + IL_0011: brtrue.s IL_001a + + IL_0013: pop + IL_0014: ldloc.2 + IL_0015: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_001a: stloc.1 + IL_001b: ldloc.1 + IL_001c: stloc.3 + IL_001d: ldloc.3 + IL_001e: callvirt instance class [runtime]System.Type [runtime]System.Exception::GetType() + IL_0023: stloc.s V_4 + IL_0025: ldtoken [runtime]System.OperationCanceledException + IL_002a: call class [netstandard]System.Type [netstandard]System.Type::GetTypeFromHandle(valuetype [netstandard]System.RuntimeTypeHandle) + IL_002f: stloc.s V_5 + IL_0031: ldloc.s V_4 + IL_0033: ldloc.s V_5 + IL_0035: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/HashCompare::GenericEqualityIntrinsic(!!0, + !!0) + IL_003a: ldc.i4.0 + IL_003b: ceq + IL_003d: brfalse.s IL_0045 + + IL_003f: ldloc.1 + IL_0040: stloc.s V_6 + IL_0042: ldc.i4.1 + IL_0043: br.s IL_0046 + + IL_0045: ldc.i4.0 + IL_0046: endfilter } { - IL_003a: castclass [runtime]System.Exception - IL_003f: stloc.s V_6 - IL_0041: ldloc.s V_6 - IL_0043: stloc.s V_7 - IL_0045: ldloc.s V_7 - IL_0047: callvirt instance class [runtime]System.Type [runtime]System.Exception::GetType() - IL_004c: stloc.s V_8 - IL_004e: ldtoken [runtime]System.OperationCanceledException - IL_0053: call class [netstandard]System.Type [netstandard]System.Type::GetTypeFromHandle(valuetype [netstandard]System.RuntimeTypeHandle) - IL_0058: stloc.s V_9 - IL_005a: ldloc.s V_8 - IL_005c: ldloc.s V_9 - IL_005e: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/HashCompare::GenericEqualityIntrinsic(!!0, - !!0) - IL_0063: ldc.i4.0 - IL_0064: ceq - IL_0066: brfalse.s IL_0072 - - IL_0068: ldloc.s V_6 - IL_006a: stloc.s V_10 - IL_006c: ldarg.0 - IL_006d: ldarg.1 - IL_006e: add - IL_006f: stloc.0 - IL_0070: leave.s IL_007d - - IL_0072: rethrow - IL_0074: ldnull - IL_0075: unbox.any [runtime]System.Int32 - IL_007a: stloc.0 - IL_007b: leave.s IL_007d + IL_0048: stloc.s V_8 + IL_004a: ldloc.s V_8 + IL_004c: isinst [runtime]System.Exception + IL_0051: dup + IL_0052: brtrue.s IL_005c + + IL_0054: pop + IL_0055: ldloc.s V_8 + IL_0057: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_005c: stloc.s V_7 + IL_005e: ldloc.s V_7 + IL_0060: stloc.s V_9 + IL_0062: ldloc.s V_9 + IL_0064: callvirt instance class [runtime]System.Type [runtime]System.Exception::GetType() + IL_0069: stloc.s V_10 + IL_006b: ldtoken [runtime]System.OperationCanceledException + IL_0070: call class [netstandard]System.Type [netstandard]System.Type::GetTypeFromHandle(valuetype [netstandard]System.RuntimeTypeHandle) + IL_0075: stloc.s V_11 + IL_0077: ldloc.s V_10 + IL_0079: ldloc.s V_11 + IL_007b: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/HashCompare::GenericEqualityIntrinsic(!!0, + !!0) + IL_0080: ldc.i4.0 + IL_0081: ceq + IL_0083: brfalse.s IL_008f + + IL_0085: ldloc.s V_7 + IL_0087: stloc.s V_12 + IL_0089: ldarg.0 + IL_008a: ldarg.1 + IL_008b: add + IL_008c: stloc.0 + IL_008d: leave.s IL_009a + + IL_008f: rethrow + IL_0091: ldnull + IL_0092: unbox.any [runtime]System.Int32 + IL_0097: stloc.0 + IL_0098: leave.s IL_009a } - IL_007d: ldloc.0 - IL_007e: ret + IL_009a: ldloc.0 + IL_009b: ret } } @@ -142,4 +160,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/TryWithExplicitGuard.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/TryWithExplicitGuard.fs.il.bsl index 7aff9be8c6a..7d27d92200d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/TryWithExplicitGuard.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TryCatch/TryWithExplicitGuard.fs.il.bsl @@ -39,56 +39,65 @@ .maxstack 4 .locals init (int32 V_0, class [runtime]System.Exception V_1, - class [runtime]System.Exception V_2, - class [runtime]System.Type V_3, + object V_2, + class [runtime]System.Exception V_3, class [runtime]System.Type V_4, - class [runtime]System.Exception V_5) + class [runtime]System.Type V_5, + class [runtime]System.Exception V_6) .try { IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: div IL_0003: stloc.0 - IL_0004: leave.s IL_0042 + IL_0004: leave.s IL_0050 } catch [runtime]System.Object { - IL_0006: castclass [runtime]System.Exception - IL_000b: stloc.1 - IL_000c: ldloc.1 - IL_000d: stloc.2 - IL_000e: ldloc.2 - IL_000f: callvirt instance class [runtime]System.Type [runtime]System.Exception::GetType() - IL_0014: stloc.3 - IL_0015: ldtoken [runtime]System.OperationCanceledException - IL_001a: call class [netstandard]System.Type [netstandard]System.Type::GetTypeFromHandle(valuetype [netstandard]System.RuntimeTypeHandle) - IL_001f: stloc.s V_4 - IL_0021: ldloc.3 - IL_0022: ldloc.s V_4 - IL_0024: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/HashCompare::GenericEqualityIntrinsic(!!0, - !!0) - IL_0029: ldc.i4.0 - IL_002a: ceq - IL_002c: brfalse.s IL_0037 - - IL_002e: ldloc.1 - IL_002f: stloc.s V_5 - IL_0031: ldarg.0 - IL_0032: ldarg.1 - IL_0033: add - IL_0034: stloc.0 - IL_0035: leave.s IL_0042 - - IL_0037: rethrow - IL_0039: ldnull - IL_003a: unbox.any [runtime]System.Int32 - IL_003f: stloc.0 - IL_0040: leave.s IL_0042 + IL_0006: stloc.2 + IL_0007: ldloc.2 + IL_0008: isinst [runtime]System.Exception + IL_000d: dup + IL_000e: brtrue.s IL_0017 + + IL_0010: pop + IL_0011: ldloc.2 + IL_0012: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_0017: stloc.1 + IL_0018: ldloc.1 + IL_0019: stloc.3 + IL_001a: ldloc.3 + IL_001b: callvirt instance class [runtime]System.Type [runtime]System.Exception::GetType() + IL_0020: stloc.s V_4 + IL_0022: ldtoken [runtime]System.OperationCanceledException + IL_0027: call class [netstandard]System.Type [netstandard]System.Type::GetTypeFromHandle(valuetype [netstandard]System.RuntimeTypeHandle) + IL_002c: stloc.s V_5 + IL_002e: ldloc.s V_4 + IL_0030: ldloc.s V_5 + IL_0032: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/HashCompare::GenericEqualityIntrinsic(!!0, + !!0) + IL_0037: ldc.i4.0 + IL_0038: ceq + IL_003a: brfalse.s IL_0045 + + IL_003c: ldloc.1 + IL_003d: stloc.s V_6 + IL_003f: ldarg.0 + IL_0040: ldarg.1 + IL_0041: add + IL_0042: stloc.0 + IL_0043: leave.s IL_0050 + + IL_0045: rethrow + IL_0047: ldnull + IL_0048: unbox.any [runtime]System.Int32 + IL_004d: stloc.0 + IL_004e: leave.s IL_0050 } - IL_0042: ldloc.0 - IL_0043: ret + IL_0050: ldloc.0 + IL_0051: ret } } @@ -110,4 +119,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 63150ad3a7d..8bd56058f17 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -195,6 +195,7 @@ + diff --git a/tests/FSharp.Compiler.ComponentTests/Language/StateMachineTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/StateMachineTests.fs index 86e11cf2029..f374cfcb2aa 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/StateMachineTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/StateMachineTests.fs @@ -190,7 +190,8 @@ let test = task { return 42 } .locals init (int32 V_0, class [runtime]System.Exception V_1, bool V_2, - class [runtime]System.Exception V_3) + class [runtime]System.Exception V_3, + object V_4) IL_0000: ldarg.0 IL_0001: ldfld int32 TestStateMachine/test@3::ResumptionPoint IL_0006: stloc.0 @@ -212,32 +213,40 @@ let test = task { return 42 } IL_0025: ldflda valuetype [FSharp.Core]Microsoft.FSharp.Control.TaskStateMachineData`1 TestStateMachine/test@3::Data IL_002a: ldfld !0 valuetype [FSharp.Core]Microsoft.FSharp.Control.TaskStateMachineData`1::Result IL_002f: call instance void valuetype [netstandard]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetResult(!0) - IL_0034: leave.s IL_0042 + IL_0034: leave.s IL_0051 - IL_0036: leave.s IL_0042 + IL_0036: leave.s IL_0051 } catch [runtime]System.Object { - IL_0038: castclass [runtime]System.Exception - IL_003d: stloc.3 - IL_003e: ldloc.3 - IL_003f: stloc.1 - IL_0040: leave.s IL_0042 + IL_0038: stloc.s V_4 + IL_003a: ldloc.s V_4 + IL_003c: isinst [runtime]System.Exception + IL_0041: dup + IL_0042: brtrue.s IL_004c + + IL_0044: pop + IL_0045: ldloc.s V_4 + IL_0047: newobj instance void [runtime]System.Runtime.CompilerServices.RuntimeWrappedException::.ctor(object) + IL_004c: stloc.3 + IL_004d: ldloc.3 + IL_004e: stloc.1 + IL_004f: leave.s IL_0051 } - IL_0042: ldloc.1 - IL_0043: stloc.3 - IL_0044: ldloc.3 - IL_0045: brtrue.s IL_0048 + IL_0051: ldloc.1 + IL_0052: stloc.3 + IL_0053: ldloc.3 + IL_0054: brtrue.s IL_0057 - IL_0047: ret + IL_0056: ret - IL_0048: ldarg.0 - IL_0049: ldflda valuetype [FSharp.Core]Microsoft.FSharp.Control.TaskStateMachineData`1 TestStateMachine/test@3::Data - IL_004e: ldflda valuetype [runtime]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 valuetype [FSharp.Core]Microsoft.FSharp.Control.TaskStateMachineData`1::MethodBuilder - IL_0053: ldloc.3 - IL_0054: call instance void valuetype [netstandard]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetException(class [netstandard]System.Exception) - IL_0059: ret + IL_0057: ldarg.0 + IL_0058: ldflda valuetype [FSharp.Core]Microsoft.FSharp.Control.TaskStateMachineData`1 TestStateMachine/test@3::Data + IL_005d: ldflda valuetype [runtime]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 valuetype [FSharp.Core]Microsoft.FSharp.Control.TaskStateMachineData`1::MethodBuilder + IL_0062: ldloc.3 + IL_0063: call instance void valuetype [netstandard]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::SetException(class [netstandard]System.Exception) + IL_0068: ret } """ ] diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowStaticProperty.fsx.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowStaticProperty.fsx.il.bsl index e1aeb56493e..b006f5563a5 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowStaticProperty.fsx.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowStaticProperty.fsx.il.bsl @@ -115,7 +115,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .method public static void Foo.X.Static(int32 v) cil managed + .method public static void Foo$X$Static(int32 v) cil managed { .maxstack 8 @@ -132,7 +132,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .method public static void Foo.X.Static(int32 v) cil managed + .method public static void Foo$X$Static(int32 v) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowStaticProperty.fsx.realInternalSignatureOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowStaticProperty.fsx.realInternalSignatureOff.il.bsl index ce7460b05d1..bca61d7eefb 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowStaticProperty.fsx.realInternalSignatureOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowStaticProperty.fsx.realInternalSignatureOff.il.bsl @@ -12,16 +12,6 @@ int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.dll @@ -186,4 +176,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowStaticProperty.fsx.realInternalSignatureOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowStaticProperty.fsx.realInternalSignatureOn.il.bsl index c29813f3509..76c9c3cf0b4 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowStaticProperty.fsx.realInternalSignatureOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowStaticProperty.fsx.realInternalSignatureOn.il.bsl @@ -12,16 +12,6 @@ int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.dll @@ -213,4 +203,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.il.bsl index e96af9ece71..2cf6beb19df 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.il.bsl @@ -367,7 +367,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .method public static void Foo.X.Static(int32 v) cil managed + .method public static void Foo$X$Static(int32 v) cil managed { .maxstack 8 @@ -384,7 +384,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .method public static void Foo.X.Static(int32 v) cil managed + .method public static void Foo$X$Static(int32 v) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOff.il.bsl index e96af9ece71..f8db25b8f62 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOff.il.bsl @@ -12,16 +12,6 @@ int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.dll @@ -568,4 +558,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOn.il.bsl index 50c58d1a2b2..ae8a5534125 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOn.il.bsl @@ -12,16 +12,6 @@ int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.dll @@ -595,4 +585,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.il.bsl index 4baf9344ebf..fa7d7d2ec19 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.il.bsl @@ -96,7 +96,7 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) .method public static class assembly/Foo - Foo.X(class assembly/Foo f, + Foo$X(class assembly/Foo f, int32 i) cil managed { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.realInternalSignatureOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.realInternalSignatureOff.il.bsl index 2fa391c3858..51d71030ece 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.realInternalSignatureOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.realInternalSignatureOff.il.bsl @@ -12,16 +12,6 @@ int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.dll @@ -92,9 +82,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .method public static class assembly/Foo - Foo.X(class assembly/Foo f, - int32 i) cil managed + .method public static class assembly/Foo Foo.X(class assembly/Foo f, int32 i) cil managed { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) @@ -218,4 +206,3 @@ - diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.realInternalSignatureOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.realInternalSignatureOn.il.bsl index 531dddf3cfc..69c89214524 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.realInternalSignatureOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.realInternalSignatureOn.il.bsl @@ -12,16 +12,6 @@ int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.dll @@ -92,9 +82,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .method public static class assembly/Foo - Foo.X(class assembly/Foo f, - int32 i) cil managed + .method public static class assembly/Foo Foo.X(class assembly/Foo f, int32 i) cil managed { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) @@ -237,4 +225,3 @@ - diff --git a/tests/FSharp.Compiler.Service.Tests/ExprTests.fs b/tests/FSharp.Compiler.Service.Tests/ExprTests.fs index f628870119a..3a50269dc77 100644 --- a/tests/FSharp.Compiler.Service.Tests/ExprTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/ExprTests.fs @@ -3699,6 +3699,19 @@ type WithStructTuple<'a> = module M type RecordWithTuple<'a> = { Pair: 'a * int; Name: string } +""" } |] + [| { Name = "TType_tuple - record with same type param in both tuple positions" + Source = """ +module M + +type TupleRecord<'a> = { Pair: 'a * string; Extra: 'a * 'a } +""" } |] + [| { Name = "TType_tuple - DU with generic param at both tuple nesting levels" + Source = """ +module M + +type DeepTuple<'a> = + | Deep of ('a * ('a * int)) """ } |] [| { Name = "TType_fun - DU case with function type containing generic param in domain" Source = """ @@ -3740,6 +3753,14 @@ type WithHigherOrderFun<'a> = module M type RecordWithFun<'a> = { Transform: 'a -> string; Id: int } +""" } |] + [| { Name = "TType_fun - DU with NoComparison NoEquality and self-referencing function field" + Source = """ +module M + +[] +type FuncDU<'a> = + | FuncCase of ('a -> 'a) """ } |] [| { Name = "TType_anon - DU case with anonymous record containing generic param" Source = """ @@ -3997,6 +4018,14 @@ module M type Writer<'w, 'a> = | Writer of value: 'a * log: 'w list +""" } |] + [| { Name = "generic record with list field and actual compare usage" + Source = """ +module M + +type Wrapper<'a> = { Items: ('a * 'a) list; Tag: string } + +let compare2 (a: Wrapper) (b: Wrapper) = compare a b """ } |] |] diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl index 1954ef2367b..dc1487dd926 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl @@ -2390,6 +2390,7 @@ FSharp.Compiler.CodeAnalysis.LegacyResolutionFailure: Int32 GetHashCode() FSharp.Compiler.CodeAnalysis.LegacyResolutionFailure: Int32 GetHashCode(System.Collections.IEqualityComparer) FSharp.Compiler.CodeAnalysis.LegacyResolutionFailure: System.String get_Message() FSharp.Compiler.CodeAnalysis.LegacyResolutionFailure: Void .ctor() +FSharp.Compiler.CodeAnalysis.LegacyResolutionFailure: Void GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext) FSharp.Compiler.CodeAnalysis.LegacyResolvedFile: Microsoft.FSharp.Core.FSharpFunc`2[System.Tuple`2[System.String,System.String],System.String] get_prepareToolTip() FSharp.Compiler.CodeAnalysis.LegacyResolvedFile: Microsoft.FSharp.Core.FSharpFunc`2[System.Tuple`2[System.String,System.String],System.String] prepareToolTip FSharp.Compiler.CodeAnalysis.LegacyResolvedFile: System.String ToString() diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.release.bsl b/tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.release.bsl index 606217f9fc5..37b4aee6700 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.release.bsl +++ b/tests/FSharp.Core.UnitTests/FSharp.Core.SurfaceArea.netstandard21.release.bsl @@ -1640,6 +1640,7 @@ Microsoft.FSharp.Core.MatchFailureException: System.String get_Data0() Microsoft.FSharp.Core.MatchFailureException: System.String get_Message() Microsoft.FSharp.Core.MatchFailureException: Void .ctor() Microsoft.FSharp.Core.MatchFailureException: Void .ctor(System.String, Int32, Int32) +Microsoft.FSharp.Core.MatchFailureException: Void GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext) Microsoft.FSharp.Core.MeasureAnnotatedAbbreviationAttribute: Void .ctor() Microsoft.FSharp.Core.MeasureAttribute: Void .ctor() Microsoft.FSharp.Core.NoComparisonAttribute: Void .ctor()