Skip to content

Commit

Permalink
Remove unnecessary bool flag
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarfgp committed Jan 4, 2025
1 parent 1e3a8cd commit e91da53
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
22 changes: 17 additions & 5 deletions src/Compiler/Checking/AttributeChecking.fs
Original file line number Diff line number Diff line change
Expand Up @@ -276,20 +276,32 @@ let CheckFSharpAttributes (g:TcGlobals) attribs m =
else
trackErrors {
match TryFindFSharpAttribute g g.attrib_SystemObsolete attribs with
| Some(Attrib(_, _, [ AttribStringArg s ], _, _, _, _)) ->
| Some(Attrib(unnamedArgs= [ AttribStringArg s ])) ->
do! WarnD(ObsoleteWarning(s, m))
| Some(Attrib(_, _, [ AttribStringArg s; AttribBoolArg(isError) ], _, _, _, _)) ->
| Some(Attrib(unnamedArgs= [ AttribStringArg message; AttribBoolArg(isError) ]; propVal = namedArgs)) ->
let diagnosticId =
match namedArgs with
| ExtractAttribNamedArg "DiagnosticId" (AttribStringArg v) -> v
| _ -> ""

let urlFormat =
match namedArgs with
| ExtractAttribNamedArg "UrlFormat" (AttribStringArg v) -> v
| _ -> ""

if isError then
do! ErrorD (ObsoleteError(s, m))
do! ErrorD (ObsoleteError(message, m))
else
do! WarnD (ObsoleteWarning(s, m))
do! WarnD (ObsoleteWarning(message, m))
| Some(Attrib(unnamedArgs= [ AttribStringArg diagnosticId; AttribStringArg urlFormat ])) ->
do! CompleteD
| Some _ ->
do! WarnD(ObsoleteWarning("", m))
| None ->
()

match TryFindFSharpAttribute g g.attrib_CompilerMessageAttribute attribs with
| Some(Attrib(_, _, [ AttribStringArg s ; AttribInt32Arg n ], namedArgs, _, _, _)) ->
| Some(Attrib(unnamedArgs= [ AttribStringArg s ; AttribInt32Arg n ]; propVal= namedArgs)) ->
let msg = UserCompilerMessage(s, n, m)
let isError =
match namedArgs with
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Checking/CheckPatterns.fs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ and TcPatLongIdentLiteral warnOnUpper (cenv: cenv) env vFlags patEnv ty (mLongId
match vref.LiteralValue with
| None -> error (Error(FSComp.SR.tcNonLiteralCannotBeUsedInPattern(), m))
| Some lit ->
let _, _, _, vexpty, _, _ = TcVal true cenv env tpenv vref None None mLongId
let _, _, _, vexpty, _, _ = TcVal cenv env tpenv vref None None mLongId
CheckValAccessible mLongId env.AccessRights vref
CheckFSharpAttributes g vref.Attribs mLongId |> CommitOperationResult
CheckNoArgsForLiteral args m
Expand Down
13 changes: 6 additions & 7 deletions src/Compiler/Checking/Expressions/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2739,7 +2739,7 @@ let TcValEarlyGeneralizationConsistencyCheck (cenv: cenv) (env: TcEnv) (v: Val,
/// instantiationInfoOpt is is also set when building the final call for a reference to an
/// F# object model member, in which case the instantiationInfoOpt is the type instantiation
/// inferred by member overload resolution.
let TcVal checkAttributes (cenv: cenv) env (tpenv: UnscopedTyparEnv) (vref: ValRef) instantiationInfoOpt optAfterResolution m =
let TcVal (cenv: cenv) env (tpenv: UnscopedTyparEnv) (vref: ValRef) instantiationInfoOpt optAfterResolution m =
let g = cenv.g

let tpsorig, _, _, _, tinst, _ as res =
Expand All @@ -2749,8 +2749,7 @@ let TcVal checkAttributes (cenv: cenv) env (tpenv: UnscopedTyparEnv) (vref: ValR

CheckValAccessible m env.eAccessRights vref

if checkAttributes then
CheckValAttributes g vref m |> CommitOperationResult
CheckValAttributes g vref m |> CommitOperationResult

let vTy = vref.Type

Expand Down Expand Up @@ -3046,7 +3045,7 @@ let BuildPossiblyConditionalMethodCall (cenv: cenv) env isMutable m isProp minfo
| _ ->
#endif
let tcVal valref valUse ttypes m =
let _, exprForVal, _, tau, _, _ = TcVal true cenv env emptyUnscopedTyparEnv valref (Some (valUse, (fun x _ -> ttypes, x))) None m
let _, exprForVal, _, tau, _, _ = TcVal cenv env emptyUnscopedTyparEnv valref (Some (valUse, (fun x _ -> ttypes, x))) None m
exprForVal, tau

BuildMethodCall tcVal g cenv.amap isMutable m isProp minfo valUseFlags minst objArgs args staticTyOpt
Expand Down Expand Up @@ -5164,7 +5163,7 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags
CallNameResolutionSink cenv.tcSink (mLongId, env.NameEnv, item, emptyTyparInst, ItemOccurrence.Pattern, env.eAccessRights)

// TOTAL/PARTIAL ACTIVE PATTERNS
let _, vExpr, _, _, tinst, _ = TcVal true cenv env tpenv vref None None m
let _, vExpr, _, _, tinst, _ = TcVal cenv env tpenv vref None None m
let vExpr = MakeApplicableExprWithFlex cenv env vExpr
let vExprTy = vExpr.Type

Expand Down Expand Up @@ -9259,7 +9258,7 @@ and TcValueItemThen cenv overallTy env vref tpenv mItem afterResolution delayed
error (Error(FSComp.SR.expressionHasNoName(), mExprAndTypeArgs))
| _ ->
let checkTys tpenv kinds = TcTypesOrMeasures (Some kinds) cenv NewTyparsOK CheckCxs ItemOccurrence.UseInType env tpenv tys mItem
let _, vExpr, isSpecial, _, _, tpenv = TcVal true cenv env tpenv vref (Some (NormalValUse, checkTys)) (Some afterResolution) mItem
let _, vExpr, isSpecial, _, _, tpenv = TcVal cenv env tpenv vref (Some (NormalValUse, checkTys)) (Some afterResolution) mItem

let vexpFlex = (if isSpecial then MakeApplicableExprNoFlex cenv vExpr else MakeApplicableExprWithFlex cenv env vExpr)
// We need to eventually record the type resolution for an expression, but this is done
Expand All @@ -9268,7 +9267,7 @@ and TcValueItemThen cenv overallTy env vref tpenv mItem afterResolution delayed

// Value get
| _ ->
let _, vExpr, isSpecial, _, _, tpenv = TcVal true cenv env tpenv vref None (Some afterResolution) mItem
let _, vExpr, isSpecial, _, _, tpenv = TcVal cenv env tpenv vref None (Some afterResolution) mItem

let vExpr, tpenv =
match vExpr with
Expand Down
1 change: 0 additions & 1 deletion src/Compiler/Checking/Expressions/CheckExpressions.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,6 @@ val TcPatLongIdentActivePatternCase:
val ConvSynPatToSynExpr: synPat: SynPat -> SynExpr

val TcVal:
checkAttributes: bool ->
cenv: TcFileState ->
env: TcEnv ->
tpenv: UnscopedTyparEnv ->
Expand Down

0 comments on commit e91da53

Please sign in to comment.