@@ -1118,24 +1118,21 @@ let mkMultiLambdaBind v letSeqPtOpt m tps vsl (b, rty) =
11181118
11191119let mkBind seqPtOpt v e = TBind( v, e, seqPtOpt)
11201120
1121- let mkCompGenBind v e = TBind( v, e, NoSequencePointAtStickyBinding)
1122-
1123- /// Make bindings that are compiler generated (though the variables may not be - e.g. they may be lambda arguments in a beta reduction)
1124- let mkCompGenBinds vs es =
1125- List.map2 mkCompGenBind vs es
1126-
1127- // n.b. type gives type of body
11281121let mkLetBind m bind body = Expr.Let( bind, body, m, NewFreeVarsCache())
11291122let mkLetsBind m binds body = List.foldBack( mkLetBind m) binds body
11301123let mkLetsFromBindings m binds body = List.foldBack( mkLetBind m) binds body
11311124let mkLet seqPtOpt m v x body = mkLetBind m( mkBind seqPtOpt v x) body
1125+
1126+ /// Make sticky bindings that are compiler generated (though the variables may not be - e.g. they may be lambda arguments in a beta reduction)
1127+ let mkCompGenBind v e = TBind( v, e, NoSequencePointAtStickyBinding)
1128+ let mkCompGenBinds ( vs : Val list ) ( es : Expr list ) = List.map2 mkCompGenBind vs es
11321129let mkCompGenLet m v x body = mkLetBind m( mkCompGenBind v x) body
1130+ let mkCompGenLets m vs xs body = mkLetsBind m( mkCompGenBinds vs xs) body
1131+ let mkCompGenLetsFromBindings m vs xs body = mkLetsFromBindings m( mkCompGenBinds vs xs) body
11331132
11341133let mkInvisibleBind v e = TBind( v, e, NoSequencePointAtInvisibleBinding)
1134+ let mkInvisibleBinds ( vs : Val list ) ( es : Expr list ) = List.map2 mkInvisibleBind vs es
11351135let mkInvisibleLet m v x body = mkLetBind m( mkInvisibleBind v x) body
1136- let mkInvisibleBinds ( vs : Val list ) ( es : Expr list ) =
1137- List.map2 mkInvisibleBind vs es
1138-
11391136let mkInvisibleLets m vs xs body = mkLetsBind m( mkInvisibleBinds vs xs) body
11401137let mkInvisibleLetsFromBindings m vs xs body = mkLetsFromBindings m( mkInvisibleBinds vs xs) body
11411138
@@ -5471,6 +5468,7 @@ let foldLinearBindingTargetsOfMatch tree (targets: _[]) =
54715468// Hence the expressions in the value bindings can be remarked with the range of the target.
54725469let mTarget = exprTarget.Range
54735470let es = es|> List.map( remarkExpr mTarget)
5471+ // These are non-sticky - any sequence point for 'exprTarget' goes on 'exprTarget' _after_ the bindings have been evaluated
54745472 TTarget( List.empty, mkLetsBind mTarget binds( mkInvisibleLetsFromBindings mTarget vs es exprTarget), spTarget)
54755473else tg)
54765474
@@ -5484,6 +5482,7 @@ let rec simplifyTrivialMatch spBind exprm matchm ty tree (targets : _[]) =
54845482// REVIEW: should we use _spTarget here?
54855483let ( TTarget ( vs , rhs , _spTarget )) = targets.[ n]
54865484if vs.Length<> es.Lengththen failwith( " simplifyTrivialMatch: invalid argument, n =" ^string n^ " , List.length targets =" ^string targets.Length);
5485+ // These are non-sticky - any sequence point for 'rhs' goes on 'rhs' _after_ the bindings have been made
54875486 mkInvisibleLetsFromBindings rhs.Range vs es rhs
54885487| _ ->
54895488 primMkMatch( spBind, exprm, tree, targets, matchm, ty)
@@ -6415,6 +6414,7 @@ let untupledToRefTupled g vs =
64156414let m = ( List.head vs) .Range
64166415let tupledv , tuplede = mkCompGenLocal m" tupledArg" ( mkRefTupledTy g untupledTys)
64176416let untupling_es = List.mapi( fun i _ -> mkTupleFieldGet g( tupInfoRef, tuplede, untupledTys, i, m)) untupledTys
6417+ // These are non-sticky - at the caller,any sequence point for 'body' goes on 'body' _after_ the binding has been made
64186418 tupledv, mkInvisibleLets m vs untupling_ es
64196419
64206420// The required tupled-arity (arity) can either be 1
@@ -6435,6 +6435,7 @@ let AdjustArityOfLambdaBody g arity (vs:Val list) body =
64356435 untupledTys
64366436|> List.mapi( fun i ty -> mkCompGenLocal v.Range( v.LogicalName^ " _" ^string i) ty)
64376437|> List.unzip
6438+ // These are non-sticky - any sequence point for 'body' goes on 'body' _after_ the binding has been made
64386439let body = mkInvisibleLet v.Range v( mkRefTupled g v.Range dummyes untupledTys) body
64396440 dummyvs, body
64406441else
@@ -6795,7 +6796,7 @@ let AdjustPossibleSubsumptionExpr g (expr: Expr) (suppliedArgs: Expr list) : (Ex
67956796( mkApps g(( inpCloVarAsExpr, inpCloVarType), [], [ inpsAsActualArg], appm), resTy)
67966797else
67976798 mkMultiLambda appm inpsAsVars
6798- ( mkInvisibleLet appm cloVar
6799+ ( mkCompGenLet appm cloVar
67996800( mkApps g(( inpCloVarAsExpr, inpCloVarType), [], [ inpsAsActualArg], appm))
68006801 res,
68016802 resTy)
@@ -6813,7 +6814,7 @@ let AdjustPossibleSubsumptionExpr g (expr: Expr) (suppliedArgs: Expr list) : (Ex
68136814let exprForAllArgs =
68146815
68156816if isNil argTysWithNiceNamesthen
6816- mkInvisibleLet appm cloVar exprWithActualTy exprForOtherArgs
6817+ mkCompGenLet appm cloVar exprWithActualTy exprForOtherArgs
68176818else
68186819let lambdaBuilders , binderBuilders , inpsAsArgs =
68196820
@@ -6858,7 +6859,7 @@ let AdjustPossibleSubsumptionExpr g (expr: Expr) (suppliedArgs: Expr list) : (Ex
68586859if isNil argTysWithoutNiceNamesthen
68596860 mkApps g(( exprWithActualTy, actualTy), [], inpsAsArgs, appm)
68606861else
6861- mkInvisibleLet appm
6862+ mkCompGenLet appm
68626863 cloVar( mkApps g(( exprWithActualTy, actualTy), [], inpsAsArgs, appm))
68636864 exprForOtherArgs
68646865
@@ -6957,6 +6958,7 @@ let LinearizeTopMatchAux g parent (spBind, m, tree, targets, m2, ty) =
69576958let rhs = etaExpandTypeLambda g m v.Typars( itemsProj vtys i tmpe, ty)
69586959// update the arity of the value
69596960 v.SetValReprInfo( Some( InferArityOfExpr g AllowTypeDirectedDetupling.Yes ty[] [] rhs))
6961+ // This binding is deliberately non-sticky - any sequence point for 'rhs' goes on 'rhs' _after_ the binding has been evaluated
69606962 mkInvisibleBind v rhs) in (* vi = proj tmp*)
69616963 mkCompGenLet m
69626964 tmp( primMkMatch( spBind, m, tree, targets, m2, tmpTy)) (* note, probably retyped match, but note, result still has same type*)
@@ -7255,7 +7257,7 @@ let mkIsInstConditional g m tgty vinpe v e2 e3 =
72557257let tg3 = mbuilder.AddResultTarget( e3, SuppressSequencePointAtTarget)
72567258let dtree = TDSwitch( exprForVal m v, [ TCase( DecisionTreeTest.IsNull, tg3)], Some tg2, m)
72577259let expr = mbuilder.Close( dtree, m, tyOfExpr g e2)
7258- mkInvisibleLet m v( mkIsInst tgty vinpe m) expr
7260+ mkCompGenLet m v( mkIsInst tgty vinpe m) expr
72597261
72607262else
72617263let mbuilder = new MatchBuilder( NoSequencePointAtInvisibleBinding, m)