diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 99949f9d608..a26d3b4a296 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -132,20 +132,6 @@ let CountMethodDef = NewCounter "IL method defintitions corresponding to values" let CountStaticFieldDef = NewCounter "IL field defintitions corresponding to values" let CountCallFuncInstructions = NewCounter "callfunc instructions (indirect calls)" -//------------------------------------------------------------------------- -// Part of the last-minute tranformation performed by this file -// is to eliminate variables of static type "unit". These are -// utility functions related to this. -//------------------------------------------------------------------------- - -let BindUnitVars g (mvs:Val list, paramInfos, body) = - match mvs,paramInfos with - | [v],[] -> - assert isUnitTy g v.Type - [], mkLet NoSequencePointAtInvisibleBinding v.Range v (mkUnit g v.Range) body - | _ -> mvs,body - - /// Non-local information related to internals of code generation within an assembly type IlxGenIntraAssemblyInfo = { /// A table recording the generated name of the static backing fields for each mutable top level value where @@ -155,7 +141,6 @@ type IlxGenIntraAssemblyInfo = /// that come from both the signature and the implementation. StaticFieldInfo : Dictionary } -//-------------------------------------------------------------------------- //-------------------------------------------------------------------------- /// Indicates how the generated IL code is ultimately emitted @@ -4093,6 +4078,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod((TSlotSig(_,delega let ilDelegeeParams,ilDelegeeRet = GenActualSlotsig m cenv envForDelegeeUnderTypars slotsig methTyparsOfOverridingMethod let numthis = 1 + let tmvs, body = BindUnitVars cenv.g (tmvs, List.replicate (List.concat slotsig.FormalParams).Length ValReprInfo.unnamedTopArg1, body) let envForDelegeeMeth = AddStorageForLocalVals cenv.g (List.mapi (fun i v -> (v,Arg (i+numthis))) tmvs) envForDelegeeUnderTypars let ilMethodBody = CodeGenMethodForExpr cenv cgbuf.mgbuf (SPAlways,[],delegeeMethName,envForDelegeeMeth,1,0,body,(if slotSigHasVoidReturnTy slotsig then discardAndReturnVoid else Return)) let delegeeInvokeMeth = diff --git a/src/fsharp/TastOps.fs b/src/fsharp/TastOps.fs index 348e98185f6..3ae3051c9d9 100644 --- a/src/fsharp/TastOps.fs +++ b/src/fsharp/TastOps.fs @@ -7993,3 +7993,18 @@ let DetectAndOptimizeForExpression g option expr = // Used to remove Expr.Link for inner expressions in pattern matches let (|InnerExprPat|) expr = stripExpr expr + +//------------------------------------------------------------------------- +// One of the tranformations performed by the compiler +// is to eliminate variables of static type "unit". These are +// utility functions related to this. +//------------------------------------------------------------------------- + +let BindUnitVars g (mvs:Val list, paramInfos:ArgReprInfo list, body) = + match mvs,paramInfos with + | [v],[] -> + assert isUnitTy g v.Type + [], mkLet NoSequencePointAtInvisibleBinding v.Range v (mkUnit g v.Range) body + | _ -> mvs,body + + diff --git a/src/fsharp/TastOps.fsi b/src/fsharp/TastOps.fsi index ed924b26921..de400762b59 100755 --- a/src/fsharp/TastOps.fsi +++ b/src/fsharp/TastOps.fsi @@ -1432,3 +1432,5 @@ val mkCoerceIfNeeded : TcGlobals -> tgtTy: TType -> srcTy: TType -> Expr -> Expr val (|InnerExprPat|) : Expr -> Expr val allValsOfModDef : ModuleOrNamespaceExpr -> seq + +val BindUnitVars : TcGlobals -> (Val list * ArgReprInfo list * Expr) -> Val list * Expr diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/env.lst b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/env.lst index b302840e317..710b50ca1be 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/env.lst +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/env.lst @@ -38,4 +38,5 @@ SOURCE=E_PrettifyForall.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_PrettifyForall.fs - SOURCE=IgnoreUnitParameters.fs # IgnoreUnitParameters.fs \ No newline at end of file + SOURCE=IgnoreUnitParameters.fs # IgnoreUnitParameters.fs + SOURCE=IgnoreUnitParameters.fs SCFLAGS="--optimize- -g" # IgnoreUnitParameters2.fs \ No newline at end of file