@@ -847,14 +847,14 @@ and IlxGenEnv =
847847 withinSEH: bool
848848
849849 /// Are we inside of a recursive let binding, while loop, or a for loop?
850- isInLoop : bool
850+ inLoop : bool
851851 }
852852
853853 override __.ToString () = " <IlxGenEnv>"
854854
855- let SetIsInLoop isInLoop eenv =
856- if eenv.isInLoop = isInLoop then eenv
857- else { eenv with isInLoop = isInLoop }
855+ let SetInLoop inLoop eenv =
856+ if eenv.inLoop = inLoop then eenv
857+ else { eenv with inLoop = inLoop }
858858
859859let ReplaceTyenv tyenv ( eenv : IlxGenEnv ) = { eenv with tyenv = tyenv }
860860
@@ -1911,9 +1911,10 @@ let CodeGenThen cenv mgbuf (entryPointInfo, methodName, eenv, alreadyUsedArgs, c
19111911 let innerVals = entryPointInfo |> List.map ( fun ( v , kind ) -> ( v, ( kind, start)))
19121912
19131913 (* Call the given code generator *)
1914- codeGenFunction cgbuf { eenv with withinSEH= false
1915- liveLocals= IntMap.empty()
1916- innerVals = innerVals}
1914+ codeGenFunction cgbuf { eenv with withinSEH = false
1915+ liveLocals = IntMap.empty()
1916+ innerVals = innerVals
1917+ inLoop = false }
19171918
19181919 let locals , maxStack , lab2pc , code , exnSpecs , hasSequencePoints = cgbuf.Close()
19191920
@@ -2196,7 +2197,7 @@ and GenExprWithStackGuard cenv cgbuf eenv sp expr sequel =
21962197 assert ( cenv.exprRecursionDepth = 1 )
21972198 with
21982199 | :? System.InsufficientExecutionStackException ->
2199- error( InternalError( " Expression is too large and/or complex to emit." , expr.Range))
2200+ error( InternalError( sprintf " Expression is too large and/or complex to emit. Method name: ' %s '. Recursive depth: %i . " cgbuf.MethodName cenv.exprRecursionDepth , expr.Range))
22002201
22012202and GenExprAux ( cenv : cenv ) ( cgbuf : CodeGenBuffer ) eenv sp expr sequel =
22022203 let g = cenv.g
@@ -3456,7 +3457,7 @@ and GenTryFinally cenv cgbuf eenv (bodyExpr, handlerExpr, m, resty, spTry, spFin
34563457//--------------------------------------------------------------------------
34573458
34583459and GenForLoop cenv cgbuf eenv ( spFor , v , e1 , dir , e2 , loopBody , m ) sequel =
3459- let eenv = SetIsInLoop true eenv
3460+ let eenv = SetInLoop true eenv
34603461 let g = cenv.g
34613462
34623463 // The JIT/NGen eliminate array-bounds checks for C# loops of form:
@@ -3547,7 +3548,7 @@ and GenForLoop cenv cgbuf eenv (spFor, v, e1, dir, e2, loopBody, m) sequel =
35473548//--------------------------------------------------------------------------
35483549
35493550and GenWhileLoop cenv cgbuf eenv ( spWhile , e1 , e2 , m ) sequel =
3550- let eenv = SetIsInLoop true eenv
3551+ let eenv = SetInLoop true eenv
35513552 let finish = CG.GenerateDelayMark cgbuf " while_finish"
35523553 let startTest = CG.GenerateMark cgbuf " startTest"
35533554
@@ -5150,7 +5151,7 @@ and GenLetRecFixup cenv cgbuf eenv (ilxCloSpec: IlxClosureSpec, e, ilField: ILFi
51505151
51515152/// Generate letrec bindings
51525153and GenLetRecBindings cenv ( cgbuf : CodeGenBuffer ) eenv ( allBinds : Bindings , m ) =
5153- let eenv = SetIsInLoop true eenv
5154+ let eenv = SetInLoop true eenv
51545155 // Fix up recursion for non-toplevel recursive bindings
51555156 let bindsPossiblyRequiringFixup =
51565157 allBinds |> List.filter ( fun b ->
@@ -5400,7 +5401,7 @@ and GenBindingAfterSequencePoint cenv cgbuf eenv sp (TBind(vspec, rhsExpr, _)) s
54005401 let storage = StorageForVal cenv.g m vspec eenv
54015402 match storage, rhsExpr with
54025403 // locals are zero-init, no need to initialize them, except if you are in a loop and the local is mutable.
5403- | Local (_, realloc, _), Expr.Const ( Const.Zero, _, _) when not realloc && not ( eenv.isInLoop && vspec.IsMutable) ->
5404+ | Local (_, realloc, _), Expr.Const ( Const.Zero, _, _) when not realloc && not ( eenv.inLoop && vspec.IsMutable) ->
54045405 CommitStartScope cgbuf startScopeMarkOpt
54055406 | _ ->
54065407 GenBindingRhs cenv cgbuf eenv SPSuppress vspec rhsExpr
@@ -7535,7 +7536,7 @@ let GetEmptyIlxGenEnv (ilg: ILGlobals) ccu =
75357536 innerVals = []
75367537 sigToImplRemapInfo = [] (* "module remap info" *)
75377538 withinSEH = false
7538- isInLoop = false }
7539+ inLoop = false }
75397540
75407541type IlxGenResults =
75417542 { ilTypeDefs: ILTypeDef list
0 commit comments