Slight cleanup of dead and repeated code (#17412) · dotnet/fsharp@2818689 · GitHub
Skip to content

Commit 2818689

Browse files
authored
Slight cleanup of dead and repeated code (#17412)
* Slight cleanup * splitoperator
1 parent b73be15 commit 2818689

5 files changed

Lines changed: 10 additions & 23 deletions

File tree

‎src/Compiler/Checking/CheckExpressions.fs‎

Lines changed: 1 addition & 4 deletions

‎src/Compiler/Checking/PostInferenceChecks.fs‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -703,10 +703,6 @@ let CheckNoReraise cenv freesOpt (body: Expr) =
703703
if fvs.UsesUnboundRethrow then
704704
errorR(Error(FSComp.SR.chkErrorContainsCallToRethrow(), body.Range))
705705

706-
/// Check if a function is a quotation splice operator
707-
let isSpliceOperator g v = valRefEq g v g.splice_expr_vref || valRefEq g v g.splice_raw_expr_vref
708-
709-
710706
/// Examples:
711707
/// I<int> & I<int> => ExactlyEqual.
712708
/// I<int> & I<string> => NotEqual.
@@ -776,8 +772,8 @@ let rec CheckExprNoByrefs cenv env expr =
776772
and CheckValRef (cenv: cenv) (env: env) v m (ctxt: PermitByRefExpr) =
777773

778774
if cenv.reportErrors then
779-
if isSpliceOperator cenv.g v && not env.quote then errorR(Error(FSComp.SR.chkSplicingOnlyInQuotations(), m))
780-
if isSpliceOperator cenv.g v then errorR(Error(FSComp.SR.chkNoFirstClassSplicing(), m))
775+
if cenv.g.isSpliceOperator v && not env.quote then errorR(Error(FSComp.SR.chkSplicingOnlyInQuotations(), m))
776+
if cenv.g.isSpliceOperator v then errorR(Error(FSComp.SR.chkNoFirstClassSplicing(), m))
781777
if valRefEq cenv.g v cenv.g.addrof_vref then errorR(Error(FSComp.SR.chkNoFirstClassAddressOf(), m))
782778
if valRefEq cenv.g v cenv.g.reraise_vref then errorR(Error(FSComp.SR.chkNoFirstClassRethrow(), m))
783779
if valRefEq cenv.g v cenv.g.nameof_vref then errorR(Error(FSComp.SR.chkNoFirstClassNameOf(), m))
@@ -1192,7 +1188,7 @@ and CheckExpr (cenv: cenv) (env: env) origExpr (ctxt: PermitByRefExpr) : Limit =
11921188
NoLimit
11931189

11941190
// Allow '%expr' in quotations
1195-
| Expr.App (Expr.Val (vref, _, _), _, tinst, [arg], m) when isSpliceOperator g vref && env.quote ->
1191+
| Expr.App (Expr.Val (vref, _, _), _, tinst, [arg], m) when g.isSpliceOperator vref && env.quote ->
11961192
CheckSpliceApplication cenv env (tinst, arg, m)
11971193

11981194
// Check an application

‎src/Compiler/Checking/QuotationTranslator.fs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ let (|ObjectInitializationCheck|_|) g expr =
214214
isUnitTy g resultTy -> ValueSome()
215215
| _ -> ValueNone
216216

217-
let isSplice g vref = valRefEq g vref g.splice_expr_vref || valRefEq g vref g.splice_raw_expr_vref
218-
219217
let rec EmitDebugInfoIfNecessary cenv env m astExpr : ExprData =
220218
// do not emit debug info if emitDebugInfoInQuotations = false or it was already written for the given expression
221219
if cenv.emitDebugInfoInQuotations && not (QP.isAttributedExpression astExpr) then
@@ -298,7 +296,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.
298296
match expr with
299297
// Detect expression tree exprSplices
300298
| Expr.App (InnerExprPat(Expr.Val (vref, _, _)), _, _, x0 :: rest, m)
301-
when isSplice g vref ->
299+
when g.isSpliceOperator vref ->
302300
let idx = cenv.exprSplices.Count
303301
let ty = tyOfExpr g expr
304302

@@ -311,7 +309,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.
311309
(hole, rest) ||> List.fold (fun fR arg -> QP.mkApp (fR, ConvExpr cenv env arg))
312310

313311
| ModuleValueOrMemberUse g (vref, vFlags, _f, _fTy, tyargs, curriedArgs)
314-
when not (isSplice g vref) ->
312+
when not (g.isSpliceOperator vref) ->
315313
let m = expr.Range
316314

317315
let numEnclTypeArgs, _, isNewObj, valUseFlags, isSelfInit, takesInstanceArg, isPropGet, isPropSet =

‎src/Compiler/Checking/QuotationTranslator.fsi‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,3 @@ val (|SimpleArrayLoopBody|_|): TcGlobals -> Expr -> (Expr * TType * Expr) voptio
5353

5454
[<return: Struct>]
5555
val (|ObjectInitializationCheck|_|): TcGlobals -> Expr -> unit voption
56-
57-
val isSplice: TcGlobals -> ValRef -> bool

‎src/Compiler/TypedTree/TcGlobals.fs‎

Lines changed: 4 additions & 6 deletions

0 commit comments

Comments
 (0)