Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8875ba4

Browse files
forkiKevinRansom
authored andcommitted
check constant first (#3130)
* check constant first* check constant first
1 parent44db9d0 commit8875ba4

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

‎src/fsharp/TypeChecker.fs‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ let MakeMemberDataAndMangledNameForMemberVal(g,tcref,isExtrinsic,attrs,optImplSl
10401040
if n<>3 && opTakesThreeArgs then warning(Error(FSComp.SR.memberOperatorDefinitionWithNonTripleArgument(name,n),m))
10411041
if not (isNil otherArgs) then warning(Error(FSComp.SR.memberOperatorDefinitionWithCurriedArguments(name),m))
10421042

1043-
if IsMangledOpName id.idText&& isExtrinsicthen
1043+
ifisExtrinsic &&IsMangledOpName id.idText then
10441044
warning(Error(FSComp.SR.tcMemberOperatorDefinitionInExtrinsic(),id.idRange))
10451045

10461046
ValMemberInfoTransient(memberInfo,logicalName,compiledName)
@@ -2628,7 +2628,7 @@ let FreshenObjectArgType cenv m rigid tcref isExtrinsic declaredTyconTypars =
26282628
#endif
26292629
// Struct members have a byref 'this' type (unless they are extrinsic extension members)
26302630
let thisTy =
2631-
iftcref.IsStructOrEnumTycon&&not isExtrinsic then
2631+
ifnot isExtrinsic&&tcref.IsStructOrEnumTycon then
26322632
mkByrefTy cenv.g objTy
26332633
else
26342634
objTy
@@ -9584,13 +9584,13 @@ and TcMethodApplication
95849584
elif isDelegateTy cenv.g calledArgTy && isFunTy cenv.g callerArgTy then
95859585
CoerceFromFSharpFuncToDelegate cenv.g cenv.amap cenv.infoReader ad callerArgTy m callerArgExpr calledArgTy
95869586

9587-
elif isLinqExpressionTy cenv.g calledArgTy &&isDelegateTy cenv.g (destLinqExpressionTy cenv.g calledArgTy) && isFunTy cenv.g callerArgTy then
9587+
elif isLinqExpressionTy cenv.g calledArgTy && isDelegateTy cenv.g (destLinqExpressionTy cenv.g calledArgTy) && isFunTy cenv.g callerArgTy then
95889588
let delegateTy = destLinqExpressionTy cenv.g calledArgTy
95899589
let expr = CoerceFromFSharpFuncToDelegate cenv.g cenv.amap cenv.infoReader ad callerArgTy m callerArgExpr delegateTy
95909590
mkCallQuoteToLinqLambdaExpression cenv.g m delegateTy (Expr.Quote(expr, ref None, false, m, mkQuotedExprTy cenv.g delegateTy))
95919591

95929592
// auto conversions to quotations (to match auto conversions to LINQ expressions)
9593-
elif reflArgInfo.AutoQuote && isQuotedExprTy cenv.g calledArgTy &&not (isQuotedExprTy cenv.g callerArgTy) then
9593+
elif reflArgInfo.AutoQuote && isQuotedExprTy cenv.g calledArgTy && not (isQuotedExprTy cenv.g callerArgTy) then
95949594
match reflArgInfo with
95959595
| ReflectedArgInfo.Quote true ->
95969596
mkCallLiftValueWithDefn cenv.g m calledArgTy callerArgExpr
@@ -10326,14 +10326,16 @@ and TcNormalizedBinding declKind (cenv:cenv) env tpenv overallTy safeThisValOpt
1032610326

1032710327
// Check other attributes
1032810328
let hasLiteralAttr,konst = TcLiteral cenv overallExprTy env tpenv (valAttribs,rhsExpr)
10329-
if hasLiteralAttr && isThreadStatic then
10330-
errorR(Error(FSComp.SR.tcIllegalAttributesForLiteral(),mBinding))
10331-
if hasLiteralAttr && isMutable then
10332-
errorR(Error(FSComp.SR.tcLiteralCannotBeMutable(),mBinding))
10333-
if hasLiteralAttr && isInline then
10334-
errorR(Error(FSComp.SR.tcLiteralCannotBeInline(),mBinding))
10335-
if hasLiteralAttr && not (isNil declaredTypars) then
10336-
errorR(Error(FSComp.SR.tcLiteralCannotHaveGenericParameters(),mBinding))
10329+
10330+
if hasLiteralAttr then
10331+
if isThreadStatic then
10332+
errorR(Error(FSComp.SR.tcIllegalAttributesForLiteral(),mBinding))
10333+
if isMutable then
10334+
errorR(Error(FSComp.SR.tcLiteralCannotBeMutable(),mBinding))
10335+
if isInline then
10336+
errorR(Error(FSComp.SR.tcLiteralCannotBeInline(),mBinding))
10337+
if not (isNil declaredTypars) then
10338+
errorR(Error(FSComp.SR.tcLiteralCannotHaveGenericParameters(),mBinding))
1033710339

1033810340
CheckedBindingInfo(inlineFlag,valAttribs,doc,tcPatPhase2,flex,nameToPrelimValSchemeMap,rhsExprChecked,argAndRetAttribs,overallPatTy,mBinding,spBind,compgen,konst,isFixed),tpenv
1033910341

@@ -10927,8 +10929,7 @@ and AnalyzeRecursiveStaticMemberOrValDecl (cenv, envinner: TcEnv, tpenv, declKin
1092710929
CheckMemberFlags cenv.g None newslotsOK overridesOK memberFlags id.idRange
1092810930
CheckForNonAbstractInterface declKind tcref memberFlags id.idRange
1092910931

10930-
if tcref.Deref.IsExceptionDecl &&
10931-
(memberFlags.MemberKind = MemberKind.Constructor) then
10932+
if memberFlags.MemberKind = MemberKind.Constructor && tcref.Deref.IsExceptionDecl then
1093210933
error(Error(FSComp.SR.tcConstructorsDisallowedInExceptionAugmentation(),id.idRange))
1093310934

1093410935
let isExtrinsic = (declKind = ExtrinsicExtensionBinding)
@@ -11753,15 +11754,15 @@ exception NotUpperCaseConstructor of range
1175311754

1175411755
let CheckNamespaceModuleOrTypeName (g:TcGlobals) (id:Ident) =
1175511756
// type names '[]' etc. are used in fslib
11756-
if not g.compilingFslib &&id.idText.IndexOfAny(IllegalCharactersInTypeAndNamespaceNames) <> -1 then
11757+
if not g.compilingFslib && id.idText.IndexOfAny(IllegalCharactersInTypeAndNamespaceNames) <> -1 then
1175711758
errorR(Error(FSComp.SR.tcInvalidNamespaceModuleTypeUnionName(),id.idRange))
1175811759

1175911760
let CheckDuplicates (idf : _ -> Ident) k elems =
1176011761
elems |> List.iteri (fun i uc1 ->
1176111762
elems |> List.iteri (fun j uc2 ->
1176211763
let id1 = (idf uc1)
1176311764
let id2 = (idf uc2)
11764-
if j > i &&id1.idText = id2.idText then
11765+
if j > i && id1.idText = id2.idText then
1176511766
errorR (Duplicate(k,id1.idText,id1.idRange))))
1176611767
elems
1176711768

@@ -11794,7 +11795,7 @@ module TcRecdUnionAndEnumDeclarations = begin
1179411795
if isVolatile then
1179511796
error(Error(FSComp.SR.tcVolatileOnlyOnClassLetBindings(),m))
1179611797

11797-
if isIncrClass&& (not zeroInit || not isMutable) then errorR(Error(FSComp.SR.tcUninitializedValFieldsMustBeMutable(),m))
11798+
if isIncrClass && (not zeroInit || not isMutable) then errorR(Error(FSComp.SR.tcUninitializedValFieldsMustBeMutable(),m))
1179811799
if isStatic && (not zeroInit || not isMutable || vis <> Some SynAccess.Private ) then errorR(Error(FSComp.SR.tcStaticValFieldsMustBeMutableAndPrivate(),m))
1179911800
let konst = if zeroInit then Some Const.Zero else None
1180011801
let rfspec = MakeRecdFieldSpec cenv env parent (isStatic,konst,ty',attrsForProperty,attrsForField,id,isMutable,isVolatile,xmldoc,vis,m)
@@ -12958,7 +12959,7 @@ module MutRecBindingChecking =
1295812959
| TyparKind.Measure,false -> error(Error(FSComp.SR.tcMeasureDeclarationsRequireStaticMembers(), m))
1295912960
| _ -> ()
1296012961

12961-
iftcref.IsStructOrEnumTycon&&not isStatic then
12962+
ifnot isStatic&&tcref.IsStructOrEnumTycon then
1296212963
let allDo = letBinds |> List.forall (function (Binding(_,DoBinding,_,_,_,_,_,_,_,_,_,_)) -> true | _ -> false)
1296312964
// Code for potential future design change to allow functions-compiled-as-members in structs
1296412965
if allDo then
@@ -13175,9 +13176,8 @@ module MutRecBindingChecking =
1317513176
let envNonRec = (envNonRec,binds) ||> List.fold (fun acc bind -> AddLocalValPrimitive bind.Var acc)
1317613177

1317713178
// Check to see that local bindings and members don't have the same name and check some other adhoc conditions
13178-
for bind in binds do
13179-
13180-
if HasFSharpAttributeOpt cenv.g cenv.g.attrib_DllImportAttribute bind.Var.Attribs && not isStatic then
13179+
for bind in binds do
13180+
if not isStatic && HasFSharpAttributeOpt cenv.g cenv.g.attrib_DllImportAttribute bind.Var.Attribs then
1318113181
errorR(Error(FSComp.SR.tcDllImportNotAllowed(),bind.Var.Range))
1318213182

1318313183
let nm = bind.Var.DisplayName
@@ -16041,7 +16041,7 @@ module TcDeclarations =
1604116041
let preEstablishedHasDefaultCtor =
1604216042
members |> List.exists (function
1604316043
| SynMemberSig.Member (valSpfn,memberFlags,_) ->
16044-
memberFlags.MemberKind=MemberKind.Constructor&&
16044+
memberFlags.MemberKind=MemberKind.Constructor &&
1604516045
// REVIEW: This is a syntactic approximation
1604616046
(match valSpfn.SynType, valSpfn.SynInfo.ArgInfos with
1604716047
| SynType.Fun (SynType.LongIdent (LongIdentWithDots([id],_)), _, _), [[_]] when id.idText = "unit" -> true
@@ -16818,7 +16818,7 @@ let ApplyDefaults cenv g denvAtEnd m mexpr extraAttribs =
1681816818
match tpc with
1681916819
| TyparConstraint.DefaultsTo(priority2,ty2,m) when priority2 = priority ->
1682016820
let ty1 = mkTyparTy tp
16821-
if not tp.IsSolved&& not (typeEquiv cenv.g ty1 ty2) then
16821+
if not tp.IsSolved && not (typeEquiv cenv.g ty1 ty2) then
1682216822
let csenv = MakeConstraintSolverEnv ContextInfo.NoContext cenv.css m denvAtEnd
1682316823
TryD (fun () -> ConstraintSolver.SolveTyparEqualsTyp csenv 0 m NoTrace ty1 ty2)
1682416824
(fun e -> solveTypAsError cenv denvAtEnd m ty1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp