diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 0fdcde7e13a..6f319030449 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "fantomas": { - "version": "5.0.0-beta-005", + "version": "5.0.3", "commands": [ "fantomas" ] diff --git a/.fantomasignore b/.fantomasignore index a3094f05991..fabfd3547e1 100644 --- a/.fantomasignore +++ b/.fantomasignore @@ -12,14 +12,79 @@ artifacts/ # Explicitly unformatted implementation files -src/Compiler/Checking/**/*.fs -src/Compiler/DependencyManager/**/*.fs -src/Compiler/Facilities/**/*.fs -src/Compiler/Interactive/**/*.fs -src/Compiler/Legacy/**/*.fs -src/Compiler/Optimize/**/*.fs -src/Compiler/Symbols/**/*.fs -src/Compiler/TypedTree/**/*.fs +src/Compiler/Checking/AccessibilityLogic.fs +src/Compiler/Checking/AttributeChecking.fs +src/Compiler/Checking/AugmentWithHashCompare.fs +src/Compiler/Checking/CheckBasics.fs +src/Compiler/Checking/CheckComputationExpressions.fs +src/Compiler/Checking/CheckDeclarations.fs +src/Compiler/Checking/CheckExpressions.fs +src/Compiler/Checking/CheckFormatStrings.fs +src/Compiler/Checking/CheckIncrementalClasses.fs +src/Compiler/Checking/CheckPatterns.fs +src/Compiler/Checking/ConstraintSolver.fs +src/Compiler/Checking/FindUnsolved.fs +src/Compiler/Checking/import.fs +src/Compiler/Checking/InfoReader.fs +src/Compiler/Checking/infos.fs +src/Compiler/Checking/MethodCalls.fs +src/Compiler/Checking/MethodOverrides.fs +src/Compiler/Checking/NameResolution.fs +src/Compiler/Checking/NicePrint.fs +src/Compiler/Checking/PatternMatchCompilation.fs +src/Compiler/Checking/PostInferenceChecks.fs +src/Compiler/Checking/QuotationTranslator.fs +src/Compiler/Checking/SignatureConformance.fs +src/Compiler/Checking/TypeHierarchy.fs +src/Compiler/Checking/TypeRelations.fs + +src/Compiler/DependencyManager/AssemblyResolveHandler.fs +src/Compiler/DependencyManager/DependencyProvider.fs +src/Compiler/DependencyManager/NativeDllResolveHandler.fs + +src/Compiler/Facilities/BuildGraph.fs +src/Compiler/Facilities/CompilerLocation.fs +src/Compiler/Facilities/DiagnosticOptions.fs +src/Compiler/Facilities/DiagnosticResolutionHints.fs +src/Compiler/Facilities/DiagnosticsLogger.fs +src/Compiler/Facilities/LanguageFeatures.fs +src/Compiler/Facilities/Logger.fs +src/Compiler/Facilities/prim-lexing.fs +src/Compiler/Facilities/prim-parsing.fs +src/Compiler/Facilities/ReferenceResolver.fs +src/Compiler/Facilities/SimulatedMSBuildReferenceResolver.fs +src/Compiler/Facilities/TextLayoutRender.fs + +src/Compiler/Interactive/ControlledExecution.fs +src/Compiler/Interactive/fsi.fs + +src/Compiler/Legacy/LegacyHostedCompilerForTesting.fs +src/Compiler/Legacy/LegacyMSBuildReferenceResolver.fs + +src/Compiler/Optimize/DetupleArgs.fs +src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs +src/Compiler/Optimize/LowerCalls.fs +src/Compiler/Optimize/LowerComputedCollections.fs +src/Compiler/Optimize/LowerLocalMutables.fs +src/Compiler/Optimize/LowerSequences.fs +src/Compiler/Optimize/LowerStateMachines.fs +src/Compiler/Optimize/Optimizer.fs + +src/Compiler/Symbols/Exprs.fs +src/Compiler/Symbols/FSharpDiagnostic.fs +src/Compiler/Symbols/SymbolHelpers.fs +src/Compiler/Symbols/SymbolPatterns.fs +src/Compiler/Symbols/Symbols.fs + +src/Compiler/TypedTree/CompilerGlobalState.fs +src/Compiler/TypedTree/QuotationPickler.fs +src/Compiler/TypedTree/tainted.fs +src/Compiler/TypedTree/TcGlobals.fs +src/Compiler/TypedTree/TypedTree.fs +src/Compiler/TypedTree/TypedTreeBasics.fs +src/Compiler/TypedTree/TypedTreeOps.fs +src/Compiler/TypedTree/TypedTreePickle.fs +src/Compiler/TypedTree/TypeProviders.fs # Explicitly unformatted file that needs more care to get it to format well diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index bbd5183842a..e0a5bb576aa 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -4629,7 +4629,7 @@ let rec encodeCustomAttrElemTypeForObject x = | ILAttribElem.UInt64 _ -> [| et_U8 |] | ILAttribElem.Type _ -> [| 0x50uy |] | ILAttribElem.TypeRef _ -> [| 0x50uy |] - | ILAttribElem.Null _ -> [| et_STRING |] // yes, the 0xe prefix is used when passing a "null" to a property or argument of type "object" here + | ILAttribElem.Null -> [| et_STRING |] // yes, the 0xe prefix is used when passing a "null" to a property or argument of type "object" here | ILAttribElem.Single _ -> [| et_R4 |] | ILAttribElem.Double _ -> [| et_R8 |] | ILAttribElem.Array (elemTy, _) -> [| yield et_SZARRAY; yield! encodeCustomAttrElemType elemTy |] diff --git a/src/Compiler/AbstractIL/ilreflect.fs b/src/Compiler/AbstractIL/ilreflect.fs index 1b30f20529f..0fc3e73e247 100644 --- a/src/Compiler/AbstractIL/ilreflect.fs +++ b/src/Compiler/AbstractIL/ilreflect.fs @@ -505,7 +505,7 @@ let convTypeRefAux (cenv: cenv) (tref: ILTypeRef) = match tref.Scope with | ILScopeRef.Assembly asmref -> convResolveAssemblyRef cenv asmref qualifiedName | ILScopeRef.Module _ - | ILScopeRef.Local _ -> + | ILScopeRef.Local -> let typT = Type.GetType qualifiedName match typT with diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index bd675aba272..9e21c434270 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -9905,7 +9905,7 @@ and TcMethodArg cenv env (lambdaPropagationInfo, tpenv) (lambdaPropagationInfoFo let lambdaPropagationInfo = [| for info, argInfo in Array.zip lambdaPropagationInfo lambdaPropagationInfoForArg do match argInfo with - | ArgDoesNotMatch _ -> () + | ArgDoesNotMatch -> () | NoInfo | CallerLambdaHasArgTypes _ -> yield info | CalledArgMatchesType (adjustedCalledArgTy, noEagerConstraintApplication) -> diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index 70382723f92..87b0678b69c 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -604,7 +604,15 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m let args, extraPatternsFromNames = match args with - | SynArgPats.Pats args -> args, [] + | SynArgPats.Pats args -> + if g.langVersion.SupportsFeature(LanguageFeature.MatchNotAllowedForUnionCaseWithNoData) then + match args with + | [ SynPat.Wild _ ] | [ SynPat.Named _ ] when argNames.IsEmpty -> + warning(Error(FSComp.SR.matchNotAllowedForUnionCaseWithNoData(), m)) + args, [] + | _ -> args, [] + else + args, [] | SynArgPats.NamePatPairs (pairs, m, _) -> // rewrite patterns from the form (name-N = pat-N; ...) to (..._, pat-N, _...) // so type T = Case of name: int * value: int @@ -661,10 +669,12 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m // note: we allow both 'C _' and 'C (_)' regardless of number of argument of the pattern | [SynPatErrorSkip(SynPat.Wild _ as e) | SynPatErrorSkip(SynPat.Paren(SynPatErrorSkip(SynPat.Wild _ as e), _))] -> List.replicate numArgTys e, [] - | args when numArgTys = 0 -> - errorR (Error (FSComp.SR.tcUnionCaseDoesNotTakeArguments (), m)) - [], args + if g.langVersion.SupportsFeature(LanguageFeature.MatchNotAllowedForUnionCaseWithNoData) then + [], args + else + errorR (Error (FSComp.SR.tcUnionCaseDoesNotTakeArguments (), m)) + [], args | arg :: rest when numArgTys = 1 -> if numArgTys = 1 && not (List.isEmpty rest) then diff --git a/src/Compiler/Checking/PatternMatchCompilation.fs b/src/Compiler/Checking/PatternMatchCompilation.fs index 2c53c73202e..8d59e3301dc 100644 --- a/src/Compiler/Checking/PatternMatchCompilation.fs +++ b/src/Compiler/Checking/PatternMatchCompilation.fs @@ -648,9 +648,9 @@ let isDiscrimSubsumedBy g amap m discrim taken = match taken, discrim with | DecisionTreeTest.IsInst (_, tgtTy1), DecisionTreeTest.IsInst (_, tgtTy2) -> computeWhatFailingTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 = Implication.Fails - | DecisionTreeTest.IsNull _, DecisionTreeTest.IsInst (_, tgtTy2) -> + | DecisionTreeTest.IsNull, DecisionTreeTest.IsInst (_, tgtTy2) -> computeWhatFailingNullTestImpliesAboutTypeTest g tgtTy2 = Implication.Fails - | DecisionTreeTest.IsInst (_, tgtTy1), DecisionTreeTest.IsNull _ -> + | DecisionTreeTest.IsInst (_, tgtTy1), DecisionTreeTest.IsNull -> computeWhatFailingTypeTestImpliesAboutNullTest g tgtTy1 = Implication.Fails | _ -> false @@ -690,7 +690,7 @@ let discrimWithinSimultaneousClass g amap m discrim prev = // Check that each previous test in the set, if successful, gives some information about this test prev |> List.forall (fun edge -> match edge with - | DecisionTreeTest.IsNull _ -> true + | DecisionTreeTest.IsNull -> true | DecisionTreeTest.IsInst (_, tgtTy1) -> computeWhatSuccessfulTypeTestImpliesAboutNullTest g tgtTy1 <> Implication.Nothing | _ -> false) @@ -698,7 +698,7 @@ let discrimWithinSimultaneousClass g amap m discrim prev = // Check that each previous test in the set, if successful, gives some information about this test prev |> List.forall (fun edge -> match edge with - | DecisionTreeTest.IsNull _ -> true + | DecisionTreeTest.IsNull -> true | DecisionTreeTest.IsInst (_, tgtTy1) -> computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 <> Implication.Nothing | _ -> false) @@ -1501,7 +1501,7 @@ let CompilePatternBasic // F# exception definitions are sealed. [] - | DecisionTreeTest.IsNull _ -> + | DecisionTreeTest.IsNull -> match computeWhatSuccessfulNullTestImpliesAboutTypeTest g tgtTy1 with | Implication.Succeeds -> [Frontier (i, newActives, valMap)] | Implication.Fails -> [] @@ -1537,7 +1537,7 @@ let CompilePatternBasic | Implication.Nothing -> [frontier] - | DecisionTreeTest.IsNull _ -> + | DecisionTreeTest.IsNull -> match computeWhatSuccessfulNullTestImpliesAboutTypeTest g tgtTy1 with | Implication.Succeeds -> [Frontier (i, newActives, valMap)] | Implication.Fails -> [] diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index b4d9acf83f9..9338abd28f5 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -685,7 +685,7 @@ let CheckTypeInstNoInnerByrefs cenv env m tyargs = /// Applied functions get wrapped in coerce nodes for subsumption coercions let (|OptionalCoerce|) expr = match stripDebugPoints expr with - | Expr.Op (TOp.Coerce _, _, [DebugPoints(Expr.App (f, _, _, [], _), _)], _) -> f + | Expr.Op (TOp.Coerce, _, [DebugPoints(Expr.App (f, _, _, [], _), _)], _) -> f | _ -> expr /// Check an expression doesn't contain a 'reraise' @@ -1539,7 +1539,7 @@ and CheckExprOp cenv env (op, tyargs, args, m) ctxt expr = else { scope = 1; flags = LimitFlags.None } - | TOp.LValueOp (LSet _, vref), _, [arg] -> + | TOp.LValueOp (LSet, vref), _, [arg] -> let isVrefLimited = not (HasLimitFlag LimitFlags.StackReferringSpanLike (GetLimitVal cenv env m vref.Deref)) let isArgLimited = HasLimitFlag LimitFlags.StackReferringSpanLike (CheckExprPermitByRefLike cenv env arg) if isVrefLimited && isArgLimited then @@ -1901,7 +1901,7 @@ and CheckAttribArgExpr cenv env expr = | Const.Double _ | Const.Single _ | Const.Char _ - | Const.Zero _ + | Const.Zero | Const.String _ -> () | _ -> if cenv.reportErrors then diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 829b7e03d20..20208e2870c 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -2840,9 +2840,7 @@ let ComputeDebugPointForBinding g bind = | DebugPointAtBinding.NoneAtDo, _ -> false, None | DebugPointAtBinding.NoneAtLet, _ -> false, None // Don't emit debug points for lambdas. - | _, - (Expr.Lambda _ - | Expr.TyLambda _) -> false, None + | _, (Expr.Lambda _ | Expr.TyLambda _) -> false, None | DebugPointAtBinding.Yes m, _ -> false, Some m //------------------------------------------------------------------------- @@ -4150,7 +4148,7 @@ and GenApp (cenv: cenv) cgbuf eenv (f, fty, tyargs, curriedArgs, m) sequel = | Expr.Val (v, _, m), _, [ arg ] when valRefEq g v g.methodhandleof_vref -> let (|OptionalCoerce|) x = match stripDebugPoints x with - | Expr.Op (TOp.Coerce _, _, [ arg ], _) -> arg + | Expr.Op (TOp.Coerce, _, [ arg ], _) -> arg | x -> x let (|OptionalTyapp|) x = @@ -4695,7 +4693,7 @@ and eligibleForFilter (cenv: cenv) expr = | Expr.Op (TOp.UnionCaseFieldGet _, _, _, _) -> true | Expr.Op (TOp.ValFieldGet _, _, _, _) -> true | Expr.Op (TOp.TupleFieldGet _, _, _, _) -> true - | Expr.Op (TOp.Coerce _, _, _, _) -> true + | Expr.Op (TOp.Coerce, _, _, _) -> true | Expr.Val _ -> true | _ -> false @@ -5134,21 +5132,10 @@ and GenAsmCode cenv cgbuf eenv (il, tyargs, args, returnTys, m) sequel = // For these we can just generate the argument and change the test (from a brfalse to a brtrue and vice versa) | ([ AI_ceq ], [ arg1 - Expr.Const ((Const.Bool false - | Const.SByte 0y - | Const.Int16 0s - | Const.Int32 0 - | Const.Int64 0L - | Const.Byte 0uy - | Const.UInt16 0us - | Const.UInt32 0u - | Const.UInt64 0UL), + Expr.Const ((Const.Bool false | Const.SByte 0y | Const.Int16 0s | Const.Int32 0 | Const.Int64 0L | Const.Byte 0uy | Const.UInt16 0us | Const.UInt32 0u | Const.UInt64 0UL), _, _) ], - CmpThenBrOrContinue (1, - [ I_brcmp ((BI_brfalse - | BI_brtrue) as bi, - label1) ]), + CmpThenBrOrContinue (1, [ I_brcmp ((BI_brfalse | BI_brtrue) as bi, label1) ]), _) -> let bi = @@ -7587,7 +7574,7 @@ and GenDecisionTreeSwitch // Use GenDecisionTreeTest to generate a single test for null (when no box required) where the success // is going to the immediate first node in the tree - | TCase (DecisionTreeTest.IsNull _, (TDSuccess ([], 0) as successTree)) :: rest when + | TCase (DecisionTreeTest.IsNull, (TDSuccess ([], 0) as successTree)) :: rest when rest.Length = (match defaultTargetOpt with | None -> 1 | Some _ -> 0) @@ -7903,9 +7890,7 @@ and GenDecisionTreeTest // If so, emit the failure logic, then came back and do the success target, then // do any postponed failure target. match successTree, failureTree with - | TDSuccess _, - (TDBind _ - | TDSwitch _) -> + | TDSuccess _, (TDBind _ | TDSwitch _) -> // OK, there is more logic in the decision tree on the failure branch let success = CG.GenerateDelayMark cgbuf "testSuccess" @@ -10641,10 +10626,9 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = | None -> None | Some memberInfo -> match name, memberInfo.MemberFlags.MemberKind with - | ("Item" - | "op_IndexedLookup"), - (SynMemberKind.PropertyGet - | SynMemberKind.PropertySet) when not (isNil (ArgInfosOfPropertyVal g vref.Deref)) -> + | ("Item" | "op_IndexedLookup"), (SynMemberKind.PropertyGet | SynMemberKind.PropertySet) when + not (isNil (ArgInfosOfPropertyVal g vref.Deref)) + -> Some( mkILCustomAttribute ( g.FindSysILTypeRef "System.Reflection.DefaultMemberAttribute", diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index a2fd68372c7..6314212327a 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -240,6 +240,7 @@ type Exception with // 24 cannot be reused | PatternMatchCompilation.MatchIncomplete _ -> 25 | PatternMatchCompilation.RuleNeverMatched _ -> 26 + | ValNotMutable _ -> 27 | ValNotLocal _ -> 28 | MissingFields _ -> 29 @@ -1083,7 +1084,7 @@ type Exception with | Parser.TOKEN_BAR_RBRACK -> SR.GetString("Parser.TOKEN.BAR.RBRACK") | Parser.TOKEN_BAR_RBRACE -> SR.GetString("Parser.TOKEN.BAR.RBRACE") | Parser.TOKEN_GREATER_RBRACK -> SR.GetString("Parser.TOKEN.GREATER.RBRACK") - | Parser.TOKEN_RQUOTE_DOT _ + | Parser.TOKEN_RQUOTE_DOT | Parser.TOKEN_RQUOTE -> SR.GetString("Parser.TOKEN.RQUOTE") | Parser.TOKEN_RBRACK -> SR.GetString("Parser.TOKEN.RBRACK") | Parser.TOKEN_RBRACE @@ -1110,8 +1111,8 @@ type Exception with | Parser.TOKEN_OTHEN -> SR.GetString("Parser.TOKEN.OTHEN") | Parser.TOKEN_ELSE | Parser.TOKEN_OELSE -> SR.GetString("Parser.TOKEN.OELSE") - | Parser.TOKEN_LET _ - | Parser.TOKEN_OLET _ -> SR.GetString("Parser.TOKEN.OLET") + | Parser.TOKEN_LET + | Parser.TOKEN_OLET -> SR.GetString("Parser.TOKEN.OLET") | Parser.TOKEN_OBINDER | Parser.TOKEN_BINDER -> SR.GetString("Parser.TOKEN.BINDER") | Parser.TOKEN_OAND_BANG diff --git a/src/Compiler/Driver/ParseAndCheckInputs.fs b/src/Compiler/Driver/ParseAndCheckInputs.fs index db3f30d41b5..3f4ac2f89ee 100644 --- a/src/Compiler/Driver/ParseAndCheckInputs.fs +++ b/src/Compiler/Driver/ParseAndCheckInputs.fs @@ -844,10 +844,7 @@ let ProcessMetaCommandsFromInput | ParsedHashDirective ("nowarn", ParsedHashDirectiveArguments numbers, m) -> List.fold (fun state d -> nowarnF state (m, d)) state numbers - | ParsedHashDirective (("reference" - | "r"), - ParsedHashDirectiveArguments args, - m) -> + | ParsedHashDirective (("reference" | "r"), ParsedHashDirectiveArguments args, m) -> matchedm <- m ProcessDependencyManagerDirective Directive.Resolution args m state diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index a298af54908..80c356d31db 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1554,6 +1554,7 @@ featureSelfTypeConstraints,"self type constraints" featureRequiredProperties,"support for required properties" featureInitProperties,"support for consuming init properties" featureLowercaseDUWhenRequireQualifiedAccess,"Allow lowercase DU when RequireQualifiedAccess attribute" +featureMatchNotAllowedForUnionCaseWithNoData,"Pattern match discard is not allowed for union case that takes no data." 3353,fsiInvalidDirective,"Invalid directive '#%s %s'" 3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." @@ -1654,3 +1655,4 @@ reprStateMachineInvalidForm,"The state machine has an unexpected form" 3545,tcMissingRequiredMembers,"The following required properties have to be initalized:%s" 3546,parsExpectingPatternInTuple,"Expecting pattern" 3547,parsExpectedPatternAfterToken,"Expected a pattern after this point" +3548,matchNotAllowedForUnionCaseWithNoData,"Pattern discard is not allowed for union case that takes no data." diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 07bcca57870..8644fbe9971 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -54,6 +54,7 @@ type LanguageFeature = | LowercaseDUWhenRequireQualifiedAccess | InterfacesWithAbstractStaticMembers | SelfTypeConstraints + | MatchNotAllowedForUnionCaseWithNoData /// LanguageVersion management type LanguageVersion(versionText) = @@ -124,6 +125,7 @@ type LanguageVersion(versionText) = // F# preview LanguageFeature.FromEndSlicing, previewVersion + LanguageFeature.MatchNotAllowedForUnionCaseWithNoData, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -230,6 +232,7 @@ type LanguageVersion(versionText) = | LanguageFeature.LowercaseDUWhenRequireQualifiedAccess -> FSComp.SR.featureLowercaseDUWhenRequireQualifiedAccess () | LanguageFeature.InterfacesWithAbstractStaticMembers -> FSComp.SR.featureInterfacesWithAbstractStaticMembers () | LanguageFeature.SelfTypeConstraints -> FSComp.SR.featureSelfTypeConstraints () + | LanguageFeature.MatchNotAllowedForUnionCaseWithNoData -> FSComp.SR.featureMatchNotAllowedForUnionCaseWithNoData () /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index cb7991392c1..694a6ae73fd 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -44,6 +44,7 @@ type LanguageFeature = | LowercaseDUWhenRequireQualifiedAccess | InterfacesWithAbstractStaticMembers | SelfTypeConstraints + | MatchNotAllowedForUnionCaseWithNoData /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index f4ee6685a11..898f15d884f 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -279,7 +279,7 @@ type ILMultiInMemoryAssemblyEmitEnv( | ILScopeRef.Assembly asmref -> convResolveAssemblyRef asmref qualifiedName | ILScopeRef.Module _ - | ILScopeRef.Local _ -> + | ILScopeRef.Local -> let typT = Type.GetType qualifiedName match typT with | null -> error(Error(FSComp.SR.itemNotFoundDuringDynamicCodeGen ("type", qualifiedName, ""), range0)) diff --git a/src/Compiler/Optimize/Optimizer.fs b/src/Compiler/Optimize/Optimizer.fs index fa965069205..54665570cc5 100644 --- a/src/Compiler/Optimize/Optimizer.fs +++ b/src/Compiler/Optimize/Optimizer.fs @@ -1575,7 +1575,7 @@ let IsKnownOnlyMutableBeforeUse (vref: ValRef) = let IsDiscardableEffectExpr expr = match stripDebugPoints expr with - | Expr.Op (TOp.LValueOp (LByrefGet _, _), [], [], _) -> true + | Expr.Op (TOp.LValueOp (LByrefGet, _), [], [], _) -> true | _ -> false /// Checks is a value binding is non-discardable diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index 70647f70d59..0abff6d4d04 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -247,9 +247,7 @@ type FSharpSymbolUse(denv: DisplayEnv, symbol: FSharpSymbol, inst: TyparInstanti // 'seq' in 'seq { ... }' gets colored as keywords | Item.Value vref, ItemOccurence.Use when valRefEq denv.g denv.g.seq_vref vref -> true // custom builders, custom operations get colored as keywords - | (Item.CustomBuilder _ - | Item.CustomOperation _), - ItemOccurence.Use -> true + | (Item.CustomBuilder _ | Item.CustomOperation _), ItemOccurence.Use -> true | _ -> false member _.IsFromOpenStatement = itemOcc = ItemOccurence.Open @@ -2306,14 +2304,8 @@ module internal ParseAndCheckFile = matchBraces stackAfterMatch - | LPAREN - | LBRACE _ - | LBRACK - | LBRACE_BAR - | LBRACK_BAR - | LQUOTE _ - | LBRACK_LESS as tok, - _ -> matchBraces ((tok, lexbuf.LexemeRange) :: stack) + | LPAREN | LBRACE _ | LBRACK | LBRACE_BAR | LBRACK_BAR | LQUOTE _ | LBRACK_LESS as tok, _ -> + matchBraces ((tok, lexbuf.LexemeRange) :: stack) // INTERP_STRING_BEGIN_PART corresponds to $"... {" at the start of an interpolated string // @@ -2322,9 +2314,7 @@ module internal ParseAndCheckFile = // interpolation expression) // // Either way we start a new potential match at the last character - | INTERP_STRING_BEGIN_PART _ - | INTERP_STRING_PART _ as tok, - _ -> + | INTERP_STRING_BEGIN_PART _ | INTERP_STRING_PART _ as tok, _ -> let m = lexbuf.LexemeRange let m2 = @@ -2332,9 +2322,7 @@ module internal ParseAndCheckFile = matchBraces ((tok, m2) :: stack) - | (EOF _ - | LEX_FAILURE _), - _ -> () + | (EOF _ | LEX_FAILURE _), _ -> () | _ -> matchBraces stack matchBraces []) diff --git a/src/Compiler/Service/SemanticClassification.fs b/src/Compiler/Service/SemanticClassification.fs index 5da02e32094..f1fdc92c0bb 100644 --- a/src/Compiler/Service/SemanticClassification.fs +++ b/src/Compiler/Service/SemanticClassification.fs @@ -107,7 +107,7 @@ module TcResolutionsExtensions = | TFSharpInterface -> SemanticClassificationType.Interface | TFSharpStruct -> SemanticClassificationType.ValueType | TFSharpDelegate _ -> SemanticClassificationType.Delegate - | TFSharpEnum _ -> SemanticClassificationType.Enumeration + | TFSharpEnum -> SemanticClassificationType.Enumeration | TFSharpRecdRepr _ | TFSharpUnionRepr _ -> if isStructTyconRef g tcref then @@ -149,9 +149,9 @@ module TcResolutionsExtensions = match occ with | ItemOccurence.UseInType | ItemOccurence.UseInAttribute - | ItemOccurence.Use _ - | ItemOccurence.Binding _ - | ItemOccurence.Pattern _ + | ItemOccurence.Use + | ItemOccurence.Binding + | ItemOccurence.Pattern | ItemOccurence.Open -> Some() | _ -> None @@ -212,10 +212,8 @@ module TcResolutionsExtensions = resolutions |> Array.iter (fun cnr -> match cnr.Item, cnr.ItemOccurence, cnr.Range with - | (Item.CustomBuilder _ - | Item.CustomOperation _), - ItemOccurence.Use, - m -> add m SemanticClassificationType.ComputationExpression + | (Item.CustomBuilder _ | Item.CustomOperation _), ItemOccurence.Use, m -> + add m SemanticClassificationType.ComputationExpression | Item.Value vref, _, m when isValRefMutable g vref -> add m SemanticClassificationType.MutableVar diff --git a/src/Compiler/Service/ServiceDeclarationLists.fs b/src/Compiler/Service/ServiceDeclarationLists.fs index 399a3037eac..06cf656b078 100644 --- a/src/Compiler/Service/ServiceDeclarationLists.fs +++ b/src/Compiler/Service/ServiceDeclarationLists.fs @@ -862,7 +862,7 @@ module internal DescriptionListsImpl = | TFSharpInterface -> FSharpGlyph.Interface | TFSharpStruct -> FSharpGlyph.Struct | TFSharpDelegate _ -> FSharpGlyph.Delegate - | TFSharpEnum _ -> FSharpGlyph.Enum + | TFSharpEnum -> FSharpGlyph.Enum | TFSharpRecdRepr _ -> FSharpGlyph.Type | TFSharpUnionRepr _ -> FSharpGlyph.Union | TILObjectRepr (TILObjectReprData (_, _, td)) -> diff --git a/src/Compiler/Service/ServiceLexing.fs b/src/Compiler/Service/ServiceLexing.fs index 80cfb38cc6c..a772cd707aa 100644 --- a/src/Compiler/Service/ServiceLexing.fs +++ b/src/Compiler/Service/ServiceLexing.fs @@ -205,13 +205,9 @@ module internal TokenClassifications = // (this isn't entirely correct, but it'll work for now - see bug 3727) (FSharpTokenColorKind.Number, FSharpTokenCharKind.Operator, FSharpTokenTriggerClass.None) - | INFIX_STAR_DIV_MOD_OP ("mod" - | "land" - | "lor" - | "lxor") - | INFIX_STAR_STAR_OP ("lsl" - | "lsr" - | "asr") -> (FSharpTokenColorKind.Keyword, FSharpTokenCharKind.Keyword, FSharpTokenTriggerClass.None) + | INFIX_STAR_DIV_MOD_OP ("mod" | "land" | "lor" | "lxor") + | INFIX_STAR_STAR_OP ("lsl" | "lsr" | "asr") -> + (FSharpTokenColorKind.Keyword, FSharpTokenCharKind.Keyword, FSharpTokenTriggerClass.None) | LPAREN_STAR_RPAREN | DOLLAR diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index 7d3c916bc8e..ef194965b34 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -2037,10 +2037,7 @@ module ParsedInput = result <- Some(oldScope, oldPos, true) | Some (oldScope, oldPos, _), _ -> match kind, oldScope.Kind with - | (Namespace - | NestedModule - | TopModule), - OpenDeclaration + | (Namespace | NestedModule | TopModule), OpenDeclaration | _ when oldPos.Line <= line -> result <- Some( diff --git a/src/Compiler/Symbols/Symbols.fs b/src/Compiler/Symbols/Symbols.fs index 9adb5ffb1f9..4b8f8c4684b 100644 --- a/src/Compiler/Symbols/Symbols.fs +++ b/src/Compiler/Symbols/Symbols.fs @@ -2383,7 +2383,7 @@ type FSharpType(cenv, ty:TType) = isResolved() && protect <| fun () -> match stripTyparEqns ty with - | TType_app _ | TType_measure (Measure.Const _ | Measure.Prod _ | Measure.Inv _ | Measure.One _) -> true + | TType_app _ | TType_measure (Measure.Const _ | Measure.Prod _ | Measure.Inv _ | Measure.One) -> true | _ -> false member _.IsTupleType = diff --git a/src/Compiler/SyntaxTree/ParseHelpers.fs b/src/Compiler/SyntaxTree/ParseHelpers.fs index 6aa973d275e..ca0b858a0ba 100644 --- a/src/Compiler/SyntaxTree/ParseHelpers.fs +++ b/src/Compiler/SyntaxTree/ParseHelpers.fs @@ -13,6 +13,7 @@ open FSharp.Compiler.Text open FSharp.Compiler.Text.Position open FSharp.Compiler.Text.Range open FSharp.Compiler.Xml +open Internal.Utilities.Library open Internal.Utilities.Text.Lexing open Internal.Utilities.Text.Parsing @@ -860,3 +861,198 @@ let mkSynTypeTuple (elementTypes: SynTupleTypeSegment list) : SynType = ||> List.fold (fun acc segment -> unionRanges acc segment.Range) SynType.Tuple(false, elementTypes, range) + +#if DEBUG +let debugPrint s = + if Internal.Utilities.Text.Parsing.Flags.debug then + printfn "\n%s" s +#else +let debugPrint s = ignore s +#endif + +let exprFromParseError (e: SynExpr) = SynExpr.FromParseError(e, e.Range) + +let patFromParseError (e: SynPat) = SynPat.FromParseError(e, e.Range) + +// record bindings returned by the recdExprBindings rule has shape: +// (binding, separator-before-this-binding) +// this function converts arguments from form +// binding1 (binding2*sep1, binding3*sep2...) sepN +// to form +// binding1*sep1, binding2*sep2 +let rebindRanges first fields lastSep = + let rec run (name, mEquals, value) l acc = + match l with + | [] -> List.rev (SynExprRecordField(name, mEquals, value, lastSep) :: acc) + | (f, m) :: xs -> run f xs (SynExprRecordField(name, mEquals, value, m) :: acc) + + run first fields [] + +let mkUnderscoreRecdField m = + SynLongIdent([ ident ("_", m) ], [], [ None ]), false + +let mkRecdField (lidwd: SynLongIdent) = lidwd, true + +// Used for 'do expr' in a class. +let mkSynDoBinding (vis: SynAccess option, expr, m) = + match vis with + | Some vis -> errorR (Error(FSComp.SR.parsDoCannotHaveVisibilityDeclarations (vis.ToString()), m)) + | None -> () + + SynBinding( + None, + SynBindingKind.Do, + false, + false, + [], + PreXmlDoc.Empty, + SynInfo.emptySynValData, + SynPat.Const(SynConst.Unit, m), + None, + expr, + m, + DebugPointAtBinding.NoneAtDo, + SynBindingTrivia.Zero + ) + +let mkSynExprDecl (e: SynExpr) = SynModuleDecl.Expr(e, e.Range) + +let addAttribs attrs p = SynPat.Attrib(p, attrs, p.Range) + +let unionRangeWithPos (r: range) p = + let r2 = mkRange r.FileName p p + unionRanges r r2 + +/// Report a good error at the end of file, e.g. for non-terminated strings +let checkEndOfFileError t = + match t with + | LexCont.IfDefSkip (_, _, _, m) -> reportParseErrorAt m (FSComp.SR.parsEofInHashIf ()) + + | LexCont.String (_, _, LexerStringStyle.SingleQuote, kind, m) -> + if kind.IsInterpolated then + reportParseErrorAt m (FSComp.SR.parsEofInInterpolatedString ()) + else + reportParseErrorAt m (FSComp.SR.parsEofInString ()) + + | LexCont.String (_, _, LexerStringStyle.TripleQuote, kind, m) -> + if kind.IsInterpolated then + reportParseErrorAt m (FSComp.SR.parsEofInInterpolatedTripleQuoteString ()) + else + reportParseErrorAt m (FSComp.SR.parsEofInTripleQuoteString ()) + + | LexCont.String (_, _, LexerStringStyle.Verbatim, kind, m) -> + if kind.IsInterpolated then + reportParseErrorAt m (FSComp.SR.parsEofInInterpolatedVerbatimString ()) + else + reportParseErrorAt m (FSComp.SR.parsEofInVerbatimString ()) + + | LexCont.Comment (_, _, _, m) -> reportParseErrorAt m (FSComp.SR.parsEofInComment ()) + + | LexCont.SingleLineComment (_, _, _, m) -> reportParseErrorAt m (FSComp.SR.parsEofInComment ()) + + | LexCont.StringInComment (_, _, LexerStringStyle.SingleQuote, _, m) -> reportParseErrorAt m (FSComp.SR.parsEofInStringInComment ()) + + | LexCont.StringInComment (_, _, LexerStringStyle.Verbatim, _, m) -> + reportParseErrorAt m (FSComp.SR.parsEofInVerbatimStringInComment ()) + + | LexCont.StringInComment (_, _, LexerStringStyle.TripleQuote, _, m) -> + reportParseErrorAt m (FSComp.SR.parsEofInTripleQuoteStringInComment ()) + + | LexCont.MLOnly (_, _, m) -> reportParseErrorAt m (FSComp.SR.parsEofInIfOcaml ()) + + | LexCont.EndLine (_, _, LexerEndlineContinuation.Skip (_, m)) -> reportParseErrorAt m (FSComp.SR.parsEofInDirective ()) + + | LexCont.EndLine (endifs, nesting, LexerEndlineContinuation.Token) + | LexCont.Token (endifs, nesting) -> + match endifs with + | [] -> () + | (_, m) :: _ -> reportParseErrorAt m (FSComp.SR.parsNoHashEndIfFound ()) + + match nesting with + | [] -> () + | (_, _, m) :: _ -> reportParseErrorAt m (FSComp.SR.parsEofInInterpolatedStringFill ()) + +type BindingSet = BindingSetPreAttrs of range * bool * bool * (SynAttributes -> SynAccess option -> SynAttributes * SynBinding list) * range + +let mkClassMemberLocalBindings + ( + isStatic, + initialRangeOpt, + attrs, + vis, + BindingSetPreAttrs (_, isRec, isUse, declsPreAttrs, bindingSetRange) + ) = + let ignoredFreeAttrs, decls = declsPreAttrs attrs vis + + let mWhole = + match initialRangeOpt with + | None -> bindingSetRange + | Some m -> unionRanges m bindingSetRange + // decls could have a leading attribute + |> fun m -> (m, decls) ||> unionRangeWithListBy (fun (SynBinding (range = m)) -> m) + + if not (isNil ignoredFreeAttrs) then + warning (Error(FSComp.SR.parsAttributesIgnored (), mWhole)) + + if isUse then + errorR (Error(FSComp.SR.parsUseBindingsIllegalInImplicitClassConstructors (), mWhole)) + + SynMemberDefn.LetBindings(decls, isStatic, isRec, mWhole) + +let mkLocalBindings (mWhole, BindingSetPreAttrs (_, isRec, isUse, declsPreAttrs, _), mIn, body: SynExpr) = + let ignoredFreeAttrs, decls = declsPreAttrs [] None + + let mWhole = + match decls with + | SynBinding (xmlDoc = xmlDoc) :: _ -> unionRangeWithXmlDoc xmlDoc mWhole + | _ -> mWhole + + if not (isNil ignoredFreeAttrs) then + warning (Error(FSComp.SR.parsAttributesIgnored (), mWhole)) + + let mIn = + mIn + |> Option.bind (fun (mIn: range) -> + if Position.posEq mIn.Start body.Range.Start then + None + else + Some mIn) + + SynExpr.LetOrUse(isRec, isUse, decls, body, mWhole, { InKeyword = mIn }) + +let mkDefnBindings (mWhole, BindingSetPreAttrs (_, isRec, isUse, declsPreAttrs, _bindingSetRange), attrs, vis, attrsm) = + if isUse then + warning (Error(FSComp.SR.parsUseBindingsIllegalInModules (), mWhole)) + + let freeAttrs, decls = declsPreAttrs attrs vis + // decls might have an extended range due to leading attributes + let mWhole = + (mWhole, decls) ||> unionRangeWithListBy (fun (SynBinding (range = m)) -> m) + + let letDecls = [ SynModuleDecl.Let(isRec, decls, mWhole) ] + + let attrDecls = + if not (isNil freeAttrs) then + [ SynModuleDecl.Attributes(freeAttrs, attrsm) ] + else + [] + + attrDecls @ letDecls + +let idOfPat (parseState: IParseState) m p = + match p with + | SynPat.Wild r when parseState.LexBuffer.SupportsFeature LanguageFeature.WildCardInForLoop -> mkSynId r "_" + | SynPat.Named (SynIdent (id, _), false, _, _) -> id + | SynPat.LongIdent (longDotId = SynLongIdent ([ id ], _, _); typarDecls = None; argPats = SynArgPats.Pats []; accessibility = None) -> + id + | _ -> raiseParseErrorAt m (FSComp.SR.parsIntegerForLoopRequiresSimpleIdentifier ()) + +let checkForMultipleAugmentations m a1 a2 = + if not (isNil a1) && not (isNil a2) then + raiseParseErrorAt m (FSComp.SR.parsOnlyOneWithAugmentationAllowed ()) + + a1 @ a2 + +let rangeOfLongIdent (lid: LongIdent) = + System.Diagnostics.Debug.Assert(not lid.IsEmpty, "the parser should never produce a long-id that is the empty list") + (lid.Head.idRange, lid) ||> unionRangeWithListBy (fun id -> id.idRange) diff --git a/src/Compiler/SyntaxTree/ParseHelpers.fsi b/src/Compiler/SyntaxTree/ParseHelpers.fsi index e345dc68a3a..b5f9bac57f9 100644 --- a/src/Compiler/SyntaxTree/ParseHelpers.fsi +++ b/src/Compiler/SyntaxTree/ParseHelpers.fsi @@ -180,3 +180,56 @@ val mkSynMemberDefnGetSet: val adjustHatPrefixToTyparLookup: mFull: range -> rightExpr: SynExpr -> SynExpr val mkSynTypeTuple: elementTypes: SynTupleTypeSegment list -> SynType + +#if DEBUG +val debugPrint: s: string -> unit +#else +val debugPrint: s: 'a -> unit +#endif + +val exprFromParseError: e: SynExpr -> SynExpr + +val patFromParseError: e: SynPat -> SynPat + +val rebindRanges: + first: (RecordFieldName * range option * SynExpr option) -> + fields: ((RecordFieldName * range option * SynExpr option) * BlockSeparator option) list -> + lastSep: BlockSeparator option -> + SynExprRecordField list + +val mkUnderscoreRecdField: m: range -> SynLongIdent * bool + +val mkRecdField: lidwd: SynLongIdent -> SynLongIdent * bool + +val mkSynDoBinding: vis: SynAccess option * expr: SynExpr * m: range -> SynBinding + +val mkSynExprDecl: e: SynExpr -> SynModuleDecl + +val addAttribs: attrs: SynAttributes -> p: SynPat -> SynPat + +val unionRangeWithPos: r: range -> p: pos -> range + +val checkEndOfFileError: t: LexerContinuation -> unit + +type BindingSet = + | BindingSetPreAttrs of + range * + bool * + bool * + (SynAttributes -> SynAccess option -> SynAttributes * SynBinding list) * + range + +val mkClassMemberLocalBindings: + isStatic: bool * initialRangeOpt: range option * attrs: SynAttributes * vis: SynAccess option * BindingSet -> + SynMemberDefn + +val mkLocalBindings: mWhole: range * BindingSet * mIn: range option * body: SynExpr -> SynExpr + +val mkDefnBindings: + mWhole: range * BindingSet * attrs: SynAttributes * vis: SynAccess option * attrsm: range -> SynModuleDecl list + +val idOfPat: parseState: IParseState -> m: range -> p: SynPat -> Ident + +val checkForMultipleAugmentations: m: range -> a1: 'a list -> a2: 'a list -> 'a list + +val rangeOfLongIdent: lid: LongIdent -> range diff --git a/src/Compiler/TypedTree/QuotationPickler.fsi b/src/Compiler/TypedTree/QuotationPickler.fsi index 648e9d0acf6..fb7dbd2be5a 100644 --- a/src/Compiler/TypedTree/QuotationPickler.fsi +++ b/src/Compiler/TypedTree/QuotationPickler.fsi @@ -2,6 +2,7 @@ /// Code to pickle out quotations in the quotation binary format. module internal FSharp.Compiler.QuotationPickler + #nowarn "1178" type TypeData diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index c166230e718..f57954f7bf5 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -6049,7 +6049,7 @@ and remapTyconRepr ctxt tmenv repr = let ctxt = st.Context.RemapTyconRefs(unbox >> remapTyconRef tmenv.tyconRefRemap >> box) ProvidedType.ApplyContext (st, ctxt)) } #endif - | TNoRepr _ -> repr + | TNoRepr -> repr | TAsmRepr _ -> repr | TMeasureableRepr x -> TMeasureableRepr (remapType tmenv x) @@ -9684,10 +9684,10 @@ let rec EvalAttribArgExpr g x = | Const.Double _ | Const.Single _ | Const.Char _ - | Const.Zero _ + | Const.Zero | Const.String _ -> x - | Const.Decimal _ | Const.IntPtr _ | Const.UIntPtr _ | Const.Unit _ -> + | Const.Decimal _ | Const.IntPtr _ | Const.UIntPtr _ | Const.Unit -> errorR (Error ( FSComp.SR.tastNotAConstantExpression(), m)) x diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 119dd6ae478..fcb9235f928 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -27,172 +27,11 @@ open FSharp.Compiler.Text.Position open FSharp.Compiler.Text.Range open FSharp.Compiler.Xml -#if DEBUG -let debugPrint s = - if Internal.Utilities.Text.Parsing.Flags.debug then - printfn "\n%s" s -#else -let debugPrint s = ignore s -#endif - -let exprFromParseError (e:SynExpr) = SynExpr.FromParseError (e, e.Range) - -let patFromParseError (e:SynPat) = SynPat.FromParseError(e, e.Range) - -// record bindings returned by the recdExprBindings rule has shape: -// (binding, separator-before-this-binding) -// this function converts arguments from form -// binding1 (binding2*sep1, binding3*sep2...) sepN -// to form -// binding1*sep1, binding2*sep2 -let rebindRanges first fields lastSep = - let rec run (name, mEquals, value) l acc = - match l with - | [] -> List.rev (SynExprRecordField(name, mEquals, value, lastSep) :: acc) - | (f, m) :: xs -> run f xs (SynExprRecordField(name, mEquals, value, m) :: acc) - run first fields [] - -let mkUnderscoreRecdField m = SynLongIdent([ident("_", m)], [], [None]), false - -let mkRecdField lidwd = lidwd, true - -// Used for 'do expr' in a class. -let mkSynDoBinding (vis, expr, m) = - match vis with - | Some vis -> errorR(Error(FSComp.SR.parsDoCannotHaveVisibilityDeclarations (vis.ToString()), m)) - | None -> () - SynBinding(None, - SynBindingKind.Do, - false, false, [], PreXmlDoc.Empty, SynInfo.emptySynValData, - SynPat.Const(SynConst.Unit, m), - None, expr, m, DebugPointAtBinding.NoneAtDo, - SynBindingTrivia.Zero) - -let mkSynExprDecl (e: SynExpr) = - SynModuleDecl.Expr(e, e.Range) - -let addAttribs attrs p = SynPat.Attrib(p, attrs, p.Range) - - // This function is called by the generated parser code. Returning initiates error recovery // It must be called precisely "parse_error_rich" let parse_error_rich = Some (fun (ctxt: ParseErrorContext<_>) -> errorR(SyntaxError(box ctxt, ctxt.ParseState.LexBuffer.LexemeRange))) -let unionRangeWithPos (r:range) p = - let r2 = mkRange r.FileName p p - unionRanges r r2 - -/// Report a good error at the end of file, e.g. for non-terminated strings -let checkEndOfFileError t = - match t with - | LexCont.IfDefSkip(_, _, _, m) -> - reportParseErrorAt m (FSComp.SR.parsEofInHashIf()) - - | LexCont.String (_, _, LexerStringStyle.SingleQuote, kind, m) -> - if kind.IsInterpolated then - reportParseErrorAt m (FSComp.SR.parsEofInInterpolatedString()) - else - reportParseErrorAt m (FSComp.SR.parsEofInString()) - - | LexCont.String (_, _, LexerStringStyle.TripleQuote, kind, m) -> - if kind.IsInterpolated then - reportParseErrorAt m (FSComp.SR.parsEofInInterpolatedTripleQuoteString()) - else - reportParseErrorAt m (FSComp.SR.parsEofInTripleQuoteString()) - - | LexCont.String (_, _, LexerStringStyle.Verbatim, kind, m) -> - if kind.IsInterpolated then - reportParseErrorAt m (FSComp.SR.parsEofInInterpolatedVerbatimString()) - else - reportParseErrorAt m (FSComp.SR.parsEofInVerbatimString()) - - | LexCont.Comment (_, _, _, m) -> - reportParseErrorAt m (FSComp.SR.parsEofInComment()) - - | LexCont.SingleLineComment (_, _, _, m) -> - reportParseErrorAt m (FSComp.SR.parsEofInComment()) - - | LexCont.StringInComment (_, _, LexerStringStyle.SingleQuote, _, m) -> - reportParseErrorAt m (FSComp.SR.parsEofInStringInComment()) - - | LexCont.StringInComment (_, _, LexerStringStyle.Verbatim, _, m) -> - reportParseErrorAt m (FSComp.SR.parsEofInVerbatimStringInComment()) - - | LexCont.StringInComment (_, _, LexerStringStyle.TripleQuote, _, m) -> - reportParseErrorAt m (FSComp.SR.parsEofInTripleQuoteStringInComment()) - - | LexCont.MLOnly (_, _, m) -> - reportParseErrorAt m (FSComp.SR.parsEofInIfOcaml()) - - | LexCont.EndLine(_, _, LexerEndlineContinuation.Skip(_, m)) -> - reportParseErrorAt m (FSComp.SR.parsEofInDirective()) - - | LexCont.EndLine(endifs, nesting, LexerEndlineContinuation.Token) - | LexCont.Token(endifs, nesting) -> - match endifs with - | [] -> () - | (_, m) :: _ -> reportParseErrorAt m (FSComp.SR.parsNoHashEndIfFound()) - match nesting with - | [] -> () - | (_, _, m) :: _ -> reportParseErrorAt m (FSComp.SR.parsEofInInterpolatedStringFill()) - -type BindingSet = BindingSetPreAttrs of range * bool * bool * (SynAttributes -> SynAccess option -> SynAttributes * SynBinding list) * range - -let mkClassMemberLocalBindings(isStatic, initialRangeOpt, attrs, vis, BindingSetPreAttrs(_, isRec, isUse, declsPreAttrs, bindingSetRange)) = - let ignoredFreeAttrs, decls = declsPreAttrs attrs vis - let mWhole = - match initialRangeOpt with - | None -> bindingSetRange - | Some m -> unionRanges m bindingSetRange - // decls could have a leading attribute - |> fun m -> (m, decls) ||> unionRangeWithListBy (fun (SynBinding(range = m)) -> m) - if not (isNil ignoredFreeAttrs) then warning(Error(FSComp.SR.parsAttributesIgnored(), mWhole)); - if isUse then errorR(Error(FSComp.SR.parsUseBindingsIllegalInImplicitClassConstructors(), mWhole)) - SynMemberDefn.LetBindings (decls, isStatic, isRec, mWhole) - -let mkLocalBindings (mWhole, BindingSetPreAttrs(_, isRec, isUse, declsPreAttrs, _), mIn, body: SynExpr) = - let ignoredFreeAttrs, decls = declsPreAttrs [] None - let mWhole = - match decls with - | SynBinding(xmlDoc = xmlDoc) :: _ -> unionRangeWithXmlDoc xmlDoc mWhole - | _ -> mWhole - if not (isNil ignoredFreeAttrs) then warning(Error(FSComp.SR.parsAttributesIgnored(), mWhole)) - let mIn = - mIn - |> Option.bind (fun (mIn: range) -> - if Position.posEq mIn.Start body.Range.Start then - None - else - Some mIn) - - SynExpr.LetOrUse (isRec, isUse, decls, body, mWhole, { InKeyword = mIn }) - -let mkDefnBindings (mWhole, BindingSetPreAttrs(_, isRec, isUse, declsPreAttrs, _bindingSetRange), attrs, vis, attrsm) = - if isUse then warning(Error(FSComp.SR.parsUseBindingsIllegalInModules(), mWhole)) - let freeAttrs, decls = declsPreAttrs attrs vis - // decls might have an extended range due to leading attributes - let mWhole = (mWhole, decls) ||> unionRangeWithListBy (fun (SynBinding(range = m)) -> m) - let letDecls = [ SynModuleDecl.Let (isRec, decls, mWhole) ] - let attrDecls = if not (isNil freeAttrs) then [ SynModuleDecl.Attributes (freeAttrs, attrsm) ] else [] - attrDecls @ letDecls - -let idOfPat (parseState:IParseState) m p = - match p with - | SynPat.Wild r when parseState.LexBuffer.SupportsFeature LanguageFeature.WildCardInForLoop -> - mkSynId r "_" - | SynPat.Named (SynIdent(id,_), false, _, _) -> id - | SynPat.LongIdent(longDotId=SynLongIdent([id], _, _); typarDecls=None; argPats=SynArgPats.Pats []; accessibility=None) -> id - | _ -> raiseParseErrorAt m (FSComp.SR.parsIntegerForLoopRequiresSimpleIdentifier()) - -let checkForMultipleAugmentations m a1 a2 = - if not (isNil a1) && not (isNil a2) then raiseParseErrorAt m (FSComp.SR.parsOnlyOneWithAugmentationAllowed()) - a1 @ a2 - -let rangeOfLongIdent(lid:LongIdent) = - System.Diagnostics.Debug.Assert(not lid.IsEmpty, "the parser should never produce a long-id that is the empty list") - (lid.Head.idRange, lid) ||> unionRangeWithListBy (fun id -> id.idRange) - %} // Producing these changes the lex state, e.g. string --> token, or nesting level of braces in interpolated strings @@ -5272,15 +5111,99 @@ arrayTypeSuffix: | LBRACK RBRACK { 1 } - | LBRACK COMMA RBRACK + | LBRACK COMMA RBRACK { 2 } - | LBRACK COMMA COMMA RBRACK + | LBRACK COMMA COMMA RBRACK { 3 } - | LBRACK COMMA COMMA COMMA RBRACK + | LBRACK COMMA COMMA COMMA RBRACK { 4 } + | LBRACK COMMA COMMA COMMA COMMA RBRACK + { 5 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA RBRACK + { 6 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 7 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 8 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 9 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 10 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 11 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 12 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 13 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 14 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 15 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 16 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 17 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 18 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 19 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 20 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 21 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 22 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 23 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 24 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 25 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 26 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 27 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 28 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 29 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 30 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 31 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 32 } + appTypePrefixArguments: | typeArgActual COMMA typeArgActual typeArgListElements { let typeArgs, commas = $4 in $1 :: $3 :: List.rev typeArgs, (rhs parseState 2) :: (List.rev commas) } diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 5500c3d5d6d..86d3df0b0e6 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -212,6 +212,11 @@ Revize kompatibility ML + + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + + nameof nameof @@ -402,6 +407,11 @@ Neplatný interpolovaný řetězec. V interpolovaných výrazech se nedají použít řetězcové literály s trojitými uvozovkami. Zvažte možnost použít pro interpolovaný výraz explicitní vazbu let. + + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Tento konstruktor je zastaralý. {0}. Tuto funkci můžete povolit pomocí parametrů --langversion:5.0 a --mlcompatibility. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 6a4d9b3b664..e2906712877 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -212,6 +212,11 @@ ML-Kompatibilitätsrevisionen + + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + + nameof nameof @@ -402,6 +407,11 @@ Ungültige interpolierte Zeichenfolge. Zeichenfolgenliterale mit dreifachen Anführungszeichen dürfen in interpolierten Ausdrücken nicht verwendet werden. Erwägen Sie die Verwendung einer expliziten let-Bindung für den Interpolationsausdruck. + + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Dieses Konstrukt ist veraltet. {0}. Sie können dieses Feature mithilfe von „--langversion:5.0“ und „--mlcompatibility“ aktivieren. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 398d6adb3d1..b9eeef028f3 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -212,6 +212,11 @@ Revisiones de compatibilidad de ML + + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + + nameof nameof @@ -402,6 +407,11 @@ Cadena interpolada no válida. No se pueden usar literales de cadena de comillas triples en las expresiones interpoladas. Puede usar un enlace "let" explícito para la expresión de interpolación. + + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Esta construcción está en desuso. {0}. Puede habilitar esta característica usando '--langversion:5.0' y '--mlcompatibility'. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 5fcc22f65e3..516da922696 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -212,6 +212,11 @@ Réviseurs de compatibilité ML + + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + + nameof nameof @@ -402,6 +407,11 @@ Chaîne interpolée non valide. Les littéraux de chaîne à guillemets triples ne peuvent pas être utilisés dans des expressions interpolées. Utilisez une liaison 'let' explicite pour l'expression d'interpolation. + + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Cette construction est déconseillée. {0}. Vous pouvez activer cette fonctionnalité à l’aide de'--langversion : 5.0 'et'--mlcompatibility'. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 52e4d991d44..4c0f6b8045e 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -212,6 +212,11 @@ Revisioni della compatibilità di Ml + + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + + nameof nameof @@ -402,6 +407,11 @@ La stringa interpolata non è valida. Non è possibile usare valori letterali stringa tra virgolette triple in espressioni interpolate. Provare a usare un binding 'let' esplicito per l'espressione di interpolazione. + + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Questo costrutto è deprecato. {0}. È possibile abilitare questa funzionalità usando '--langversion:5.0' and '--mlcompatibility'. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 6581600dab9..a851b0056bd 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -212,6 +212,11 @@ ML 互換性のリビジョン + + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + + nameof nameof @@ -402,6 +407,11 @@ 補間された文字列が無効です。三重引用符文字列リテラルは、補間された式では使用できません。補間式に対して明示的な 'let' バインドを使用することをご検討ください。 + + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. このコンストラクトは使用されなくなりました。{0}。'--langversion:5.0' と '--mlcompatibility' を使用することで、この機能を有効にすることができます。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 5cd40d56b9b..f8aba1cd9df 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -212,6 +212,11 @@ ML 호환성 개정 + + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + + nameof nameof @@ -402,6 +407,11 @@ 잘못된 보간 문자열. 삼중 따옴표 문자열 리터럴은 보간 식에 사용할 수 없습니다. 보간 식에 명시적 'let' 바인딩을 사용해 보세요. + + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. 이 구성은 더 이상 사용되지 않습니다. {0}. '--langversion:5.0' 및 '--mlcompatibility'를 사용하여 이 기능을 활성화할 수 있습니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index c582e51fed2..7e0ac72e64a 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -212,6 +212,11 @@ Poprawki dotyczące zgodności Machine Learning + + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + + nameof nameof @@ -402,6 +407,11 @@ Nieprawidłowy ciąg interpolowany. Literały ciągów z potrójnymi cudzysłowami nie mogą być używane w wyrażeniach interpolowanych. Rozważ użycie jawnego powiązania „let” dla wyrażenia interpolacji. + + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Ta konstrukcja jest przestarzała. {0}. Tę funkcję można włączyć przy użyciu poleceń"--langversion:5.0" i "--mlcompatibility". diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 85159ea6ccb..a35a4526ff4 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -212,6 +212,11 @@ Revisões de compatibilidade de ML + + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + + nameof nameof @@ -402,6 +407,11 @@ Cadeia de caracteres interpolada inválida. Literais de cadeia de caracteres de aspas triplas não podem ser usados em expressões interpoladas. Considere usar uma associação 'let' explícita para a expressão de interpolação. + + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Esta construção foi preterida. {0} Você pode habilitar este recurso usando '--langversion:5.0' e '--mlcompatibility'. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 115749aaeb4..e9cc08fa9cd 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -212,6 +212,11 @@ Редакции совместимости ML + + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + + nameof nameof @@ -402,6 +407,11 @@ Недопустимая интерполированная строка. Строковые литералы с тройными кавычками запрещено использовать в интерполированных выражениях. Рекомендуется использовать явную привязку "let" для выражения интерполяции. + + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Эта конструкция не рекомендуется к использованию. {0}. Вы можете включить эту функцию с помощью команд "--langversion:5.0" и "--mlcompatibility". diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 1bcc4c713a3..bb289ebc867 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -212,6 +212,11 @@ ML uyumluluk düzeltmeleri + + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + + nameof nameof @@ -402,6 +407,11 @@ Geçersiz düz metin arasına kod eklenmiş dize. Üç tırnaklı dize sabitleri, düz metin arasına kod eklenmiş ifadelerde kullanılamaz. Düz metin arasına kod ekleme ifadesi için açık bir 'let' bağlaması kullanmayı düşünün. + + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. Bu yapı kullanım dışı. {0}. Bu özelliği '--langversion:5.0' ve '--mlcompatibility' kullanarak etkinleştirebilirsiniz. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 898b9d527be..6098fcbaf0c 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -212,6 +212,11 @@ ML 兼容性修订 + + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + + nameof nameof @@ -402,6 +407,11 @@ 内插字符串无效。在内插表达式中不能使用三重引号字符串文字。请考虑对内插表达式使用显式的 "let" 绑定。 + + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. 此构造已弃用。{0}。可以通过使用 “--langversion:5.0” 和 “--mlcompatibility” 启用此功能。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 9cd17ae1a98..7e9a9048b4b 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -212,6 +212,11 @@ ML 相容性修訂 + + Pattern match discard is not allowed for union case that takes no data. + Pattern match discard is not allowed for union case that takes no data. + + nameof nameof @@ -402,6 +407,11 @@ 插補字串無效。三引號字串常值不可用於插補運算式。請考慮為內插補點運算式使用明確的 'let' 繫結。 + + Pattern discard is not allowed for union case that takes no data. + Pattern discard is not allowed for union case that takes no data. + + This construct is deprecated. {0}. You can enable this feature by using '--langversion:5.0' and '--mlcompatibility'. 此建構已被取代。{0}。您可以使用 '--langversion:5.0' and '--mlcompatibility' 來啟用此功能。 diff --git a/src/FSharp.Core/local.fsi b/src/FSharp.Core/local.fsi index e4d26e76e2b..2af9465beaf 100644 --- a/src/FSharp.Core/local.fsi +++ b/src/FSharp.Core/local.fsi @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. namespace Microsoft.FSharp.Core + open Microsoft.FSharp.Core [] diff --git a/src/FSharp.Core/quotations.fs b/src/FSharp.Core/quotations.fs index 44c625de5f5..c3c7317e522 100644 --- a/src/FSharp.Core/quotations.fs +++ b/src/FSharp.Core/quotations.fs @@ -942,14 +942,8 @@ module Patterns = | VarSetOp, _ | AddressSetOp, _ -> typeof | AddressOfOp, [ expr ] -> (typeOf expr).MakeByRefType() - | (AddressOfOp - | QuoteOp _ - | SequentialOp - | TryWithOp - | TryFinallyOp - | IfThenElseOp - | AppOp), - _ -> failwith "unreachable" + | (AddressOfOp | QuoteOp _ | SequentialOp | TryWithOp | TryFinallyOp | IfThenElseOp | AppOp), _ -> + failwith "unreachable" //-------------------------------------------------------------------------- // Constructors for building Raw quotations @@ -2933,8 +2927,7 @@ module DerivedPatterns = let (|SpecificCall|_|) templateParameter = // Note: precomputation match templateParameter with - | (Lambdas (_, Call (_, minfo1, _)) - | Call (_, minfo1, _)) -> + | (Lambdas (_, Call (_, minfo1, _)) | Call (_, minfo1, _)) -> let isg1 = minfo1.IsGenericMethod let gmd = diff --git a/src/FSharp.Core/seqcore.fsi b/src/FSharp.Core/seqcore.fsi index 03496378232..701a92fc705 100644 --- a/src/FSharp.Core/seqcore.fsi +++ b/src/FSharp.Core/seqcore.fsi @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. namespace Microsoft.FSharp.Collections + open System open System.Collections open System.Collections.Generic diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs index b64dff5176c..63973ea991a 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/UnionCasePatternMatchingErrors.fs @@ -69,4 +69,247 @@ let myVal = |> typecheck |> shouldFail |> withSingleDiagnostic (Error 727, Line 10, Col 7, Line 10, Col 15, "This union case expects 3 arguments in tupled form, but was given 2. The missing field arguments may be any of: -\tint") \ No newline at end of file +\tint") + +[] +let ``Union Pattern discard not allowed for union case that takes no data with Lang preview`` () = + FSharp """ +module Tests +type X = X + +let x: X = X + +let myVal = + match x with + | X _ -> ()""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 3548, Line 9, Col 7, Line 9, Col 10, "Pattern discard is not allowed for union case that takes no data.") + + +[] +let ``Union Pattern discard allowed for union case that takes no data with Lang version 7`` () = + FSharp """ +module Tests +type X = X + +let x: X = X + +let myVal = + match x with + | X _ -> ()""" + |> withLangVersion70 + |> typecheck + |> shouldSucceed + +[] +let ``Union function Pattern discard allowed for union case that takes no data with Lang version 7`` () = + FSharp """ +module Tests +type X = X + +let x: X = X + +let myVal = + function + | X _ -> ()""" + |> withLangVersion70 + |> typecheck + |> shouldSucceed + +[] +let ``Union function Pattern discard not allowed for union case that takes no data with Lang version preview`` () = + FSharp """ +module Tests +type X = X + +let x: X = X + +let myVal = + function + | X _ -> ()""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 3548, Line 9, Col 7, Line 9, Col 10, "Pattern discard is not allowed for union case that takes no data.") + +[] +let ``Pattern discard not allowed for union case that takes no data with Lang preview`` () = + FSharp """ +module Tests +type U = + | A + | B of int * int * int + | C of int * int * int + +let a : U = A + +let myVal = + match a with + | A _ -> 15 + | B (x, _, _) -> 16 + | C _ -> 17""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard is not allowed for union case that takes no data.") + +[] +let ``Pattern function discard not allowed for union case that takes no data with Lang preview`` () = + FSharp """ +module Tests +type U = + | A + | B of int * int * int + | C of int * int * int + +let a : U = A + +let myVal = + function + | A _ -> 15 + | B (x, _, _) -> 16 + | C _ -> 17""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard is not allowed for union case that takes no data.") + +[] +let ``Pattern discard allowed for union case that takes no data with Lang version 7`` () = + FSharp """ +module Tests +type U = + | A + | B of int * int * int + | C of int * int * int + +let a : U = A + +let myVal = + match a with + | A _ -> 15 + | B (x, _, _) -> 16 + | C _ -> 17""" + |> withLangVersion70 + |> typecheck + |> shouldSucceed + +[] +let ``Grouped Pattern discard not allowed for union case that takes no data with Lang preview`` () = + FSharp """ +module Tests +type U = + | A + | B of int * int * int + | C of int * int * int + +let a : U = A + +let myVal = + match a with + | A _ + | B _ + | C _ -> 17""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 3548, Line 12, Col 7, Line 12, Col 10, "Pattern discard is not allowed for union case that takes no data.") + +[] +let ``Multiple pattern discards not allowed for union case that takes no data with Lang preview`` () = + FSharp """ +module Tests +type U = + | A + | B of int * int * int + | C of int * int * int + +type V = + | D + +let a : U = A +let d : V = D + +let myVal = + match a, d with + | A _, D -> 15 + | B (x, _, _), D _ -> 16 + | C _, _ -> 17""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 3548, Line 16, Col 7, Line 16, Col 10, "Pattern discard is not allowed for union case that takes no data.") + (Warning 3548, Line 17, Col 20, Line 17, Col 23, "Pattern discard is not allowed for union case that takes no data.") + ] + +[] +let ``Multiple function pattern discards is not allowed for union case that takes no data with Lang preview`` () = + FSharp """ +module Tests +type U = + | A + | B of int * int * int + | C of int * int * int + +type V = + | D + +let a : U = A +let d : V = D + +let myVal = + function + | A _, D -> 15 + | B (x, _, _), D _ -> 16 + | C _, _ -> 17""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 3548, Line 16, Col 7, Line 16, Col 10, "Pattern discard is not allowed for union case that takes no data.") + (Warning 3548, Line 17, Col 20, Line 17, Col 23, "Pattern discard is not allowed for union case that takes no data.") + ] + +[] +let ``Pattern discard allowed for single-case unions when using them as a deconstruct syntax in functions with Lang 7`` () = + FSharp """ +module Tests +type MyWrapper = A + +let myDiscardedArgFunc(A _) = 5+5""" + |> withLangVersion70 + |> typecheck + |> shouldSucceed + +[] +let ``Pattern named not allowed for single-case unions when using them as a deconstruct syntax in functions with Lang 7`` () = + FSharp """ +module Tests +type MyWrapper = A + +let myFunc(A a) = 5+5""" + |> withLangVersion70 + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 725, Line 5, Col 12, Line 5, Col 15, "This union case does not take arguments") + ] + +[] +let ``Pattern discard or named are not allowed for single-case union case that takes no data with Lang preview`` () = + FSharp """ +module Tests +type MyWrapper = A + +let myFunc(A a) = 5+5 +let myDiscardedArgFunc(A _) = 5+5""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 3548, Line 5, Col 12, Line 5, Col 15, "Pattern discard is not allowed for union case that takes no data.") + (Warning 3548, Line 6, Col 24, Line 6, Col 27, "Pattern discard is not allowed for union case that takes no data.") + ] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 0b5e005d7b7..75e0f8a0323 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -161,6 +161,7 @@ + diff --git a/tests/FSharp.Compiler.ComponentTests/Language/MultiDimensionalArrayTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/MultiDimensionalArrayTests.fs new file mode 100644 index 00000000000..7a107e1e910 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Language/MultiDimensionalArrayTests.fs @@ -0,0 +1,52 @@ +namespace FSharp.Compiler.ComponentTests.Language + +open Xunit +open FSharp.Test.Compiler + +module MultiDimensionalArrayTests = + + [] + [] + [] + [] + let ``MultiDimensional array type can be written with or without backticks`` (commas: int, shortcut: string) = + let commaString = System.String(',', commas) + + FSharp + $""" +module MultiDimArrayTests +let backTickStyle : int ``[{commaString}]`` = Unchecked.defaultof<_> +let cleanStyle : int [{commaString}] = backTickStyle +let shortCutStyle : int {shortcut} = cleanStyle + """ + |> compile + |> shouldSucceed + + [] + let ``Multidimensional array - reports an error if types are not matching`` () = + let commaString = System.String(',', 30) + + FSharp + $""" +module MultiDimArrayErrorTests +let cleanStyle : int [{commaString}] = Unchecked.defaultof<_> +let shortCutStyle : int array32d = cleanStyle + """ + |> compile + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 4, Col 36, Line 4, Col 46, "This expression was expected to have type + 'int array32d' +but here has type + 'int array31d' ") + + [] + let ``Multidimensional with rank over 32 cannot be defined`` () = + let commaString = System.String(',', 42) + + FSharp + $""" +module MultiDimArrayErrorTests +let cleanStyle : int [{commaString}] = Unchecked.defaultof<_> + """ + |> compile + |> shouldFail diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 202bd49532e..c5b206ed9e6 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -119,6 +119,9 @@ SyntaxTree\SynIdentTests.fs + + SyntaxTree\SynTypeTests.fs + SyntaxTree\AttributeTests.fs diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index 1679a74a336..c526d83da7e 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -691,7 +691,7 @@ Updated automatically, please check diffs in your pull request, changes must be Assert.IsEmpty(parseResults.Diagnostics, sprintf "Parse errors: %A" parseResults.Diagnostics) match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted") + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted") | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> Assert.IsEmpty(typeCheckResults.Diagnostics, sprintf "Type Check errors: %A" typeCheckResults.Diagnostics) @@ -704,7 +704,7 @@ Updated automatically, please check diffs in your pull request, changes must be Assert.IsEmpty(parseResults.Diagnostics, sprintf "Parse errors: %A" parseResults.Diagnostics) match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted") + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted") | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> Assert.IsEmpty(typeCheckResults.Diagnostics, sprintf "Type Check errors: %A" typeCheckResults.Diagnostics) @@ -722,7 +722,7 @@ Updated automatically, please check diffs in your pull request, changes must be Assert.IsEmpty(parseResults.Diagnostics, sprintf "Parse errors: %A" parseResults.Diagnostics) match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted") + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted") | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> let errorsExpectedBaseLine = @@ -754,7 +754,7 @@ Updated automatically, please check diffs in your pull request, changes must be else match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted"); [| |] + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted"); [| |] | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> typeCheckResults.Diagnostics errors @@ -774,7 +774,7 @@ Updated automatically, please check diffs in your pull request, changes must be else match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted"); [| |] + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted"); [| |] | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> typeCheckResults.Diagnostics errors @@ -790,7 +790,7 @@ Updated automatically, please check diffs in your pull request, changes must be |> Async.RunImmediate match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted"); failwith "Type Checker Aborted" + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted"); failwith "Type Checker Aborted" | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> parseResults, typeCheckResults /// Parses and type checks the given source. Fails if the type checker is aborted or the parser returns any diagnostics. @@ -816,7 +816,7 @@ Updated automatically, please check diffs in your pull request, changes must be else match fileAnswer with - | FSharpCheckFileAnswer.Aborted _ -> Assert.Fail("Type Checker Aborted"); [| |] + | FSharpCheckFileAnswer.Aborted -> Assert.Fail("Type Checker Aborted"); [| |] | FSharpCheckFileAnswer.Succeeded(typeCheckResults) -> typeCheckResults.Diagnostics assertErrors libAdjust false errors expectedTypeErrors diff --git a/tests/service/Symbols.fs b/tests/service/Symbols.fs index d9cb28398b9..c5d8c5f53ba 100644 --- a/tests/service/Symbols.fs +++ b/tests/service/Symbols.fs @@ -361,3 +361,15 @@ let tester2: int Group = [] |> should equal expectedTypeFormat | _ -> Assert.Fail (sprintf "Couldn't get member: %s" entityName) ) + + [] + let ``FsharpType.Format default to arrayNd shorthands for multidimensional arrays`` ([]rank) = + let commas = System.String(',', rank - 1) + let _, checkResults = getParseAndCheckResults $""" let myArr : int[{commas}] = Unchecked.defaultOf<_>""" + let symbolUse = findSymbolUseByName "myArr" checkResults + match symbolUse.Symbol with + | :? FSharpMemberOrFunctionOrValue as v -> + v.FullType.Format symbolUse.DisplayContext + |> shouldEqual $"int array{rank}d" + + | other -> Assert.Fail(sprintf "myArr was supposed to be a value, but is %A" other) diff --git a/tests/service/SyntaxTreeTests/SynTypeTests.fs b/tests/service/SyntaxTreeTests/SynTypeTests.fs new file mode 100644 index 00000000000..1ab5ed12e94 --- /dev/null +++ b/tests/service/SyntaxTreeTests/SynTypeTests.fs @@ -0,0 +1,51 @@ +module FSharp.Compiler.Service.Tests.SyntaxTreeTests.SynTypeTests + +open FSharp.Compiler.Service.Tests.Common +open FSharp.Compiler.Syntax +open NUnit.Framework + +[] +let ``SynType.Tuple does include leading parameter name`` () = + let parseResults = + getParseResultsOfSignatureFile + """ +type T = + member M: p1: a * p2: b -> int + """ + + match parseResults with + | ParsedInput.SigFile(ParsedSigFileInput(contents = [ + SynModuleOrNamespaceSig(decls = [ + SynModuleSigDecl.Types(types = [ + SynTypeDefnSig(typeRepr = SynTypeDefnSigRepr.ObjectModel(memberSigs = [ + SynMemberSig.Member(memberSig = SynValSig(synType = + SynType.Fun(argType = SynType.Tuple(_, _, mTuple)))) + ])) + ]) + ]) + ])) -> + assertRange (3, 14) (3, 27) mTuple + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``SynType.Tuple does include leading parameter attributes`` () = + let parseResults = + getParseResultsOfSignatureFile + """ +type T = + member M: [] a * [] b -> int + """ + + match parseResults with + | ParsedInput.SigFile(ParsedSigFileInput(contents = [ + SynModuleOrNamespaceSig(decls = [ + SynModuleSigDecl.Types(types = [ + SynTypeDefnSig(typeRepr = SynTypeDefnSigRepr.ObjectModel(memberSigs = [ + SynMemberSig.Member(memberSig = SynValSig(synType = + SynType.Fun(argType = SynType.Tuple(_, _, mTuple)))) + ])) + ]) + ]) + ])) -> + assertRange (3, 14) (3, 56) mTuple + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" diff --git a/tests/service/data/TestTP/ProvidedTypes.fs b/tests/service/data/TestTP/ProvidedTypes.fs index e12c6f843d3..c13961cbc27 100644 --- a/tests/service/data/TestTP/ProvidedTypes.fs +++ b/tests/service/data/TestTP/ProvidedTypes.fs @@ -629,8 +629,8 @@ type ProvidedTypeSymbol(kind: ProvidedTypeSymbolKind, typeArgs: Type list, typeB override __.GetArrayRank() = (match kind with ProvidedTypeSymbolKind.Array n -> n | ProvidedTypeSymbolKind.SDArray -> 1 | _ -> failwithf "non-array type '%O'" this) override __.IsValueTypeImpl() = (match kind with ProvidedTypeSymbolKind.Generic gtd -> gtd.IsValueType | _ -> false) override __.IsArrayImpl() = (match kind with ProvidedTypeSymbolKind.Array _ | ProvidedTypeSymbolKind.SDArray -> true | _ -> false) - override __.IsByRefImpl() = (match kind with ProvidedTypeSymbolKind.ByRef _ -> true | _ -> false) - override __.IsPointerImpl() = (match kind with ProvidedTypeSymbolKind.Pointer _ -> true | _ -> false) + override __.IsByRefImpl() = (match kind with ProvidedTypeSymbolKind.ByRef -> true | _ -> false) + override __.IsPointerImpl() = (match kind with ProvidedTypeSymbolKind.Pointer -> true | _ -> false) override __.IsPrimitiveImpl() = false override __.IsGenericType = (match kind with ProvidedTypeSymbolKind.Generic _ -> true | _ -> false) override this.GetGenericArguments() = (match kind with ProvidedTypeSymbolKind.Generic _ -> typeArgs | _ -> failwithf "non-generic type '%O'" this) @@ -7335,8 +7335,8 @@ namespace ProviderImplementation.ProvidedTypes override __.GetArrayRank() = (match kind with TypeSymbolKind.Array n -> n | TypeSymbolKind.SDArray -> 1 | _ -> failwithf "non-array type") override __.IsValueTypeImpl() = this.IsGenericType && this.GetGenericTypeDefinition().IsValueType override __.IsArrayImpl() = (match kind with TypeSymbolKind.Array _ | TypeSymbolKind.SDArray -> true | _ -> false) - override __.IsByRefImpl() = (match kind with TypeSymbolKind.ByRef _ -> true | _ -> false) - override __.IsPointerImpl() = (match kind with TypeSymbolKind.Pointer _ -> true | _ -> false) + override __.IsByRefImpl() = (match kind with TypeSymbolKind.ByRef -> true | _ -> false) + override __.IsPointerImpl() = (match kind with TypeSymbolKind.Pointer -> true | _ -> false) override __.IsPrimitiveImpl() = false override __.IsGenericType = (match kind with TypeSymbolKind.TargetGeneric _ | TypeSymbolKind.OtherGeneric _ -> true | _ -> false) override __.GetGenericArguments() = (match kind with TypeSymbolKind.TargetGeneric _ | TypeSymbolKind.OtherGeneric _ -> typeArgs | _ -> [| |]) diff --git a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/ProvidedTypes.fs b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/ProvidedTypes.fs index ee27b6103ba..4a7bc2764f1 100644 --- a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/ProvidedTypes.fs +++ b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/ProvidedTypes.fs @@ -546,8 +546,8 @@ namespace ProviderImplementation.ProvidedTypes override _.GetArrayRank() = (match kind with ProvidedTypeSymbolKind.Array n -> n | ProvidedTypeSymbolKind.SDArray -> 1 | _ -> failwithf "non-array type '%O'" this) override _.IsValueTypeImpl() = (match kind with ProvidedTypeSymbolKind.Generic gtd -> gtd.IsValueType | _ -> false) override _.IsArrayImpl() = (match kind with ProvidedTypeSymbolKind.Array _ | ProvidedTypeSymbolKind.SDArray -> true | _ -> false) - override _.IsByRefImpl() = (match kind with ProvidedTypeSymbolKind.ByRef _ -> true | _ -> false) - override _.IsPointerImpl() = (match kind with ProvidedTypeSymbolKind.Pointer _ -> true | _ -> false) + override _.IsByRefImpl() = (match kind with ProvidedTypeSymbolKind.ByRef -> true | _ -> false) + override _.IsPointerImpl() = (match kind with ProvidedTypeSymbolKind.Pointer -> true | _ -> false) override _.IsPrimitiveImpl() = false override _.IsGenericType = (match kind with ProvidedTypeSymbolKind.Generic _ -> true | _ -> false) override this.GetGenericArguments() = (match kind with ProvidedTypeSymbolKind.Generic _ -> typeArgs | _ -> failwithf "non-generic type '%O'" this) @@ -6993,8 +6993,8 @@ namespace ProviderImplementation.ProvidedTypes override _.GetArrayRank() = (match kind with TypeSymbolKind.Array n -> n | TypeSymbolKind.SDArray -> 1 | _ -> failwithf "non-array type") override _.IsValueTypeImpl() = this.IsGenericType && this.GetGenericTypeDefinition().IsValueType override _.IsArrayImpl() = (match kind with TypeSymbolKind.Array _ | TypeSymbolKind.SDArray -> true | _ -> false) - override _.IsByRefImpl() = (match kind with TypeSymbolKind.ByRef _ -> true | _ -> false) - override _.IsPointerImpl() = (match kind with TypeSymbolKind.Pointer _ -> true | _ -> false) + override _.IsByRefImpl() = (match kind with TypeSymbolKind.ByRef -> true | _ -> false) + override _.IsPointerImpl() = (match kind with TypeSymbolKind.Pointer -> true | _ -> false) override _.IsPrimitiveImpl() = false override _.IsGenericType = (match kind with TypeSymbolKind.TargetGeneric _ | TypeSymbolKind.OtherGeneric _ -> true | _ -> false) override _.GetGenericArguments() = (match kind with TypeSymbolKind.TargetGeneric _ | TypeSymbolKind.OtherGeneric _ -> typeArgs | _ -> [| |])