From 40d3e691a0728ce0afd4487210744f2cc9f4a029 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Mon, 4 Aug 2025 15:41:21 +0800 Subject: [PATCH 01/22] move TcOpen to CheckExpressions --- src/Compiler/Checking/CheckBasics.fs | 91 +++++++++++++++ src/Compiler/Checking/CheckBasics.fsi | 9 ++ src/Compiler/Checking/CheckDeclarations.fs | 105 ------------------ src/Compiler/Checking/CheckDeclarations.fsi | 3 - .../Checking/Expressions/CheckExpressions.fs | 34 ++++++ .../Checking/Expressions/CheckExpressions.fsi | 8 ++ 6 files changed, 142 insertions(+), 108 deletions(-) diff --git a/src/Compiler/Checking/CheckBasics.fs b/src/Compiler/Checking/CheckBasics.fs index 7cbca970cc3..302a366e72e 100644 --- a/src/Compiler/Checking/CheckBasics.fs +++ b/src/Compiler/Checking/CheckBasics.fs @@ -379,3 +379,94 @@ type TcFileState = } override _.ToString() = "" + +open FSharp.Compiler.AttributeChecking +open FSharp.Compiler.Features +open FSharp.Compiler.Syntax.PrettyNaming +open FSharp.Compiler.Text.Range +open FSharp.Compiler.TypedTreeBasics + +let CheckNamespaceModuleOrTypeName (g: TcGlobals) (id: Ident) = + // type names '[]' etc. are used in fslib + if not g.compilingFSharpCore && id.idText.IndexOfAny IllegalCharactersInTypeAndNamespaceNames <> -1 then + errorR(Error(FSComp.SR.tcInvalidNamespaceModuleTypeUnionName(), id.idRange)) + +/// Adjust the TcEnv to account for opening the set of modules or namespaces implied by an `open` declaration +let OpenModuleOrNamespaceRefs tcSink g amap scopem root env mvvs openDeclaration = + let env = + if isNil mvvs then env else + { env with eNameResEnv = AddModuleOrNamespaceRefsContentsToNameEnv g amap env.eAccessRights scopem root env.eNameResEnv mvvs } + CallEnvSink tcSink (scopem, env.NameEnv, env.eAccessRights) + CallOpenDeclarationSink tcSink openDeclaration + env + +//------------------------------------------------------------------------- +// Bind 'open' declarations +//------------------------------------------------------------------------- + +let TcOpenLidAndPermitAutoResolve tcSink (env: TcEnv) amap (longId : Ident list) = + let ad = env.AccessRights + match longId with + | [] -> [] + | id :: rest -> + let m = longId |> List.map (fun id -> id.idRange) |> List.reduce unionRanges + match ResolveLongIdentAsModuleOrNamespace tcSink amap m true OpenQualified env.NameEnv ad id rest true ShouldNotifySink.Yes with + | Result res -> res + | Exception err -> + errorR(err); [] + +let TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) = + match TcOpenLidAndPermitAutoResolve tcSink env amap longId with + | [] -> env, [] + | modrefs -> + + // validate opened namespace names + for id in longId do + if id.idText <> MangledGlobalName then + CheckNamespaceModuleOrTypeName g id + + let IsPartiallyQualifiedNamespace (modref: ModuleOrNamespaceRef) = + let (CompPath(_, _, p)) = modref.CompilationPath + // Bug FSharp 1.0 3274: FSI paths don't count when determining this warning + let p = + match p with + | [] -> [] + | (h, _) :: t -> if h.StartsWithOrdinal FsiDynamicModulePrefix then t else p + + // See https://fslang.uservoice.com/forums/245727-f-language/suggestions/6107641-make-microsoft-prefix-optional-when-using-core-f + let isFSharpCoreSpecialCase = + match ccuOfTyconRef modref with + | None -> false + | Some ccu -> + ccuEq ccu g.fslibCcu && + // Check if we're using a reference one string shorter than what we expect. + // + // "p" is the fully qualified path _containing_ the thing we're opening, e.g. "Microsoft.FSharp" when opening "Microsoft.FSharp.Data" + // "longId" is the text being used, e.g. "FSharp.Data" + // Length of thing being opened = p.Length + 1 + // Length of reference = longId.Length + // So the reference is a "shortened" reference if (p.Length + 1) - 1 = longId.Length + (p.Length + 1) - 1 = longId.Length && + fst p[0] = "Microsoft" + + modref.IsNamespace && + p.Length >= longId.Length && + not isFSharpCoreSpecialCase + // Allow "open Foo" for "Microsoft.Foo" from FSharp.Core + + modrefs |> List.iter (fun (_, modref, _) -> + if modref.IsModule && HasFSharpAttribute g g.attrib_RequireQualifiedAccessAttribute modref.Attribs then + errorR(Error(FSComp.SR.tcModuleRequiresQualifiedAccess(fullDisplayTextOfModRef modref), m))) + + // Bug FSharp 1.0 3133: 'open Lexing'. Skip this warning if we successfully resolved to at least a module name + if not (modrefs |> List.exists (fun (_, modref, _) -> modref.IsModule && not (HasFSharpAttribute g g.attrib_RequireQualifiedAccessAttribute modref.Attribs))) then + modrefs |> List.iter (fun (_, modref, _) -> + if IsPartiallyQualifiedNamespace modref then + errorR(Error(FSComp.SR.tcOpenUsedWithPartiallyQualifiedPath(fullDisplayTextOfModRef modref), m))) + + let modrefs = List.map p23 modrefs + modrefs |> List.iter (fun modref -> CheckEntityAttributes g modref m |> CommitOperationResult) + + let openDecl = OpenDeclaration.Create (SynOpenDeclTarget.ModuleOrNamespace (SynLongIdent(longId, [], []), m), modrefs, [], scopem, false) + let env = OpenModuleOrNamespaceRefs tcSink g amap scopem false env modrefs openDecl + env, [openDecl] diff --git a/src/Compiler/Checking/CheckBasics.fsi b/src/Compiler/Checking/CheckBasics.fsi index 179752c394c..8d26dfd18dd 100644 --- a/src/Compiler/Checking/CheckBasics.fsi +++ b/src/Compiler/Checking/CheckBasics.fsi @@ -358,3 +358,12 @@ type TcFileState = -> range * Expr * TType * SynExpr -> Expr * UnscopedTyparEnv) -> TcFileState + +val TcOpenModuleOrNamespaceDecl: + tcSink: TcResultsSink -> + g: TcGlobals -> + amap: Import.ImportMap -> + scopem: range -> + env: TcEnv -> + longId: LongIdent * m: range -> + TcEnv * OpenDeclaration list diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 07b40b6b119..8376af11e3d 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -294,14 +294,6 @@ let OpenModuleOrNamespaceRefs tcSink g amap scopem root env mvvs openDeclaration CallOpenDeclarationSink tcSink openDeclaration env -/// Adjust the TcEnv to account for opening a type implied by an `open type` declaration -let OpenTypeContent tcSink g amap scopem env (ty: TType) openDeclaration = - let env = - { env with eNameResEnv = AddTypeContentsToNameEnv g amap env.eAccessRights scopem env.eNameResEnv ty } - CallEnvSink tcSink (scopem, env.NameEnv, env.eAccessRights) - CallOpenDeclarationSink tcSink openDeclaration - env - /// Adjust the TcEnv to account for a new root Ccu being available, e.g. a referenced assembly let AddRootModuleOrNamespaceRefs g amap m env modrefs = if isNil modrefs then env else @@ -677,103 +669,6 @@ let TcTyconMemberSpecs cenv env containerInfo declKind tpenv augSpfn = let members, tpenv = List.mapFold (TcAndPublishMemberSpec cenv env containerInfo declKind) tpenv augSpfn List.concat members, tpenv -//------------------------------------------------------------------------- -// Bind 'open' declarations -//------------------------------------------------------------------------- - -let TcOpenLidAndPermitAutoResolve tcSink (env: TcEnv) amap (longId : Ident list) = - let ad = env.AccessRights - match longId with - | [] -> [] - | id :: rest -> - let m = longId |> List.map (fun id -> id.idRange) |> List.reduce unionRanges - match ResolveLongIdentAsModuleOrNamespace tcSink amap m true OpenQualified env.NameEnv ad id rest true ShouldNotifySink.Yes with - | Result res -> res - | Exception err -> - errorR(err); [] - -let TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) = - match TcOpenLidAndPermitAutoResolve tcSink env amap longId with - | [] -> env, [] - | modrefs -> - - // validate opened namespace names - for id in longId do - if id.idText <> MangledGlobalName then - CheckNamespaceModuleOrTypeName g id - - let IsPartiallyQualifiedNamespace (modref: ModuleOrNamespaceRef) = - let (CompPath(_, _, p)) = modref.CompilationPath - // Bug FSharp 1.0 3274: FSI paths don't count when determining this warning - let p = - match p with - | [] -> [] - | (h, _) :: t -> if h.StartsWithOrdinal FsiDynamicModulePrefix then t else p - - // See https://fslang.uservoice.com/forums/245727-f-language/suggestions/6107641-make-microsoft-prefix-optional-when-using-core-f - let isFSharpCoreSpecialCase = - match ccuOfTyconRef modref with - | None -> false - | Some ccu -> - ccuEq ccu g.fslibCcu && - // Check if we're using a reference one string shorter than what we expect. - // - // "p" is the fully qualified path _containing_ the thing we're opening, e.g. "Microsoft.FSharp" when opening "Microsoft.FSharp.Data" - // "longId" is the text being used, e.g. "FSharp.Data" - // Length of thing being opened = p.Length + 1 - // Length of reference = longId.Length - // So the reference is a "shortened" reference if (p.Length + 1) - 1 = longId.Length - (p.Length + 1) - 1 = longId.Length && - fst p[0] = "Microsoft" - - modref.IsNamespace && - p.Length >= longId.Length && - not isFSharpCoreSpecialCase - // Allow "open Foo" for "Microsoft.Foo" from FSharp.Core - - modrefs |> List.iter (fun (_, modref, _) -> - if modref.IsModule && HasFSharpAttribute g g.attrib_RequireQualifiedAccessAttribute modref.Attribs then - errorR(Error(FSComp.SR.tcModuleRequiresQualifiedAccess(fullDisplayTextOfModRef modref), m))) - - // Bug FSharp 1.0 3133: 'open Lexing'. Skip this warning if we successfully resolved to at least a module name - if not (modrefs |> List.exists (fun (_, modref, _) -> modref.IsModule && not (HasFSharpAttribute g g.attrib_RequireQualifiedAccessAttribute modref.Attribs))) then - modrefs |> List.iter (fun (_, modref, _) -> - if IsPartiallyQualifiedNamespace modref then - errorR(Error(FSComp.SR.tcOpenUsedWithPartiallyQualifiedPath(fullDisplayTextOfModRef modref), m))) - - let modrefs = List.map p23 modrefs - modrefs |> List.iter (fun modref -> CheckEntityAttributes g modref m |> CommitOperationResult) - - let openDecl = OpenDeclaration.Create (SynOpenDeclTarget.ModuleOrNamespace (SynLongIdent(longId, [], []), m), modrefs, [], scopem, false) - let env = OpenModuleOrNamespaceRefs tcSink g amap scopem false env modrefs openDecl - env, [openDecl] - -let TcOpenTypeDecl (cenv: cenv) mOpenDecl scopem env (synType: SynType, m) = - let g = cenv.g - - checkLanguageFeatureError g.langVersion LanguageFeature.OpenTypeDeclaration mOpenDecl - - let ty, _tpenv = TcType cenv NoNewTypars CheckCxs ItemOccurrence.Open WarnOnIWSAM.Yes env emptyUnscopedTyparEnv synType - - if not (isAppTy g ty) then - errorR(Error(FSComp.SR.tcNamedTypeRequired("open type"), m)) - - if isByrefTy g ty then - errorR(Error(FSComp.SR.tcIllegalByrefsInOpenTypeDeclaration(), m)) - - let openDecl = OpenDeclaration.Create (SynOpenDeclTarget.Type (synType, m), [], [ty], scopem, false) - let env = OpenTypeContent cenv.tcSink g cenv.amap scopem env ty openDecl - env, [openDecl] - -let TcOpenDecl (cenv: cenv) mOpenDecl scopem env target = - let g = cenv.g - match target with - | SynOpenDeclTarget.ModuleOrNamespace (longId, m) -> - TcOpenModuleOrNamespaceDecl cenv.tcSink g cenv.amap scopem env (longId.LongIdent, m) - - | SynOpenDeclTarget.Type (synType, m) -> - TcOpenTypeDecl cenv mOpenDecl scopem env (synType, m) - let MakeSafeInitField (cenv: cenv) env m isStatic = let id = // Ensure that we have an g.CompilerGlobalState diff --git a/src/Compiler/Checking/CheckDeclarations.fsi b/src/Compiler/Checking/CheckDeclarations.fsi index 9b06fcc828d..fe42a443a89 100644 --- a/src/Compiler/Checking/CheckDeclarations.fsi +++ b/src/Compiler/Checking/CheckDeclarations.fsi @@ -41,9 +41,6 @@ val EmptyTopAttrs: TopAttribs val CombineTopAttrs: TopAttribs -> TopAttribs -> TopAttribs -val TcOpenModuleOrNamespaceDecl: - TcResultsSink -> TcGlobals -> ImportMap -> range -> TcEnv -> LongIdent * range -> TcEnv * OpenDeclaration list - val AddLocalSubModule: g: TcGlobals -> amap: ImportMap -> m: range -> env: TcEnv -> moduleEntity: ModuleOrNamespace -> TcEnv diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 5862b907e05..590136c12ab 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -4052,6 +4052,14 @@ type ImplicitlyBoundTyparsAllowed = | NewTyparsOK | NoNewTypars +/// Adjust the TcEnv to account for opening a type implied by an `open type` declaration +let OpenTypeContent tcSink g amap scopem env (ty: TType) openDeclaration = + let env = + { env with eNameResEnv = AddTypeContentsToNameEnv g amap env.eAccessRights scopem env.eNameResEnv ty } + CallEnvSink tcSink (scopem, env.NameEnv, env.eAccessRights) + CallOpenDeclarationSink tcSink openDeclaration + env + //------------------------------------------------------------------------- // Checking types and type constraints //------------------------------------------------------------------------- @@ -12840,6 +12848,32 @@ and TcLetrecBindings overridesOK (cenv: cenv) env tpenv (binds, bindsm, scopem) let envbody = AddLocalVals g cenv.tcSink scopem prelimRecValues env binds, envbody, tpenv +and TcOpenTypeDecl (cenv: cenv) mOpenDecl scopem env (synType: SynType, m) = + let g = cenv.g + + checkLanguageFeatureError g.langVersion LanguageFeature.OpenTypeDeclaration mOpenDecl + + let ty, _tpenv = TcType cenv NoNewTypars CheckCxs ItemOccurrence.Open WarnOnIWSAM.Yes env emptyUnscopedTyparEnv synType + + if not (isAppTy g ty) then + errorR(Error(FSComp.SR.tcNamedTypeRequired("open type"), m)) + + if isByrefTy g ty then + errorR(Error(FSComp.SR.tcIllegalByrefsInOpenTypeDeclaration(), m)) + + let openDecl = OpenDeclaration.Create (SynOpenDeclTarget.Type (synType, m), [], [ty], scopem, false) + let env = OpenTypeContent cenv.tcSink g cenv.amap scopem env ty openDecl + env, [openDecl] + +and TcOpenDecl (cenv: cenv) mOpenDecl scopem env target = + let g = cenv.g + match target with + | SynOpenDeclTarget.ModuleOrNamespace (longId, m) -> + TcOpenModuleOrNamespaceDecl cenv.tcSink g cenv.amap scopem env (longId.LongIdent, m) + + | SynOpenDeclTarget.Type (synType, m) -> + TcOpenTypeDecl cenv mOpenDecl scopem env (synType, m) + //------------------------------------------------------------------------- // Bind specifications of values //------------------------------------------------------------------------- diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fsi b/src/Compiler/Checking/Expressions/CheckExpressions.fsi index 9e3014896c8..ef05183d9dc 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fsi +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fsi @@ -883,6 +883,14 @@ val TcRuntimeTypeTest: srcTy: TType -> unit +val TcOpenDecl: + cenv: TcFileState -> + mOpenDecl: range -> + scopem: range -> + env: TcEnv -> + target: SynOpenDeclTarget -> + TcEnv * OpenDeclaration list + /// Allow the inference of structness from the known type, e.g. /// let (x: struct (int * int)) = (3,4) val UnifyTupleTypeAndInferCharacteristics: From 31858a4bbdb985ae52979d76acd8aca3384e3636 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Mon, 4 Aug 2025 15:46:38 +0800 Subject: [PATCH 02/22] prototype --- src/Compiler/Checking/CheckDeclarations.fs | 31 +++++++++----- .../Checking/Expressions/CheckExpressions.fs | 5 +++ .../GraphChecking/FileContentMapping.fs | 1 + .../Service/FSharpParseFileResults.fs | 1 + src/Compiler/Service/ServiceParseTreeWalk.fs | 3 +- src/Compiler/Service/ServiceParsedInputOps.fs | 40 ++++++++++--------- src/Compiler/SyntaxTree/LexFilter.fs | 19 ++++++++- src/Compiler/SyntaxTree/SyntaxTree.fs | 5 ++- src/Compiler/SyntaxTree/SyntaxTree.fsi | 4 ++ src/Compiler/SyntaxTree/SyntaxTreeOps.fs | 2 + src/Compiler/pars.fsy | 8 +++- 11 files changed, 88 insertions(+), 31 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 8376af11e3d..8d6058c2677 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -850,6 +850,8 @@ module MutRecBindingChecking = /// Indicates the last 'field' has been initialized, only 'do' comes after | Phase2AIncrClassCtorJustAfterLastLet + | Phase2AOpen of target: SynOpenDeclTarget * range: range + /// The collected syntactic input definitions for a single type or type-extension definition type TyconBindingsPhase2A = | TyconBindingsPhase2A of Tycon option * DeclKind * Val list * TyconRef * Typar list * TType * TyconBindingPhase2A list @@ -1061,6 +1063,9 @@ module MutRecBindingChecking = let innerState = (incrCtorInfoOpt, envForTycon, tpenv, recBindIdx, List.rev binds @ uncheckedBindsRev) cbinds, innerState + + | Some (SynMemberDefn.Open (target, m)), _ -> [Phase2AOpen (target, m)], innerState + | definition -> error(InternalError(sprintf "Unexpected definition %A" definition, m))) @@ -1108,7 +1113,7 @@ module MutRecBindingChecking = let rest = let isAfter b = match b with - | Phase2AIncrClassCtor _ | Phase2AInherit _ | Phase2AIncrClassCtorJustAfterSuperInit -> false + | Phase2AIncrClassCtor _ | Phase2AInherit _ | Phase2AIncrClassCtorJustAfterSuperInit | Phase2AOpen _ -> false | Phase2AIncrClassBindings (_, binds, _, _, _) -> binds |> List.exists (function SynBinding (kind=SynBindingKind.Do) -> true | _ -> false) | Phase2AIncrClassCtorJustAfterLastLet | Phase2AMember _ -> true @@ -1224,7 +1229,7 @@ module MutRecBindingChecking = let defnBs, (tpenv, _, _, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) = let initialInnerState = (tpenv, envForTycon, envForTycon, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - (initialInnerState, defnAs) ||> List.mapFold (fun innerState defnA -> + (initialInnerState, defnAs) ||> List.collectFold (fun innerState defnA -> let tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable = innerState @@ -1257,7 +1262,7 @@ module MutRecBindingChecking = | Some incrCtorInfo -> TcLetrecComputeCtorSafeThisValBind cenv incrCtorInfo.InstanceCtorSafeThisValOpt let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - Phase2BIncrClassCtor (staticCtorInfo, incrCtorInfoOpt, safeThisValBindOpt), innerState + [Phase2BIncrClassCtor (staticCtorInfo, incrCtorInfoOpt, safeThisValBindOpt)], innerState // Phase2B: typecheck the argument to an 'inherits' call and build the new object expr for the inherit-call | Phase2AInherit (synBaseTy, arg, baseValOpt, m) -> @@ -1272,7 +1277,7 @@ module MutRecBindingChecking = let envInstance = match baseValOpt with Some baseVal -> AddLocalVal g cenv.tcSink scopem baseVal envInstance | None -> envInstance let envNonRec = match baseValOpt with Some baseVal -> AddLocalVal g cenv.tcSink scopem baseVal envNonRec | None -> envNonRec let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - Phase2BInherit inheritsExpr, innerState + [Phase2BInherit inheritsExpr], innerState // Phase2B: let and let rec value and function definitions | Phase2AIncrClassBindings (tcref, binds, isStatic, isRec, mBinds) -> @@ -1317,15 +1322,15 @@ module MutRecBindingChecking = let envInstance = (if isStatic then (binds, envInstance) ||> List.foldBack (fun b e -> AddLocalVal g cenv.tcSink scopem b.Var e) else env) let envStatic = (if isStatic then env else envStatic) let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - Phase2BIncrClassBindings bindRs, innerState + [Phase2BIncrClassBindings bindRs], innerState | Phase2AIncrClassCtorJustAfterSuperInit -> let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - Phase2BIncrClassCtorJustAfterSuperInit, innerState + [Phase2BIncrClassCtorJustAfterSuperInit], innerState | Phase2AIncrClassCtorJustAfterLastLet -> let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - Phase2BIncrClassCtorJustAfterLastLet, innerState + [Phase2BIncrClassCtorJustAfterLastLet], innerState // Note: this path doesn't add anything the environment, because the member is already available off via its type @@ -1355,7 +1360,15 @@ module MutRecBindingChecking = TcLetrecBinding (cenv, envForBinding, scopem, extraGeneralizableTypars, reqdThisValTyOpt) (envNonRec, generalizedRecBinds, preGeneralizationRecBinds, tpenv, uncheckedRecBindsTable) rbind let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - Phase2BMember rbind.RecBindingInfo.Index, innerState) + [Phase2BMember rbind.RecBindingInfo.Index], innerState + | Phase2AOpen (target, m) -> + let scopem = unionRanges m.EndRange scopem + let envInstance, _openDecls = TcOpenDecl cenv m scopem envInstance target + let envStatic, _openDecls = TcOpenDecl cenv m scopem envStatic target + let envNonRec, _openDecls = TcOpenDecl cenv m scopem envNonRec target + let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) + [], innerState + ) let tyconOpt = if not(cenv.g.langVersion.SupportsFeature(LanguageFeature.CSharpExtensionAttributeNotRequired)) then @@ -1964,10 +1977,10 @@ let TcMutRecDefns_Phase2 (cenv: cenv) envInitial mBinds scopem mutRecNSInfo (env match mem with | SynMemberDefn.AutoProperty (isStatic=isStatic) | SynMemberDefn.LetBindings (isStatic=isStatic) when isStatic -> () + | SynMemberDefn.Open _ | SynMemberDefn.Member _ | SynMemberDefn.GetSetMember _ | SynMemberDefn.Interface _ -> () - | SynMemberDefn.Open _ | SynMemberDefn.AutoProperty _ | SynMemberDefn.LetBindings _ | SynMemberDefn.ImplicitCtor _ // accept implicit ctor pattern, should be first! diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 590136c12ab..713afe6c8e2 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -6091,6 +6091,10 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE | SynExpr.IndexRange (range=m) -> error(Error(FSComp.SR.tcInvalidIndexerExpression(), m)) + | SynExpr.Open (target, m, body) -> + let env, _openDecls = TcOpenDecl cenv m body.Range env target + TcLinearExprs (TcExprThatCanBeCtorBody cenv) cenv env overallTy tpenv false body id + and TcExprMatch (cenv: cenv) overallTy env tpenv synInputExpr spMatch synClauses = let inputExpr, inputTy, tpenv = let env = { env with eIsControlFlow = false } @@ -9213,6 +9217,7 @@ and TcImplicitOpItemThen (cenv: cenv) overallTy env id sln tpenv mItem delayed = | SynExpr.TraitCall _ | SynExpr.IndexFromEnd _ | SynExpr.IndexRange _ + | SynExpr.Open _ -> false // Propagate the known application structure into function types diff --git a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs index 7be965522f6..c3f937c0a96 100644 --- a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs +++ b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs @@ -574,6 +574,7 @@ let visitSynExpr (e: SynExpr) : FileContentEntry list = | SynExpr.Dynamic(funcExpr, _, argExpr, _) -> let continuations = List.map visit [ funcExpr; argExpr ] Continuation.concatenate continuations continuation + | SynExpr.Open(body = body) -> visit body continuation visit e id diff --git a/src/Compiler/Service/FSharpParseFileResults.fs b/src/Compiler/Service/FSharpParseFileResults.fs index 612057578f7..3f51731ed72 100644 --- a/src/Compiler/Service/FSharpParseFileResults.fs +++ b/src/Compiler/Service/FSharpParseFileResults.fs @@ -771,6 +771,7 @@ type FSharpParseFileResults(diagnostics: FSharpDiagnostic[], input: ParsedInput, yield! walkExpr true eAndBang yield! walkExpr true bodyExpr + | SynExpr.Open(body = bodyExpr) -> yield! walkExpr true bodyExpr ] // Process a class declaration or F# type declaration diff --git a/src/Compiler/Service/ServiceParseTreeWalk.fs b/src/Compiler/Service/ServiceParseTreeWalk.fs index 33734db9a62..0c990bbdc91 100644 --- a/src/Compiler/Service/ServiceParseTreeWalk.fs +++ b/src/Compiler/Service/ServiceParseTreeWalk.fs @@ -423,7 +423,8 @@ module SyntaxTraversal = | SynExpr.TypeApp(expr = synExpr) | SynExpr.DotLambda(expr = synExpr) | SynExpr.Quote(quotedExpr = synExpr) - | SynExpr.Paren(expr = synExpr) -> traverseSynExpr synExpr + | SynExpr.Paren(expr = synExpr) + | SynExpr.Open(body = synExpr) -> traverseSynExpr synExpr | SynExpr.InterpolatedString(contents = parts) -> [ diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index b8ffe0d030f..48b5f94793d 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -1424,6 +1424,25 @@ module ParsedInput = None | _ -> None + let tryMakeOpenDeclarationCtx target m (pos: pos) = + // in theory, this means we're "in an open" + // in practice, because the parse tree/visitors do not handle attributes well yet, need extra check below to ensure not e.g. $here$ + // open System + // [ true + | SynOpenDeclTarget.ModuleOrNamespace _ -> false + + Some(CompletionContext.OpenDeclaration isOpenType) + else + None + /// Try to determine completion context for the given pair (row, columns) let TryGetCompletionContext (pos, parsedInput: ParsedInput, lineStr: string) : CompletionContext option = @@ -1476,6 +1495,8 @@ module ParsedInput = -> Some(CompletionContext.Inherit(InheritanceContext.Unknown, ([], None))) + | SynExpr.Open(target, m, _) -> tryMakeOpenDeclarationCtx target m pos + | _ -> defaultTraverse expr member _.VisitRecordField(path, copyOpt, field) = @@ -1744,24 +1765,7 @@ module ParsedInput = member _.VisitModuleDecl(_, defaultTraverse, decl) = match decl with - | SynModuleDecl.Open(target, m) -> - // in theory, this means we're "in an open" - // in practice, because the parse tree/visitors do not handle attributes well yet, need extra check below to ensure not e.g. $here$ - // open System - // [ true - | SynOpenDeclTarget.ModuleOrNamespace _ -> false - - Some(CompletionContext.OpenDeclaration isOpenType) - else - None + | SynModuleDecl.Open(target, m) -> tryMakeOpenDeclarationCtx target m pos // module Namespace.Top // module Nested diff --git a/src/Compiler/SyntaxTree/LexFilter.fs b/src/Compiler/SyntaxTree/LexFilter.fs index e298202d984..ddb0b589a13 100644 --- a/src/Compiler/SyntaxTree/LexFilter.fs +++ b/src/Compiler/SyntaxTree/LexFilter.fs @@ -66,6 +66,8 @@ type Context = // Indicates we're processing the second part of a match, after the 'with' // First bool indicates "was this 'with' followed immediately by a '|'"? | CtxtMatchClauses of bool * Position + // Used to avoid early inserting OBLOCKEND in `open type ...` + | CtxtOpen of Position member c.StartPos = match c with @@ -74,6 +76,7 @@ type Context = | CtxtWithAsLet p | CtxtWithAsAugment p | CtxtMatchClauses (_, p) | CtxtIf p | CtxtMatch p | CtxtFor p | CtxtWhile p | CtxtWhen p | CtxtFunction p | CtxtFun p | CtxtTry p | CtxtThen p | CtxtElse p | CtxtVanilla (p, _) + | CtxtOpen p | CtxtSeqBlock (_, p, _) -> p member c.StartCol = c.StartPos.Column @@ -109,6 +112,7 @@ type Context = | CtxtThen _ -> "then" | CtxtElse p -> sprintf "else(%s)" (stringOfPos p) | CtxtVanilla (p, _) -> sprintf "vanilla(%s)" (stringOfPos p) + | CtxtOpen _ -> "open" and AddBlockEnd = AddBlockEnd | NoAddBlockEnd | AddOneSidedBlockEnd and FirstInSequence = FirstInSeqBlock | NotFirstInSeqBlock @@ -765,7 +769,8 @@ type LexFilterImpl ( | _, [] -> PositionWithColumn(newCtxt.StartPos, -1) // ignore Vanilla because a SeqBlock is always coming - | _, CtxtVanilla _ :: rest -> undentationLimit strict rest + | _, CtxtVanilla _ :: rest + | _, CtxtOpen _ :: rest -> undentationLimit strict rest | CtxtSeqBlock(FirstInSeqBlock, _, _), (CtxtDo _ as limitCtxt) :: CtxtSeqBlock _ :: (CtxtTypeDefns _ | CtxtModuleBody _) :: _ -> PositionWithColumn(limitCtxt.StartPos, limitCtxt.StartCol + 1) @@ -2469,6 +2474,18 @@ type LexFilterImpl ( pushCtxtSeqBlock tokenTup AddBlockEnd returnToken tokenLexbufState token + // The `open type ...` case + | OPEN, _ when peekNextToken().IsTYPE -> + pushCtxt tokenTup (CtxtOpen tokenStartPos) + if debug then dprintf "pushing CtxtOpen at tokenStartPos = %a\n" outputPos tokenStartPos + returnToken tokenLexbufState token + + // The `open type ...` case + | TYPE, CtxtOpen _ :: _ -> + if debug then dprintf "--> because TYPE is coming, popping CtxtOpen\n" + popCtxt() + returnToken tokenLexbufState token + | TYPE, _ -> insertComingSoonTokens("TYPE", TYPE_COMING_SOON, TYPE_IS_HERE) if debug then dprintf "TYPE, pushing CtxtTypeDefns(%a)\n" outputPos tokenStartPos diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index 5e3542f6b69..cf470cb970a 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -773,6 +773,8 @@ type SynExpr = | Dynamic of funcExpr: SynExpr * qmark: range * argExpr: SynExpr * range: range + | Open of target: SynOpenDeclTarget * range: range * body: SynExpr + member e.Range = match e with | SynExpr.Paren(_, leftParenRange, rightParenRange, r) -> @@ -846,7 +848,8 @@ type SynExpr = | SynExpr.InterpolatedString(range = m) | SynExpr.Dynamic(range = m) -> m | SynExpr.Ident id -> id.idRange - | SynExpr.Typar(range = m) -> m + | SynExpr.Typar(range = m) + | SynExpr.Open(range = m) -> m | SynExpr.DebugPoint(_, _, innerExpr) -> innerExpr.Range member e.RangeWithoutAnyExtraDot = diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index aa6f394d6c4..c145fffffb9 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -964,6 +964,10 @@ type SynExpr = /// F# syntax: f?x | Dynamic of funcExpr: SynExpr * qmark: range * argExpr: SynExpr * range: range + /// An 'open' definition within an expr + /// let open System in ... + | Open of target: SynOpenDeclTarget * range: range * body: SynExpr + /// Gets the syntax range of this construct member Range: range diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs index 616191c9b5a..0479ef5cf90 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs @@ -997,6 +997,8 @@ let rec synExprContainsError inpExpr = | SynInterpolatedStringPart.FillExpr(x, _) -> Some x) |> walkExprs + | SynExpr.Open (body = e) -> walkExpr e + walkExpr inpExpr let longIdentToString (ident: SynLongIdent) = diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 8b0dfa4ae8c..bd828ae10b6 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -2125,7 +2125,7 @@ classDefnMember: assert (match declPat with SynPatForConstructorDecl _ -> true | _ -> false) let synBindingTrivia: SynBindingTrivia = { LeadingKeyword = SynLeadingKeyword.New mNew; InlineKeyword = None; EqualsRange = None } [ SynMemberDefn.Member(SynBinding(None, SynBindingKind.Normal, false, false, $1, xmlDoc, valSynData, declPat, None, expr, m, DebugPointAtBinding.NoneAtInvisible, synBindingTrivia), m) ] } - + | opt_attributes opt_access NEW atomicPattern optAsSpec OBLOCKSEP { reportParseErrorAt (rhs parseState 5) (FSComp.SR.parsMissingMemberBody ()) let mNew = rhs parseState 3 @@ -2157,6 +2157,8 @@ classDefnMember: let leadingKeyword = SynTypeDefnLeadingKeyword.StaticType(rhs parseState 3, rhs parseState 4) [ SynMemberDefn.NestedType($5 leadingKeyword, None, rhs2 parseState 1 5) ] } + | openDecl + { [ SynMemberDefn.Open $1 ] } /* A 'val' definition in an object type definition */ valDefnDecl: @@ -4207,6 +4209,10 @@ declExpr: { let (BindingSetPreAttrs(_, _, _, _, m)), e = $1 SynExpr.Do(e, unionRanges (rhs parseState 1).StartRange e.Range) } + | openDecl opt_seps typedSequentialExpr + { let target, mOpen = $1 + SynExpr.Open(target, mOpen, $3) } + | anonMatchingExpr %prec expr_function { $1 } From d80fdcb896cfafffda5ed49f23635d565b4a54a5 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Mon, 4 Aug 2025 23:12:40 +0800 Subject: [PATCH 03/22] fix: the later line can have more indents --- src/Compiler/SyntaxTree/SyntaxTreeOps.fs | 2 +- src/Compiler/pars.fsy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs index 0479ef5cf90..9b9bef46240 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs @@ -997,7 +997,7 @@ let rec synExprContainsError inpExpr = | SynInterpolatedStringPart.FillExpr(x, _) -> Some x) |> walkExprs - | SynExpr.Open (body = e) -> walkExpr e + | SynExpr.Open(body = e) -> walkExpr e walkExpr inpExpr diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index bd828ae10b6..f3abb018fa8 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -4209,7 +4209,7 @@ declExpr: { let (BindingSetPreAttrs(_, _, _, _, m)), e = $1 SynExpr.Do(e, unionRanges (rhs parseState 1).StartRange e.Range) } - | openDecl opt_seps typedSequentialExpr + | openDecl seps typedSequentialExprBlock { let target, mOpen = $1 SynExpr.Open(target, mOpen, $3) } From fc1869da5855f00e58855b4a4788126ca922cf56 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Mon, 4 Aug 2025 23:40:28 +0800 Subject: [PATCH 04/22] fix: ce --- .../Checking/Expressions/CheckComputationExpressions.fs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs index 00b992a6f92..5981d68b974 100644 --- a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs @@ -2261,6 +2261,10 @@ let rec TryTranslateComputationExpression Some(translatedCtxt yieldOrReturnCall) + | SynExpr.Open(target, m, body) -> + let body = TranslateComputationExpressionNoQueryOps ceenv body + Some(translatedCtxt (SynExpr.Open(target, m, body))) + | _ -> None and ConsumeCustomOpClauses From 2ab59c52310a97c6a84f150765906f658cb2457f Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 5 Aug 2025 03:11:16 +0800 Subject: [PATCH 05/22] try to make type-scoped open works --- src/Compiler/Checking/CheckDeclarations.fs | 91 +++++++++++++++++++--- 1 file changed, 82 insertions(+), 9 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 8d6058c2677..bd69ccb3d95 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -1361,11 +1361,11 @@ module MutRecBindingChecking = let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) [Phase2BMember rbind.RecBindingInfo.Index], innerState + | Phase2AOpen (target, m) -> let scopem = unionRanges m.EndRange scopem let envInstance, _openDecls = TcOpenDecl cenv m scopem envInstance target let envStatic, _openDecls = TcOpenDecl cenv m scopem envStatic target - let envNonRec, _openDecls = TcOpenDecl cenv m scopem envNonRec target let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) [], innerState ) @@ -1991,7 +1991,7 @@ let TcMutRecDefns_Phase2 (cenv: cenv) envInitial mBinds scopem mutRecNSInfo (env let binds: MutRecDefnsPhase2Info = (envMutRec, mutRecDefns) ||> MutRecShapes.mapTyconsWithEnv (fun envForDecls tyconData -> - let (MutRecDefnsPhase2DataForTycon(tyconOpt, _x, declKind, tcref, _, _, declaredTyconTypars, synMembers, _, _, fixupFinalAttrs)) = tyconData + let (MutRecDefnsPhase2DataForTycon(tyconOpt, parent, declKind, tcref, _, _, declaredTyconTypars, synMembers, _, _, fixupFinalAttrs)) = tyconData // If a tye uses both [] and [] attributes it means it is a static class. let isStaticClass = HasFSharpAttribute g g.attrib_SealedAttribute tcref.Attribs && HasFSharpAttribute g g.attrib_AbstractClassAttribute tcref.Attribs @@ -2017,10 +2017,26 @@ let TcMutRecDefns_Phase2 (cenv: cenv) envInitial mBinds scopem mutRecNSInfo (env | _ -> envForDecls let obinds = tyconBindingsOfTypeDefn tyconData - let ibinds = - let intfTypes = interfacesFromTypeDefn envForDecls tyconData - let slotImplSets = DispatchSlotChecking.GetSlotImplSets cenv.infoReader envForDecls.DisplayEnv envForDecls.AccessRights false (List.map (fun (intfTy, _, m) -> (intfTy, m)) intfTypes) - (intfTypes, slotImplSets) ||> List.map2 (interfaceMembersFromTypeDefn tyconData) |> List.concat + let ibinds = + // The env with type-scoped `open`s applied + let envForDecls = + // Get the whole range that containing the type definition + // Used to add `open`s to the environment + let mParent = + match parent with + | Parent parent -> parent.DefinitionRange + | ParentNone -> tcref.DefinitionRange + (envForDecls, synMembers) ||> List.fold (fun envForDecls -> + function + | SynMemberDefn.Open (target, mOpen) -> + let envForDecls, _openDecl = TcOpenDecl cenv mOpen mParent envForDecls target + envForDecls + | _ -> envForDecls + ) + + let intfTypes = interfacesFromTypeDefn envForDecls tyconData + let slotImplSets = DispatchSlotChecking.GetSlotImplSets cenv.infoReader envForDecls.DisplayEnv envForDecls.AccessRights false (List.map (fun (intfTy, _, m) -> (intfTy, m)) intfTypes) + (intfTypes, slotImplSets) ||> List.map2 (interfaceMembersFromTypeDefn tyconData) |> List.concat MutRecDefnsPhase2InfoForTycon(tyconOpt, tcref, declaredTyconTypars, declKind, obinds @ ibinds, fixupFinalAttrs)) MutRecBindingChecking.TcMutRecDefns_Phase2_Bindings cenv envInitial tpenv mBinds scopem mutRecNSInfo envMutRec binds @@ -3193,12 +3209,31 @@ module EstablishTypeDefinitionCores = let tyconWithImplementsL = (envMutRec, mutRecDefns) ||> MutRecShapes.mapTyconsWithEnv (fun envinner (origInfo, tyconAndAttrsOpt) -> match origInfo, tyconAndAttrsOpt with - | (typeDefCore, _, _), Some (tycon, (attrs, _)) -> + | (typeDefCore, memberDefns, parent), Some (tycon, (attrs, _)) -> let (MutRecDefnsPhase1DataForTycon(_, synTyconRepr, explicitImplements, _, _, _)) = typeDefCore let m = tycon.Range let tcref = mkLocalTyconRef tycon let envinner = AddDeclaredTypars CheckForDuplicateTypars (tycon.Typars m) envinner let envinner = MakeInnerEnvForTyconRef envinner tcref false + + // The env with type-scoped `open`s applied + let envinner = + match box memberDefns with + | :? (SynMemberDefn list) as memberDefns -> + // Get the whole range that containing the type definition + // Used to add `open`s to the environment + let mParent = + match parent with + | Parent parent -> parent.DefinitionRange + | ParentNone -> m + (envinner, memberDefns) ||> List.fold (fun envinner -> + function + | SynMemberDefn.Open (target, mOpen) -> + let envinner, _openDecl = TcOpenDecl cenv mOpen mParent envinner target + envinner + | _ -> envinner + ) + | _ -> envinner let implementedTys, _ = List.mapFold (mapFoldFst (TcTypeAndRecover cenv NoNewTypars checkConstraints ItemOccurrence.UseInType WarnOnIWSAM.No envinner)) tpenv explicitImplements @@ -4021,7 +4056,26 @@ module EstablishTypeDefinitionCores = (envMutRecPrelim, withEnvs) ||> MutRecShapes.mapTyconsWithEnv (fun envForDecls (origInfo, tyconOpt) -> match origInfo, tyconOpt with - | (typeDefCore, _, _), Some tycon -> Some (tycon, GetStructuralElementsOfTyconDefn cenv envForDecls tpenv typeDefCore tycon) + | (typeDefCore, memberDefns, parent), Some tycon -> + // The env with type-scoped `open`s applied + let envForDecls = + match box memberDefns with + | :? (SynMemberDefn list) as memberDefns -> + // Get the whole range that containing the type definition + // Used to add `open`s to the environment + let mParent = + match parent with + | Parent parent -> parent.DefinitionRange + | ParentNone -> m + (envForDecls, memberDefns) ||> List.fold (fun envForDecls -> + function + | SynMemberDefn.Open (target, mOpen) -> + let envForDecls, _openDecl = TcOpenDecl cenv mOpen mParent envForDecls target + envForDecls + | _ -> envForDecls + ) + | _ -> envForDecls + Some (tycon, GetStructuralElementsOfTyconDefn cenv envForDecls tpenv typeDefCore tycon) | _ -> None) |> MutRecShapes.collectTycons |> List.choose id @@ -4067,7 +4121,26 @@ module EstablishTypeDefinitionCores = (envMutRecPrelim, withAttrs) ||> MutRecShapes.mapTyconsWithEnv (fun envForDecls (origInfo, tyconAndAttrsOpt) -> let info = match origInfo, tyconAndAttrsOpt with - | (typeDefCore, _, _), Some (tycon, (attrs, _)) -> TcTyconDefnCore_Phase1G_EstablishRepresentation cenv envForDecls tpenv inSig typeDefCore tycon attrs + | (typeDefCore, memberDefns, parent), Some (tycon, (attrs, _)) -> + // The env with type-scoped `open`s applied + let envForDecls = + match box memberDefns with + | :? (SynMemberDefn list) as memberDefns -> + // Get the whole range that containing the type definition + // Used to add `open`s to the environment + let mParent = + match parent with + | Parent parent -> parent.DefinitionRange + | ParentNone -> m + (envForDecls, memberDefns) ||> List.fold (fun envForDecls -> + function + | SynMemberDefn.Open (target, mOpen) -> + let envForDecls, _openDecl = TcOpenDecl cenv mOpen mParent envForDecls target + envForDecls + | _ -> envForDecls + ) + | _ -> envForDecls + TcTyconDefnCore_Phase1G_EstablishRepresentation cenv envForDecls tpenv inSig typeDefCore tycon attrs | _ -> None, NoSafeInitInfo let tyconOpt, fixupFinalAttrs = match tyconAndAttrsOpt with From 10b65bc8616b369d21041674cdd055d4b0b925bd Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 5 Aug 2025 23:27:50 +0800 Subject: [PATCH 06/22] type-scoped opens must at the begining --- src/Compiler/Checking/CheckDeclarations.fs | 133 +++++++++----------- src/Compiler/Checking/CheckDeclarations.fsi | 3 + src/Compiler/FSComp.txt | 3 +- src/Compiler/xlf/FSComp.txt.cs.xlf | 5 + src/Compiler/xlf/FSComp.txt.de.xlf | 5 + src/Compiler/xlf/FSComp.txt.es.xlf | 5 + src/Compiler/xlf/FSComp.txt.fr.xlf | 5 + src/Compiler/xlf/FSComp.txt.it.xlf | 5 + src/Compiler/xlf/FSComp.txt.ja.xlf | 5 + src/Compiler/xlf/FSComp.txt.ko.xlf | 5 + src/Compiler/xlf/FSComp.txt.pl.xlf | 5 + src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 + src/Compiler/xlf/FSComp.txt.ru.xlf | 5 + src/Compiler/xlf/FSComp.txt.tr.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 + 16 files changed, 132 insertions(+), 72 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index bd69ccb3d95..d73c5d336c2 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -669,6 +669,37 @@ let TcTyconMemberSpecs cenv env containerInfo declKind tpenv augSpfn = let members, tpenv = List.mapFold (TcAndPublishMemberSpec cenv env containerInfo declKind) tpenv augSpfn List.concat members, tpenv +//------------------------------------------------------------------------- +// Bind 'open' declarations +//------------------------------------------------------------------------- + +let TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) = + CheckBasics.TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) + +let private buildTcEnvWithTypeScopedOpensApplied cenv parent mFallback synMembers env = + // Because 'MemberInfo is not SynMemberDefn list when it is in a signature file, + // we need to check the type first + match box synMembers with + | :? (SynMemberDefn list) as synMembers -> + // Get the whole range that containing the type definition + // Used to add `open`s to the environment + let mParent = + match parent with + | Parent parent -> parent.DefinitionRange + | ParentNone -> mFallback + + // Since type-scoped opens are always at the top of the type definition, + // we can just go through until we hit a non-open declaration + let rec loop env = function + | SynMemberDefn.Open (target, mOpen) :: rest -> + let env, _openDecl = TcOpenDecl cenv mOpen mParent env target + loop env rest + | SynMemberDefn.ImplicitCtor _ :: rest -> loop env rest + | _ -> env + + loop env synMembers + | _ -> env + let MakeSafeInitField (cenv: cenv) env m isStatic = let id = // Ensure that we have an g.CompilerGlobalState @@ -2019,21 +2050,7 @@ let TcMutRecDefns_Phase2 (cenv: cenv) envInitial mBinds scopem mutRecNSInfo (env let obinds = tyconBindingsOfTypeDefn tyconData let ibinds = // The env with type-scoped `open`s applied - let envForDecls = - // Get the whole range that containing the type definition - // Used to add `open`s to the environment - let mParent = - match parent with - | Parent parent -> parent.DefinitionRange - | ParentNone -> tcref.DefinitionRange - (envForDecls, synMembers) ||> List.fold (fun envForDecls -> - function - | SynMemberDefn.Open (target, mOpen) -> - let envForDecls, _openDecl = TcOpenDecl cenv mOpen mParent envForDecls target - envForDecls - | _ -> envForDecls - ) - + let envForDecls = buildTcEnvWithTypeScopedOpensApplied cenv parent tcref.Range synMembers envForDecls let intfTypes = interfacesFromTypeDefn envForDecls tyconData let slotImplSets = DispatchSlotChecking.GetSlotImplSets cenv.infoReader envForDecls.DisplayEnv envForDecls.AccessRights false (List.map (fun (intfTy, _, m) -> (intfTy, m)) intfTypes) (intfTypes, slotImplSets) ||> List.map2 (interfaceMembersFromTypeDefn tyconData) |> List.concat @@ -2319,6 +2336,13 @@ let CheckForDuplicateModule env nm m = if curr.ModulesAndNamespacesByDemangledName.ContainsKey nm then errorR (Duplicate(FSComp.SR.tcTypeOrModule(), nm, m)) +// Check the ordering of opens +// 'open' declarations must come before all other definitions in type definitions +let rec private CheckOpensOrderInTypeDefinition metNonOpen = function +| (SynMemberDefn.Open _ | SynMemberDefn.ImplicitCtor _) :: ds when not metNonOpen -> CheckOpensOrderInTypeDefinition false ds +| SynMemberDefn.Open (range = m) :: _ -> errorR(Error(FSComp.SR.tcTypeDefinitionsMustHaveOpensBeforeOtherMembers(), m)) +| _ :: ds -> CheckOpensOrderInTypeDefinition true ds +| [] -> () //------------------------------------------------------------------------- // Bind exception definitions @@ -2432,6 +2456,8 @@ module TcExceptionDeclarations = let binds1, exnc = TcExnDefnCore cenv envInitial parent core let envMutRec = AddLocalExnDefnAndReport cenv.tcSink scopem (AddLocalTycons g cenv.amap scopem [exnc] envInitial) exnc + CheckOpensOrderInTypeDefinition false aug + let defns = [MutRecShape.Tycon(MutRecDefnsPhase2DataForTycon(Some exnc, parent, ModuleOrMemberBinding, mkLocalEntityRef exnc, None, NoSafeInitInfo, [], aug, m, NoNewSlots, (fun () -> ())))] let binds2, envFinal = TcMutRecDefns_Phase2 cenv envInitial m scopem None envMutRec defns true let binds2flat = binds2 |> MutRecShapes.collectTycons |> List.collect snd @@ -3217,24 +3243,7 @@ module EstablishTypeDefinitionCores = let envinner = MakeInnerEnvForTyconRef envinner tcref false // The env with type-scoped `open`s applied - let envinner = - match box memberDefns with - | :? (SynMemberDefn list) as memberDefns -> - // Get the whole range that containing the type definition - // Used to add `open`s to the environment - let mParent = - match parent with - | Parent parent -> parent.DefinitionRange - | ParentNone -> m - (envinner, memberDefns) ||> List.fold (fun envinner -> - function - | SynMemberDefn.Open (target, mOpen) -> - let envinner, _openDecl = TcOpenDecl cenv mOpen mParent envinner target - envinner - | _ -> envinner - ) - | _ -> envinner - + let envinner = buildTcEnvWithTypeScopedOpensApplied cenv parent m memberDefns envinner let implementedTys, _ = List.mapFold (mapFoldFst (TcTypeAndRecover cenv NoNewTypars checkConstraints ItemOccurrence.UseInType WarnOnIWSAM.No envinner)) tpenv explicitImplements if firstPass then @@ -4056,25 +4065,14 @@ module EstablishTypeDefinitionCores = (envMutRecPrelim, withEnvs) ||> MutRecShapes.mapTyconsWithEnv (fun envForDecls (origInfo, tyconOpt) -> match origInfo, tyconOpt with - | (typeDefCore, memberDefns, parent), Some tycon -> - // The env with type-scoped `open`s applied - let envForDecls = - match box memberDefns with - | :? (SynMemberDefn list) as memberDefns -> - // Get the whole range that containing the type definition - // Used to add `open`s to the environment - let mParent = - match parent with - | Parent parent -> parent.DefinitionRange - | ParentNone -> m - (envForDecls, memberDefns) ||> List.fold (fun envForDecls -> - function - | SynMemberDefn.Open (target, mOpen) -> - let envForDecls, _openDecl = TcOpenDecl cenv mOpen mParent envForDecls target - envForDecls - | _ -> envForDecls - ) - | _ -> envForDecls + | (MutRecDefnsPhase1DataForTycon(_, synTyconRepr, _, _, _, _) as typeDefCore, memberDefns, parent), Some tycon -> + // The env with type-scoped `open`s applied. + // Only apply when the type is not a union/record/exception, to avoid the field types + // can reference a type open in the `with` section. + let envForDecls = + if synTyconRepr.IsGeneral then + buildTcEnvWithTypeScopedOpensApplied cenv parent m memberDefns envForDecls + else envForDecls Some (tycon, GetStructuralElementsOfTyconDefn cenv envForDecls tpenv typeDefCore tycon) | _ -> None) |> MutRecShapes.collectTycons @@ -4121,25 +4119,14 @@ module EstablishTypeDefinitionCores = (envMutRecPrelim, withAttrs) ||> MutRecShapes.mapTyconsWithEnv (fun envForDecls (origInfo, tyconAndAttrsOpt) -> let info = match origInfo, tyconAndAttrsOpt with - | (typeDefCore, memberDefns, parent), Some (tycon, (attrs, _)) -> - // The env with type-scoped `open`s applied - let envForDecls = - match box memberDefns with - | :? (SynMemberDefn list) as memberDefns -> - // Get the whole range that containing the type definition - // Used to add `open`s to the environment - let mParent = - match parent with - | Parent parent -> parent.DefinitionRange - | ParentNone -> m - (envForDecls, memberDefns) ||> List.fold (fun envForDecls -> - function - | SynMemberDefn.Open (target, mOpen) -> - let envForDecls, _openDecl = TcOpenDecl cenv mOpen mParent envForDecls target - envForDecls - | _ -> envForDecls - ) - | _ -> envForDecls + | (MutRecDefnsPhase1DataForTycon(_, synTyconRepr, _, _, _, _) as typeDefCore, memberDefns, parent), Some (tycon, (attrs, _)) -> + // The env with type-scoped `open`s applied. + // Only apply when the type is not a union/record/exception, to avoid the field types + // can reference a type open in the `with` section. + let envForDecls = + if synTyconRepr.IsGeneral then + buildTcEnvWithTypeScopedOpensApplied cenv parent m memberDefns envForDecls + else envForDecls TcTyconDefnCore_Phase1G_EstablishRepresentation cenv envForDecls tpenv inSig typeDefCore tycon attrs | _ -> None, NoSafeInitInfo let tyconOpt, fixupFinalAttrs = @@ -4478,12 +4465,16 @@ module TcDeclarations = /// body = members /// where members contain methods/overrides, also implicit ctor, inheritCall and local definitions. let rec private SplitTyconDefn g (SynTypeDefn(typeInfo=synTyconInfo;typeRepr=trepr; members=extraMembers)) = + CheckOpensOrderInTypeDefinition false extraMembers + let extraMembers = desugarGetSetMembers extraMembers let extraMembers, extra_vals_Inherits_Abstractslots = SplitAutoProps g extraMembers let implements1 = extraMembers |> List.choose (function SynMemberDefn.Interface (interfaceType=ty) -> Some(ty, ty.Range) | _ -> None) match trepr with | SynTypeDefnRepr.ObjectModel(kind, members, m) -> + CheckOpensOrderInTypeDefinition false members + let members = desugarGetSetMembers members CheckMembersForm members synTyconInfo.Range diff --git a/src/Compiler/Checking/CheckDeclarations.fsi b/src/Compiler/Checking/CheckDeclarations.fsi index fe42a443a89..9b06fcc828d 100644 --- a/src/Compiler/Checking/CheckDeclarations.fsi +++ b/src/Compiler/Checking/CheckDeclarations.fsi @@ -41,6 +41,9 @@ val EmptyTopAttrs: TopAttribs val CombineTopAttrs: TopAttribs -> TopAttribs -> TopAttribs +val TcOpenModuleOrNamespaceDecl: + TcResultsSink -> TcGlobals -> ImportMap -> range -> TcEnv -> LongIdent * range -> TcEnv * OpenDeclaration list + val AddLocalSubModule: g: TcGlobals -> amap: ImportMap -> m: range -> env: TcEnv -> moduleEntity: ModuleOrNamespace -> TcEnv diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index f259f06cac0..c26f807692d 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1806,4 +1806,5 @@ featureAllowLetOrUseBangTypeAnnotationWithoutParens,"Allow let! and use! type an 3875,lexWarnDirectiveMustHaveArgs,"Warn directives must have warning number(s) as argument(s)" 3876,lexWarnDirectivesMustMatch,"There is another %s for this warning already in line %d." 3877,lexLineDirectiveMappingIsNotUnique,"The file '%s' was also pointed to in a line directive in '%s'. Proper warn directive application may not be possible." -3878,tcAttributeIsNotValidForUnionCaseWithFields,"This attribute is not valid for use on union cases with fields." \ No newline at end of file +3878,tcAttributeIsNotValidForUnionCaseWithFields,"This attribute is not valid for use on union cases with fields." +3879,tcTypeDefinitionsMustHaveOpensBeforeOtherMembers,"'open' declarations must come before all other definitions in type definitions or augmentation" \ No newline at end of file diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index bb56261f125..596329ab05a 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -1757,6 +1757,11 @@ Vlastnost nesmí určovat volitelné argumenty, in, out, ParamArray, CallerInfo nebo Quote. + + 'open' declarations must come before all other definitions in type definitions or augmentation + 'open' declarations must come before all other definitions in type definitions or augmentation + + The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 7b8d6567c1c..2416099ef5b 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -1757,6 +1757,11 @@ Ein Merkmal darf keine Argumente für „optional“, „in“, „out“, „ParamArray“", „CallerInfo“ oder „Quote“ angeben. + + 'open' declarations must come before all other definitions in type definitions or augmentation + 'open' declarations must come before all other definitions in type definitions or augmentation + + The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 8a0ac83a342..a56fe3f6c11 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -1757,6 +1757,11 @@ Un rasgo no puede especificar argumentos opcionales, in, out, ParamArray, CallerInfo o Quote + + 'open' declarations must come before all other definitions in type definitions or augmentation + 'open' declarations must come before all other definitions in type definitions or augmentation + + The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 621813988a3..ba13399d5af 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -1757,6 +1757,11 @@ Une caractéristique ne peut pas spécifier d’arguments facultatifs, in, out, ParamArray, CallerInfo ou Quote + + 'open' declarations must come before all other definitions in type definitions or augmentation + 'open' declarations must come before all other definitions in type definitions or augmentation + + The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 76294e7ac7f..f0e97722d7c 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -1757,6 +1757,11 @@ Un tratto non può specificare argomenti optional, in, out, ParamArray, CallerInfo o Quote + + 'open' declarations must come before all other definitions in type definitions or augmentation + 'open' declarations must come before all other definitions in type definitions or augmentation + + The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index cf31f12757e..bd9ae88f972 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -1757,6 +1757,11 @@ 特性では、オプションの、in 引数、out 引数、ParamArray 引数、CallerInfo 引数、または Quote 引数を指定することはできません + + 'open' declarations must come before all other definitions in type definitions or augmentation + 'open' declarations must come before all other definitions in type definitions or augmentation + + The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 70f312b88cd..49ce1993964 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -1757,6 +1757,11 @@ 특성은 optional, in, out, ParamArray, CallerInfo, Quote 인수를 지정할 수 없습니다. + + 'open' declarations must come before all other definitions in type definitions or augmentation + 'open' declarations must come before all other definitions in type definitions or augmentation + + The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 5cb379287e1..67cdf4c2cff 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -1757,6 +1757,11 @@ Cecha nie może określać opcjonalnych argumentów in, out, ParamArray, CallerInfo lub Quote + + 'open' declarations must come before all other definitions in type definitions or augmentation + 'open' declarations must come before all other definitions in type definitions or augmentation + + The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 8f67095285e..decdcf41077 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -1757,6 +1757,11 @@ Uma característica não pode especificar os argumentos optional, in, out, ParamArray, CallerInfo ou Quote + + 'open' declarations must come before all other definitions in type definitions or augmentation + 'open' declarations must come before all other definitions in type definitions or augmentation + + The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 19de2b0d1a9..81f321a1cfd 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -1757,6 +1757,11 @@ Признак не может указывать необязательные аргументы in, out, ParamArray, CallerInfo или Quote + + 'open' declarations must come before all other definitions in type definitions or augmentation + 'open' declarations must come before all other definitions in type definitions or augmentation + + The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index eb357aaa843..2e0afd3f924 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -1757,6 +1757,11 @@ Bir nitelik optional, in, out, ParamArray, CallerInfo veya Quote bağımsız değişkenlerini belirtemiyor + + 'open' declarations must come before all other definitions in type definitions or augmentation + 'open' declarations must come before all other definitions in type definitions or augmentation + + The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 256302b235e..198f32af4b7 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -1757,6 +1757,11 @@ 特征不能指定 option、in、out、ParamArray、CallerInfo 或 Quote 参数 + + 'open' declarations must come before all other definitions in type definitions or augmentation + 'open' declarations must come before all other definitions in type definitions or augmentation + + The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 674e3ee9c45..778f641471b 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -1757,6 +1757,11 @@ 特徵不能指定選擇性、in、out、ParamArray、CallerInfo 或 Quote 引數 + + 'open' declarations must come before all other definitions in type definitions or augmentation + 'open' declarations must come before all other definitions in type definitions or augmentation + + The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. From 22feebfea87b1e9a36f0bd6687372003203436d1 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 5 Aug 2025 23:28:23 +0800 Subject: [PATCH 07/22] test --- .../CheckComputationExpressions.fs | 2 +- src/Compiler/SyntaxTree/LexFilter.fs | 18 +++- .../ImportDeclarations/E_openInTypeDecl.fs | 61 +++++++++++- .../E_openInTypeInterface.fs | 5 + .../ImportDeclarations/E_openModInFun.fs | 24 ----- .../ImportDeclarations/ImportDeclarations.fs | 63 ++++++++++--- .../ImportDeclarations/openInTypeDecl.fs | 51 ++++++++++ .../ImportDeclarations/openModInFun.fs | 93 +++++++++++++++++++ .../tests/UnitTests/UnusedOpensTests.fs | 42 +++++++++ 9 files changed, 313 insertions(+), 46 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeInterface.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openModInFun.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openModInFun.fs diff --git a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs index 5981d68b974..b84d3fb0777 100644 --- a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs @@ -2264,7 +2264,7 @@ let rec TryTranslateComputationExpression | SynExpr.Open(target, m, body) -> let body = TranslateComputationExpressionNoQueryOps ceenv body Some(translatedCtxt (SynExpr.Open(target, m, body))) - + | _ -> None and ConsumeCustomOpClauses diff --git a/src/Compiler/SyntaxTree/LexFilter.fs b/src/Compiler/SyntaxTree/LexFilter.fs index ddb0b589a13..56f89abc069 100644 --- a/src/Compiler/SyntaxTree/LexFilter.fs +++ b/src/Compiler/SyntaxTree/LexFilter.fs @@ -769,8 +769,7 @@ type LexFilterImpl ( | _, [] -> PositionWithColumn(newCtxt.StartPos, -1) // ignore Vanilla because a SeqBlock is always coming - | _, CtxtVanilla _ :: rest - | _, CtxtOpen _ :: rest -> undentationLimit strict rest + | _, CtxtVanilla _ :: rest -> undentationLimit strict rest | CtxtSeqBlock(FirstInSeqBlock, _, _), (CtxtDo _ as limitCtxt) :: CtxtSeqBlock _ :: (CtxtTypeDefns _ | CtxtModuleBody _) :: _ -> PositionWithColumn(limitCtxt.StartPos, limitCtxt.StartCol + 1) @@ -976,7 +975,7 @@ type LexFilterImpl ( // These contexts all require indentation by at least one space - | _, (CtxtInterfaceHead _ | CtxtNamespaceHead _ | CtxtModuleHead _ | CtxtException _ | CtxtModuleBody (_, false) | CtxtIf _ | CtxtWithAsLet _ | CtxtLetDecl _ | CtxtMemberHead _ | CtxtMemberBody _ as limitCtxt :: _) + | _, (CtxtInterfaceHead _ | CtxtNamespaceHead _ | CtxtModuleHead _ | CtxtException _ | CtxtModuleBody (_, false) | CtxtIf _ | CtxtWithAsLet _ | CtxtLetDecl _ | CtxtMemberHead _ | CtxtMemberBody _ | CtxtOpen _ as limitCtxt :: _) -> PositionWithColumn(limitCtxt.StartPos, limitCtxt.StartCol + 1) // These contexts can have their contents exactly aligning @@ -2474,8 +2473,17 @@ type LexFilterImpl ( pushCtxtSeqBlock tokenTup AddBlockEnd returnToken tokenLexbufState token - // The `open type ...` case - | OPEN, _ when peekNextToken().IsTYPE -> + // The `open type ...` case, prevent early inserting OBLOCKEND by `insertComingSoonTokens` + | OPEN, head :: _ when peekNextToken().IsTYPE && + isSameLine() && // `open` and `type` should be on the same line + (match head with // follow the checks in `insertComingSoonTokens` + // open-parens of sorts + | CtxtParen(TokenLExprParen, _) -> true + // seq blocks + | CtxtSeqBlock _ -> true + // vanillas + | CtxtVanilla _ -> true + | _ -> false) -> pushCtxt tokenTup (CtxtOpen tokenStartPos) if debug then dprintf "pushing CtxtOpen at tokenStartPos = %a\n" outputPos tokenStartPos returnToken tokenLexbufState token diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs index 85a71f628f5..1d95c4c623e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs @@ -1,8 +1,63 @@ // #Regression #Conformance #DeclarationElements #Import -//Unexpected keyword 'open' in member definition$ +module openInTypeDecl type Foo() = - let x = 42 + open type System.DateTime + inherit Object() + + [] val mutable x: Int64 + let x = 42 + let timeConstructed = Now.Ticks + do printfn "%d" Int32.MaxValue + static member Now () = DateTime.Now + member val TimeConstructed = timeConstructed with get, set + + member _.M() = + open type System.ArgumentException + Int32.MaxValue + + interface IDisposable with + member this.Dispose (): unit = + raise (NotImplementedException()) + open global.System + +type A = A of int + with + member _.RandomNumber with get() = Random().Next() + open System + +type ARecord = { A : int } + with + member _.RandomNumber with get() = Random().Next() + open System + +exception AException of int + with + member _.RandomNumber with get() = Random().Next() + open System + +type B = A of Int32 + with + open System + +exception BException of Int32 + with + open System + +type BRecord = { A : Int32 } + with + open System + +[] +type ABC = + val a: Int32 + val b: Int32 + new (a) = + open type System.Int32 + { a = a; b = MinValue } open System - let timeConstructed = DateTime.Now.Ticks + +type System.Int32 with + member this.Abs111 = Abs(this) + open type System.Math diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeInterface.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeInterface.fs new file mode 100644 index 00000000000..d55cd3c3eab --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeInterface.fs @@ -0,0 +1,5 @@ +type AAA = + interface System.IDisposable with + open System + member this.Dispose (): unit = + raise (NotImplementedException()) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openModInFun.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openModInFun.fs deleted file mode 100644 index bf3f835744a..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openModInFun.fs +++ /dev/null @@ -1,24 +0,0 @@ -// #Regression #Conformance #DeclarationElements #Import -//Unexpected keyword 'open' in binding\. Expected incomplete structured construct at or before this point or other token\.$ -//Unexpected keyword 'open' in binding$ -//Unexpected keyword 'open' in expression$ - -let f x y = - let result = x + y - Console.WriteLine(result.ToString()) - open System - Console.WriteLine(result.ToString()) - - -let top x y = - let r1 = x + y - let r2 = x * y - let nested x y = - open System - Console.WriteLine(result.ToString()) - nested r1 r2 - -type Foo() = - member public this.PrintHello() = - open System - Console.WriteLine("Hello!") diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs index 449fb5bd9d3..a0ef2ce8430 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs @@ -53,28 +53,65 @@ module ImportDeclarations = (Error 39, Line 34, Col 9, Line 34, Col 10, "The value or constructor 'C' is not defined.") ] - // SOURCE=E_openInTypeDecl.fs SCFLAGS="--test:ErrorRanges" # E_openInTypeDecl.fs - [] - let ``E_openInTypeDecl_fs`` compilation = + // SOURCE=E_openInTypeInterface.fs SCFLAGS="--test:ErrorRanges" # E_openInTypeInterface.fs + [] + let ``E_openInTypeInterface_fs`` compilation = compilation - |> verifyCompile + |> withLangVersionPreview + |> typecheck |> shouldFail |> withDiagnostics [ - (Error 10, Line 7, Col 5, Line 7, Col 9, "Unexpected keyword 'open' in member definition") + (Error 0010, Line 3, Col 5, Line 3, Col 9, "Unexpected keyword 'open' in member definition. Expected 'member', 'override', 'static' or other token.") + (Error 3567, Line 3, Col 17, Line 4, Col 5, "Expecting member body") ] - // SOURCE=E_openModInFun.fs SCFLAGS="--test:ErrorRanges" # E_openModInFun.fs - [] - let ``E_openModInFun_fs`` compilation = + // SOURCE=E_openInTypeDecl.fs SCFLAGS="--test:ErrorRanges" # E_openInTypeDecl.fs + [] + let ``E_openInTypeDecl_fs`` compilation = compilation - |> verifyCompile + |> withLangVersionPreview + |> typecheck |> shouldFail |> withDiagnostics [ - (Error 10, Line 9, Col 5, Line 9, Col 9, "Unexpected keyword 'open' in binding. Expected incomplete structured construct at or before this point or other token.") - (Error 10, Line 17, Col 9, Line 17, Col 13, "Unexpected keyword 'open' in binding") - (Error 10, Line 23, Col 9, Line 23, Col 13, "Unexpected keyword 'open' in expression") - (Error 3567, Line 23, Col 9, Line 23, Col 13, "Expecting member body") + (Error 3879, Line 23, Col 5, Line 23, Col 23, "'open' declarations must come before all other definitions in type definitions or augmentation") + (Error 0039, Line 20, Col 15, Line 20, Col 26, "The type 'IDisposable' is not defined.") + (Error 0039, Line 7, Col 13, Line 7, Col 19, "The type 'Object' is not defined. Maybe you want one of the following: obj") + (Error 0887, Line 20, Col 15, Line 20, Col 26, "The type 'obj' is not an interface type") + (Error 0039, Line 20, Col 15, Line 20, Col 26, "The type 'IDisposable' is not defined.") + (Error 0039, Line 7, Col 13, Line 7, Col 19, "The type 'Object' is not defined. Maybe you want one of the following: obj") + (Error 0039, Line 9, Col 37, Line 9, Col 42, "The type 'Int64' is not defined. Maybe you want one of the following: int64 uint64 int8 int int16") + (Error 0039, Line 20, Col 15, Line 20, Col 26, "The type 'IDisposable' is not defined.") + (Error 0855, Line 21, Col 21, Line 21, Col 28, "No abstract or interface member was found that corresponds to this override") + (Error 0039, Line 7, Col 13, Line 7, Col 19, "The type 'Object' is not defined. Maybe you want one of the following: obj") + (Error 0039, Line 12, Col 21, Line 12, Col 26, "The value, namespace, type or module 'Int32' is not defined. Maybe you want one of the following: int32 uint32 int8 int int16") + (Error 3879, Line 28, Col 9, Line 28, Col 20, "'open' declarations must come before all other definitions in type definitions or augmentation") + (Error 3879, Line 33, Col 9, Line 33, Col 20, "'open' declarations must come before all other definitions in type definitions or augmentation") + (Error 3879, Line 38, Col 9, Line 38, Col 20, "'open' declarations must come before all other definitions in type definitions or augmentation") + (Error 0039, Line 37, Col 44, Line 37, Col 50, "The value or constructor 'Random' is not defined.") + (Error 0039, Line 40, Col 15, Line 40, Col 20, "The type 'Int32' is not defined. Maybe you want one of the following: int32 uint32 int8 int int16") + (Error 0039, Line 40, Col 15, Line 40, Col 20, "The type 'Int32' is not defined. Maybe you want one of the following: int32 uint32 int8 int int16") + (Error 0039, Line 44, Col 25, Line 44, Col 30, "The type 'Int32' is not defined. Maybe you want one of the following: int32 uint32 int8 int int16") + (Error 0039, Line 48, Col 22, Line 48, Col 27, "The type 'Int32' is not defined. Maybe you want one of the following: int32 uint32 int8 int int16") + (Error 0039, Line 48, Col 22, Line 48, Col 27, "The type 'Int32' is not defined. Maybe you want one of the following: int32 uint32 int8 int int16") + (Error 3879, Line 59, Col 5, Line 59, Col 16, "'open' declarations must come before all other definitions in type definitions or augmentation") + (Error 3879, Line 63, Col 5, Line 63, Col 26, "'open' declarations must come before all other definitions in type definitions or augmentation") ] + + // SOURCE=openInTypeDecl.fs # openInTypeDecl.fs + [] + let ``openInTypeDecl_fs`` compilation = + compilation + |> withLangVersionPreview + |> typecheck + |> shouldSucceed + + // SOURCE=openModInFun.fs # openModInFun.fs + [] + let ``openModInFun_fs`` compilation = + compilation + |> withLangVersionPreview + |> typecheck + |> shouldSucceed // SOURCE=OpenNestedModule01.fs # OpenNestedModule01.fs [] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs new file mode 100644 index 00000000000..dcca61fa898 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs @@ -0,0 +1,51 @@ +// #Regression #Conformance #DeclarationElements #Import +module openInTypeDecl + +type Foo() = + open global.System + open type DateTime + + inherit Object() + + [] val mutable x: Int64 + let x = 42 + let timeConstructed = Now.Ticks + do printfn "%d" Int32.MaxValue + static member Now () = DateTime.Now + member val TimeConstructed = timeConstructed with get, set + + member _.M() = + open type System.ArgumentException + Int32.MaxValue + + interface IDisposable with + member this.Dispose (): unit = + raise (NotImplementedException()) + +type A = A of int + with + open System + member _.RandomNumber with get() = Random().Next() + +type ARecord = { A : int } + with + open System + member _.RandomNumber with get() = Random().Next() + +exception AException of int + with + open System + member _.RandomNumber with get() = Random().Next() + +[] +type ABC = + open System + val a: Int32 + val b: Int32 + new (a) = + open type System.Int32 + { a = a; b = MinValue } + +type System.Int32 with + open type System.Math + member this.Abs111 = Abs(this) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openModInFun.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openModInFun.fs new file mode 100644 index 00000000000..7897999147e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openModInFun.fs @@ -0,0 +1,93 @@ +// #Regression #Conformance #DeclarationElements #Import +module openModInFun + +let f x y = + let result = x + y + open System + Console.WriteLine(result.ToString()) + + open type Console + WriteLine(result.ToString()) + +let top x y = + let r1 = x + y + let r2 = x * y + let nested x y = + open System + Console.WriteLine(r1.ToString()) + nested r1 r2 + +type Foo() = + do + open System + open type Console + WriteLine 123 + member public this.PrintHello() = + open System + Console.WriteLine("Hello!") + + +( + open type + System.Console + WriteLine() +) + + +// In `match` +match Some 1 with +| Some 1 when open System; Int32.MinValue < 0 -> + open type System.Console + WriteLine "Is 1" +| _ -> () + +// In `for` +for _ in open System.Linq; Enumerable.Range(0, 10) do + open type System.Console + WriteLine "Hello, World!" + +// In `while` +while + (open type System.Int32 + MaxValue < 0) do + open type System.Console + WriteLine "MaxValue is negative" + +// In `if` +if (open type System.Int32; MaxValue <> MinValue) then + open type System.Console + WriteLine "MaxValue is not equal to MinValue" +elif (open type System.Int32; MaxValue < 0) then + open type System.Console + WriteLine "MaxValue is negative" +else + open type System.Console + WriteLine "MaxValue is positive" + +// In `try` +try + open type System.Int32 + open Checked + MaxValue + 1 +with | exn -> open type System.Console; WriteLine exn.Message; 0 + +// In lambdas +let fun1 = fun x -> open System; x + 1 +let fun2 = function x -> open type System.Int32; x + MinValue + +// In computation expressions +let res = async { + open System + Console.WriteLine("Hello, World!") + let! x = Async.Sleep 1000 + return x +} + +// In `query` +let q = + query { + open type System.Linq.Enumerable + for i in Range(1, 10) do + open type int + yield MinValue + i + } |> Seq.toArray diff --git a/vsintegration/tests/UnitTests/UnusedOpensTests.fs b/vsintegration/tests/UnitTests/UnusedOpensTests.fs index b77d7e257ef..418737fdf84 100644 --- a/vsintegration/tests/UnitTests/UnusedOpensTests.fs +++ b/vsintegration/tests/UnitTests/UnusedOpensTests.fs @@ -851,3 +851,45 @@ printfn "%A" MyModule.Thingy.Thing """ => [6, (10, 25)] + +[] +let ``unused open C# type in expression scoped``() = + """ +let f() = + open type System.Console + printfn "%s" "Hello World" + """ + => [3, (14, 28)] + +[] +let ``unused open C# type in type scoped``() = + """ +type T() = + open type System.Console + do printfn "%s" "Hello World" + """ + => [3, (14, 28)] + + +[] +let ``type-scoped open declaration duplication in module is unused``() = + """ +module TopModule +open System.IO +type T() = + open System.IO + do File.Create "" +""" + => [ 5, (9, 18) ] + + +[] +let ``expression-scoped open declaration duplication in module is unused``() = + """ +module TopModule +open System.IO +let _ = + open System.IO + File.Create "" +""" + => [ 5, (9, 18) ] From c7b056e14c4b34df5c11bc0237dbc47d6d4f1eef Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 5 Aug 2025 23:33:54 +0800 Subject: [PATCH 08/22] release note --- docs/release-notes/.FSharp.Compiler.Service/10.0.100.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md index 70920a02872..89c7a520b46 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md @@ -1,6 +1,7 @@ ### Added * Add opt-in warning attribute not valid for union case with fields [PR #18532](https://github.com/dotnet/fsharp/pull/18532)) * Add support for `when 'T : Enum` library-only static optimization constraint. ([PR #18546](https://github.com/dotnet/fsharp/pull/18546)) +* [RFC-1331] Allow opens in expression/type scoped. ([Suggestion](https://github.com/fsharp/fslang-suggestions/issues/96), [PR #18814](https://github.com/dotnet/fsharp/pull/18814)) ### Fixed From f89cf14b0afda7956f375e106f338a4a9d4857aa Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Wed, 6 Aug 2025 20:55:58 +0800 Subject: [PATCH 09/22] fix tests, add language feature --- src/Compiler/Checking/CheckDeclarations.fs | 12 ++++++++--- .../Checking/Expressions/CheckExpressions.fs | 1 + src/Compiler/FSComp.txt | 3 ++- src/Compiler/Facilities/LanguageFeatures.fs | 3 +++ src/Compiler/Facilities/LanguageFeatures.fsi | 1 + src/Compiler/SyntaxTree/LexFilter.fs | 10 +++++---- src/Compiler/xlf/FSComp.txt.cs.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.de.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.es.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.fr.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.it.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.ja.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.ko.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.pl.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.ru.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.tr.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 +++++ src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 +++++ .../ImportDeclarations/ImportDeclarations.fs | 21 ++++++++----------- .../ImportDeclarations/openInTypeDecl.fs | 2 +- .../ImportDeclarations/openModInFun.fs | 4 ++-- ...y_FSharp.Compiler.Service_Debug_net9.0.bsl | 12 +++++------ ....Compiler.Service_Debug_netstandard2.0.bsl | 14 ++++++------- ...FSharp.Compiler.Service_Release_net9.0.bsl | 12 +++++------ ...ompiler.Service_Release_netstandard2.0.bsl | 14 ++++++------- 26 files changed, 125 insertions(+), 49 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index d73c5d336c2..8efb519d8a9 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -676,7 +676,7 @@ let TcTyconMemberSpecs cenv env containerInfo declKind tpenv augSpfn = let TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) = CheckBasics.TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) -let private buildTcEnvWithTypeScopedOpensApplied cenv parent mFallback synMembers env = +let private buildTcEnvWithTypeScopedOpensApplied (cenv: cenv) parent mFallback synMembers env = // Because 'MemberInfo is not SynMemberDefn list when it is in a signature file, // we need to check the type first match box synMembers with @@ -692,6 +692,8 @@ let private buildTcEnvWithTypeScopedOpensApplied cenv parent mFallback synMember // we can just go through until we hit a non-open declaration let rec loop env = function | SynMemberDefn.Open (target, mOpen) :: rest -> + checkLanguageFeatureAndRecover cenv.g.langVersion LanguageFeature.ExpressionAndTypeScopedOpens mOpen + let env, _openDecl = TcOpenDecl cenv mOpen mParent env target loop env rest | SynMemberDefn.ImplicitCtor _ :: rest -> loop env rest @@ -1095,8 +1097,12 @@ module MutRecBindingChecking = let innerState = (incrCtorInfoOpt, envForTycon, tpenv, recBindIdx, List.rev binds @ uncheckedBindsRev) cbinds, innerState - | Some (SynMemberDefn.Open (target, m)), _ -> [Phase2AOpen (target, m)], innerState - + | Some (SynMemberDefn.Open (target, m)), _ -> + if cenv.g.langVersion.SupportsFeature(LanguageFeature.ExpressionAndTypeScopedOpens) then + [Phase2AOpen (target, m)], innerState + else + [], innerState + | definition -> error(InternalError(sprintf "Unexpected definition %A" definition, m))) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 057ad68a80f..e48153abeec 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -6092,6 +6092,7 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE error(Error(FSComp.SR.tcInvalidIndexerExpression(), m)) | SynExpr.Open (target, m, body) -> + checkLanguageFeatureAndRecover g.langVersion LanguageFeature.ExpressionAndTypeScopedOpens m let env, _openDecls = TcOpenDecl cenv m body.Range env target TcLinearExprs (TcExprThatCanBeCtorBody cenv) cenv env overallTy tpenv false body id diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index f591bbbe615..efe2953b454 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1808,4 +1808,5 @@ featureAllowLetOrUseBangTypeAnnotationWithoutParens,"Allow let! and use! type an 3876,lexWarnDirectivesMustMatch,"There is another %s for this warning already in line %d." 3877,lexLineDirectiveMappingIsNotUnique,"The file '%s' was also pointed to in a line directive in '%s'. Proper warn directive application may not be possible." 3878,tcAttributeIsNotValidForUnionCaseWithFields,"This attribute is not valid for use on union cases with fields." -3879,tcTypeDefinitionsMustHaveOpensBeforeOtherMembers,"'open' declarations must come before all other definitions in type definitions or augmentation" \ No newline at end of file +3879,tcTypeDefinitionsMustHaveOpensBeforeOtherMembers,"'open' declarations must come before all other definitions in type definitions or augmentation" +featureExpressionAndTypeScopedOpens,"'open' declarations in expression or type scopes" \ No newline at end of file diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index a3a9a3855aa..26d40af4b4f 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -103,6 +103,7 @@ type LanguageFeature = | BetterAnonymousRecordParsing | ScopedNowarn | AllowTypedLetUseAndBang + | ExpressionAndTypeScopedOpens /// LanguageVersion management type LanguageVersion(versionText) = @@ -241,6 +242,7 @@ type LanguageVersion(versionText) = // F# preview (still preview in 10.0) LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work + LanguageFeature.ExpressionAndTypeScopedOpens, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -409,6 +411,7 @@ type LanguageVersion(versionText) = | LanguageFeature.BetterAnonymousRecordParsing -> FSComp.SR.featureBetterAnonymousRecordParsing () | LanguageFeature.ScopedNowarn -> FSComp.SR.featureScopedNowarn () | LanguageFeature.AllowTypedLetUseAndBang -> FSComp.SR.featureAllowLetOrUseBangTypeAnnotationWithoutParens () + | LanguageFeature.ExpressionAndTypeScopedOpens -> FSComp.SR.featureExpressionAndTypeScopedOpens () /// 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 f034979a6d3..aa5fcfe8161 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -94,6 +94,7 @@ type LanguageFeature = | BetterAnonymousRecordParsing | ScopedNowarn | AllowTypedLetUseAndBang + | ExpressionAndTypeScopedOpens /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/SyntaxTree/LexFilter.fs b/src/Compiler/SyntaxTree/LexFilter.fs index 156c16d58a6..030e327f403 100644 --- a/src/Compiler/SyntaxTree/LexFilter.fs +++ b/src/Compiler/SyntaxTree/LexFilter.fs @@ -2473,10 +2473,12 @@ type LexFilterImpl ( pushCtxtSeqBlock tokenTup AddBlockEnd returnToken tokenLexbufState token - // The `open type ...` case, prevent early inserting OBLOCKEND by `insertComingSoonTokens` + // The expression/type-scoped `open type ...` case, + // prevent early inserting OBLOCKEND by `insertComingSoonTokens` | OPEN, head :: _ when peekNextToken().IsTYPE && - isSameLine() && // `open` and `type` should be on the same line - (match head with // follow the checks in `insertComingSoonTokens` + isSameLine() && // `open` and `type` should be on the same line. If them can be on different lines, + // the `type` keyword can have same indentation as `open`. + (match head with // Follow the checks in `insertComingSoonTokens` // open-parens of sorts | CtxtParen(TokenLExprParen, _) -> true // seq blocks @@ -2488,7 +2490,7 @@ type LexFilterImpl ( if debug then dprintf "pushing CtxtOpen at tokenStartPos = %a\n" outputPos tokenStartPos returnToken tokenLexbufState token - // The `open type ...` case + // The expression/type-scoped `open type ...` case | TYPE, CtxtOpen _ :: _ -> if debug then dprintf "--> because TYPE is coming, popping CtxtOpen\n" popCtxt() diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index c56fe4bd559..4818ac27052 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -412,6 +412,11 @@ více typů podporuje měrné jednotky + + 'open' declarations in expression or type scopes + 'open' declarations in expression or type scopes + + extended fixed bindings for byref and GetPinnableReference rozšířené pevné vazby pro byref a GetPinnableReference diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 68cecdc7d68..2c8547c6bb9 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -412,6 +412,11 @@ Maßeinheitenunterstützung durch weitere Typen + + 'open' declarations in expression or type scopes + 'open' declarations in expression or type scopes + + extended fixed bindings for byref and GetPinnableReference Erweiterte feste Bindungen für byref und GetPinnableReference diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 5c55b0743d5..20f0919770c 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -412,6 +412,11 @@ más tipos admiten las unidades de medida + + 'open' declarations in expression or type scopes + 'open' declarations in expression or type scopes + + extended fixed bindings for byref and GetPinnableReference enlaces fijos extendidos para byref y GetPinnableReference diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 950d51b0ae8..a9637b85c16 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -412,6 +412,11 @@ d'autres types prennent en charge les unités de mesure + + 'open' declarations in expression or type scopes + 'open' declarations in expression or type scopes + + extended fixed bindings for byref and GetPinnableReference liaisons fixes étendues pour byref et GetPinnableReference diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 7f72d531f00..b9727b76095 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -412,6 +412,11 @@ più tipi supportano le unità di misura + + 'open' declarations in expression or type scopes + 'open' declarations in expression or type scopes + + extended fixed bindings for byref and GetPinnableReference binding fissi estesi per byref e GetPinnableReference diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 91162282610..dc45e75829f 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -412,6 +412,11 @@ 単位をサポートするその他の型 + + 'open' declarations in expression or type scopes + 'open' declarations in expression or type scopes + + extended fixed bindings for byref and GetPinnableReference byref と GetPinnableReference の拡張固定バインド diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 5d2259e8b9d..5672e1aeb3d 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -412,6 +412,11 @@ 더 많은 형식이 측정 단위를 지원함 + + 'open' declarations in expression or type scopes + 'open' declarations in expression or type scopes + + extended fixed bindings for byref and GetPinnableReference byref 및 GetPinnableReference에 대한 확장된 고정 바인딩 diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index c8c9024bdd3..227ab33fe96 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -412,6 +412,11 @@ więcej typów obsługuje jednostki miary + + 'open' declarations in expression or type scopes + 'open' declarations in expression or type scopes + + extended fixed bindings for byref and GetPinnableReference rozszerzone powiązania stałe dla elementów byref i GetPinnableReference diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 0bc99e149ec..c070ad1b7cf 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -412,6 +412,11 @@ mais tipos dão suporte para unidades de medida + + 'open' declarations in expression or type scopes + 'open' declarations in expression or type scopes + + extended fixed bindings for byref and GetPinnableReference associações fixas estendidas para byref e GetPinnableReference diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 2be33142c4a..5d74fddae20 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -412,6 +412,11 @@ другие типы поддерживают единицы измерения + + 'open' declarations in expression or type scopes + 'open' declarations in expression or type scopes + + extended fixed bindings for byref and GetPinnableReference расширенные фиксированные привязки для byref и GetPinnableReference diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 0787c29f9b3..b15721a8f02 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -412,6 +412,11 @@ tür daha ölçü birimlerini destekler + + 'open' declarations in expression or type scopes + 'open' declarations in expression or type scopes + + extended fixed bindings for byref and GetPinnableReference byref ve GetPinnableReference için genişletilmiş sabit bağlamalar diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index caaafc6d232..d4045373d5e 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -412,6 +412,11 @@ 更多类型支持度量单位 + + 'open' declarations in expression or type scopes + 'open' declarations in expression or type scopes + + extended fixed bindings for byref and GetPinnableReference byref 和 GetPinnableReference 的扩展固定绑定 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index d0abee10ea6..29d2644598b 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -412,6 +412,11 @@ 更多支援測量單位的類型 + + 'open' declarations in expression or type scopes + 'open' declarations in expression or type scopes + + extended fixed bindings for byref and GetPinnableReference ByRef 和 GetPinnableReference 的擴充固定繫結 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs index a0ef2ce8430..fe4b92e228a 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs @@ -75,24 +75,20 @@ module ImportDeclarations = |> withDiagnostics [ (Error 3879, Line 23, Col 5, Line 23, Col 23, "'open' declarations must come before all other definitions in type definitions or augmentation") (Error 0039, Line 20, Col 15, Line 20, Col 26, "The type 'IDisposable' is not defined.") - (Error 0039, Line 7, Col 13, Line 7, Col 19, "The type 'Object' is not defined. Maybe you want one of the following: obj") + (Error 0039, Line 7, Col 13, Line 7, Col 19, "The type 'Object' is not defined. Maybe you want one of the following:\n obj") (Error 0887, Line 20, Col 15, Line 20, Col 26, "The type 'obj' is not an interface type") - (Error 0039, Line 20, Col 15, Line 20, Col 26, "The type 'IDisposable' is not defined.") - (Error 0039, Line 7, Col 13, Line 7, Col 19, "The type 'Object' is not defined. Maybe you want one of the following: obj") - (Error 0039, Line 9, Col 37, Line 9, Col 42, "The type 'Int64' is not defined. Maybe you want one of the following: int64 uint64 int8 int int16") - (Error 0039, Line 20, Col 15, Line 20, Col 26, "The type 'IDisposable' is not defined.") + (Error 0039, Line 9, Col 37, Line 9, Col 42, "The type 'Int64' is not defined. Maybe you want one of the following:\n int64\n uint64\n int8\n int\n int16") (Error 0855, Line 21, Col 21, Line 21, Col 28, "No abstract or interface member was found that corresponds to this override") - (Error 0039, Line 7, Col 13, Line 7, Col 19, "The type 'Object' is not defined. Maybe you want one of the following: obj") - (Error 0039, Line 12, Col 21, Line 12, Col 26, "The value, namespace, type or module 'Int32' is not defined. Maybe you want one of the following: int32 uint32 int8 int int16") + (Error 0039, Line 12, Col 21, Line 12, Col 26, "The value, namespace, type or module 'Int32' is not defined. Maybe you want one of the following:\n int32\n uint32\n int8\n int\n int16") (Error 3879, Line 28, Col 9, Line 28, Col 20, "'open' declarations must come before all other definitions in type definitions or augmentation") (Error 3879, Line 33, Col 9, Line 33, Col 20, "'open' declarations must come before all other definitions in type definitions or augmentation") (Error 3879, Line 38, Col 9, Line 38, Col 20, "'open' declarations must come before all other definitions in type definitions or augmentation") (Error 0039, Line 37, Col 44, Line 37, Col 50, "The value or constructor 'Random' is not defined.") - (Error 0039, Line 40, Col 15, Line 40, Col 20, "The type 'Int32' is not defined. Maybe you want one of the following: int32 uint32 int8 int int16") - (Error 0039, Line 40, Col 15, Line 40, Col 20, "The type 'Int32' is not defined. Maybe you want one of the following: int32 uint32 int8 int int16") - (Error 0039, Line 44, Col 25, Line 44, Col 30, "The type 'Int32' is not defined. Maybe you want one of the following: int32 uint32 int8 int int16") - (Error 0039, Line 48, Col 22, Line 48, Col 27, "The type 'Int32' is not defined. Maybe you want one of the following: int32 uint32 int8 int int16") - (Error 0039, Line 48, Col 22, Line 48, Col 27, "The type 'Int32' is not defined. Maybe you want one of the following: int32 uint32 int8 int int16") + (Error 0039, Line 40, Col 15, Line 40, Col 20, "The type 'Int32' is not defined. Maybe you want one of the following:\n int32\n uint32\n int8\n int\n int16") + (Warning 1178, Line 40, Col 6, Line 40, Col 7, "The struct, record or union type 'B' is not structurally comparable because the type 'obj' does not satisfy the 'comparison' constraint. Consider adding the 'NoComparison' attribute to the type 'B' to clarify that the type is not comparable") + (Error 0039, Line 44, Col 25, Line 44, Col 30, "The type 'Int32' is not defined. Maybe you want one of the following:\n int32\n uint32\n int8\n int\n int16") + (Error 0039, Line 48, Col 22, Line 48, Col 27, "The type 'Int32' is not defined. Maybe you want one of the following:\n int32\n uint32\n int8\n int\n int16") + (Warning 1178, Line 48, Col 6, Line 48, Col 13, "The struct, record or union type 'BRecord' is not structurally comparable because the type 'obj' does not satisfy the 'comparison' constraint. Consider adding the 'NoComparison' attribute to the type 'BRecord' to clarify that the type is not comparable") (Error 3879, Line 59, Col 5, Line 59, Col 16, "'open' declarations must come before all other definitions in type definitions or augmentation") (Error 3879, Line 63, Col 5, Line 63, Col 26, "'open' declarations must come before all other definitions in type definitions or augmentation") ] @@ -101,6 +97,7 @@ module ImportDeclarations = [] let ``openInTypeDecl_fs`` compilation = compilation + |> withOptions ["--nowarn:52"] |> withLangVersionPreview |> typecheck |> shouldSucceed diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs index dcca61fa898..4740d2d30f3 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs @@ -9,7 +9,7 @@ type Foo() = [] val mutable x: Int64 let x = 42 - let timeConstructed = Now.Ticks + let timeConstructed = Now.TemporarilySuspendReportingTypecheckResultsToSink do printfn "%d" Int32.MaxValue static member Now () = DateTime.Now member val TimeConstructed = timeConstructed with get, set diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openModInFun.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openModInFun.fs index 7897999147e..38e95c7ded1 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openModInFun.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openModInFun.fs @@ -68,8 +68,8 @@ else try open type System.Int32 open Checked - MaxValue + 1 -with | exn -> open type System.Console; WriteLine exn.Message; 0 + ignore(MaxValue + 1) +with | exn -> open type System.Console; WriteLine exn.Message // In lambdas let fun1 = fun x -> open System; x + 1 diff --git a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_net9.0.bsl b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_net9.0.bsl index 6e1f6ab941b..d8ce72282ec 100644 --- a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_net9.0.bsl +++ b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_net9.0.bsl @@ -21,14 +21,14 @@ [IL]: Error [StackUnexpected]: : FSharp.Compiler.CodeAnalysis.Hosted.CompilerHelpers::fscCompile([FSharp.Compiler.Service]FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver, string, string[])][offset 0x00000082][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CodeAnalysis.Hosted.CompilerHelpers::fscCompile([FSharp.Compiler.Service]FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver, string, string[])][offset 0x0000008B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+MagicAssemblyResolution::ResolveAssemblyCore([FSharp.Compiler.Service]Internal.Utilities.Library.CompilationThreadToken, [FSharp.Compiler.Service]FSharp.Compiler.Text.Range, [FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, [FSharp.Compiler.Service]FSharp.Compiler.CompilerImports+TcImports, [FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiDynamicCompiler, [FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiConsoleOutput, string)][offset 0x00000015][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+clo@3499-813::Invoke([S.P.CoreLib]System.Tuple`3)][offset 0x000001E5][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+clo@3499-816::Invoke([S.P.CoreLib]System.Tuple`3)][offset 0x000001E5][found Char] Unexpected type on the stack. [IL]: Error [UnmanagedPointer]: : FSharp.Compiler.Interactive.Shell+Utilities+pointerToNativeInt@106::Invoke(object)][offset 0x00000007] Unmanaged pointers are not a verifiable type. [IL]: Error [StackUnexpected]: : .$FSharpCheckerResults+dataTipOfReferences@2225::Invoke([FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x00000084][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-515::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000032][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-515::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000003B][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-515::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000082][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-515::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000008B][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-515::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000094][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-518::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000032][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-518::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000003B][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-518::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000082][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-518::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000008B][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-518::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000094][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.StaticLinking+TypeForwarding::followTypeForwardForILTypeRef([FSharp.Compiler.Service]FSharp.Compiler.AbstractIL.IL+ILTypeRef)][offset 0x00000010][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::getCompilerOption([FSharp.Compiler.Service]FSharp.Compiler.CompilerOptions+CompilerOption, [FSharp.Core]Microsoft.FSharp.Core.FSharpOption`1)][offset 0x000000E6][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CompilerOptions::AddPathMapping([FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, string)][offset 0x0000000B][found Char] Unexpected type on the stack. diff --git a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_netstandard2.0.bsl b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_netstandard2.0.bsl index 616742054b4..acd82273ad3 100644 --- a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_netstandard2.0.bsl +++ b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_netstandard2.0.bsl @@ -28,18 +28,18 @@ [IL]: Error [StackUnexpected]: : FSharp.Compiler.CodeAnalysis.Hosted.CompilerHelpers::fscCompile([FSharp.Compiler.Service]FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver, string, string[])][offset 0x0000008B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+FsiStdinSyphon::GetLine(string, int32)][offset 0x00000039][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+MagicAssemblyResolution::ResolveAssemblyCore([FSharp.Compiler.Service]Internal.Utilities.Library.CompilationThreadToken, [FSharp.Compiler.Service]FSharp.Compiler.Text.Range, [FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, [FSharp.Compiler.Service]FSharp.Compiler.CompilerImports+TcImports, [FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiDynamicCompiler, [FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiConsoleOutput, string)][offset 0x00000015][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+clo@3499-813::Invoke([S.P.CoreLib]System.Tuple`3)][offset 0x000001E5][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+clo@3499-816::Invoke([S.P.CoreLib]System.Tuple`3)][offset 0x000001E5][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+FsiInteractionProcessor::CompletionsForPartialLID([FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiDynamicCompilerState, string)][offset 0x0000001B][found Char] Unexpected type on the stack. [IL]: Error [UnmanagedPointer]: : FSharp.Compiler.Interactive.Shell+Utilities+pointerToNativeInt@106::Invoke(object)][offset 0x00000007] Unmanaged pointers are not a verifiable type. [IL]: Error [StackUnexpected]: : .$FSharpCheckerResults+dataTipOfReferences@2225::Invoke([FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x00000084][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.AssemblyContent+traverseMemberFunctionAndValues@176::Invoke([FSharp.Compiler.Service]FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue)][offset 0x00000059][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.AssemblyContent+traverseEntity@218::GenerateNext([S.P.CoreLib]System.Collections.Generic.IEnumerable`1&)][offset 0x000000DA][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.ParsedInput+visitor@1431-6::VisitExpr([FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, [FSharp.Compiler.Service]FSharp.Compiler.Syntax.SynExpr)][offset 0x00000605][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-515::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000032][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-515::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000003B][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-515::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000082][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-515::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000008B][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-515::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000094][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.ParsedInput+visitor@1450-6::VisitExpr([FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, [FSharp.Compiler.Service]FSharp.Compiler.Syntax.SynExpr)][offset 0x0000060D][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-518::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000032][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-518::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000003B][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-518::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000082][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-518::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000008B][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-518::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000094][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : .$Symbols+fullName@2498-1::Invoke([FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x00000015][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CreateILModule+MainModuleBuilder::ConvertProductVersionToILVersionInfo(string)][offset 0x00000011][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.StaticLinking+TypeForwarding::followTypeForwardForILTypeRef([FSharp.Compiler.Service]FSharp.Compiler.AbstractIL.IL+ILTypeRef)][offset 0x00000010][found Char] Unexpected type on the stack. diff --git a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_net9.0.bsl b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_net9.0.bsl index c8ec600ff30..9b2d883696c 100644 --- a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_net9.0.bsl +++ b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_net9.0.bsl @@ -21,13 +21,13 @@ [IL]: Error [StackUnexpected]: : FSharp.Compiler.CodeAnalysis.Hosted.CompilerHelpers::fscCompile([FSharp.Compiler.Service]FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver, string, string[])][offset 0x00000082][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.CodeAnalysis.Hosted.CompilerHelpers::fscCompile([FSharp.Compiler.Service]FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver, string, string[])][offset 0x0000008B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+MagicAssemblyResolution::ResolveAssemblyCore([FSharp.Compiler.Service]Internal.Utilities.Library.CompilationThreadToken, [FSharp.Compiler.Service]FSharp.Compiler.Text.Range, [FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, [FSharp.Compiler.Service]FSharp.Compiler.CompilerImports+TcImports, [FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiDynamicCompiler, [FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiConsoleOutput, string)][offset 0x00000015][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+clo@3499-851::Invoke([S.P.CoreLib]System.Tuple`3)][offset 0x000001C7][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+clo@3499-854::Invoke([S.P.CoreLib]System.Tuple`3)][offset 0x000001C7][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : .$FSharpCheckerResults+GetReferenceResolutionStructuredToolTipText@2225::Invoke([FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x00000076][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-530::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000032][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-530::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000003B][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-530::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000064][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-530::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000006D][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-530::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000076][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-533::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000032][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-533::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000003B][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-533::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000064][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-533::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000006D][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-533::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000076][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Driver+ProcessCommandLineFlags@286-1::Invoke(string)][offset 0x0000000B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Driver+ProcessCommandLineFlags@286-1::Invoke(string)][offset 0x00000014][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.StaticLinking+TypeForwarding::followTypeForwardForILTypeRef([FSharp.Compiler.Service]FSharp.Compiler.AbstractIL.IL+ILTypeRef)][offset 0x00000010][found Char] Unexpected type on the stack. diff --git a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_netstandard2.0.bsl b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_netstandard2.0.bsl index c7871e0fe77..5d99ca98902 100644 --- a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_netstandard2.0.bsl +++ b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_netstandard2.0.bsl @@ -28,17 +28,17 @@ [IL]: Error [StackUnexpected]: : FSharp.Compiler.CodeAnalysis.Hosted.CompilerHelpers::fscCompile([FSharp.Compiler.Service]FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver, string, string[])][offset 0x0000008B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+FsiStdinSyphon::GetLine(string, int32)][offset 0x00000032][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+MagicAssemblyResolution::ResolveAssemblyCore([FSharp.Compiler.Service]Internal.Utilities.Library.CompilationThreadToken, [FSharp.Compiler.Service]FSharp.Compiler.Text.Range, [FSharp.Compiler.Service]FSharp.Compiler.CompilerConfig+TcConfigBuilder, [FSharp.Compiler.Service]FSharp.Compiler.CompilerImports+TcImports, [FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiDynamicCompiler, [FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiConsoleOutput, string)][offset 0x00000015][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+clo@3499-851::Invoke([S.P.CoreLib]System.Tuple`3)][offset 0x000001C7][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+clo@3499-854::Invoke([S.P.CoreLib]System.Tuple`3)][offset 0x000001C7][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Interactive.Shell+FsiInteractionProcessor::CompletionsForPartialLID([FSharp.Compiler.Service]FSharp.Compiler.Interactive.Shell+FsiDynamicCompilerState, string)][offset 0x00000024][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : .$FSharpCheckerResults+GetReferenceResolutionStructuredToolTipText@2225::Invoke([FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x00000076][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.AssemblyContent+traverseMemberFunctionAndValues@176::Invoke([FSharp.Compiler.Service]FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue)][offset 0x0000002B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.AssemblyContent+traverseEntity@218::GenerateNext([S.P.CoreLib]System.Collections.Generic.IEnumerable`1&)][offset 0x000000BB][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.ParsedInput+visitor@1431-11::VisitExpr([FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, [FSharp.Compiler.Service]FSharp.Compiler.Syntax.SynExpr)][offset 0x00000620][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-530::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000032][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-530::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000003B][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-530::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000064][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-530::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000006D][found Char] Unexpected type on the stack. -[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-530::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000076][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.ParsedInput+visitor@1450-11::VisitExpr([FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, [FSharp.Compiler.Service]FSharp.Compiler.Syntax.SynExpr)][offset 0x00000628][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-533::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000032][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-533::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000003B][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-533::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000064][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-533::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x0000006D][found Char] Unexpected type on the stack. +[IL]: Error [StackUnexpected]: : .$ServiceLexing+clo@924-533::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Core.Unit>)][offset 0x00000076][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : .$Symbols+fullName@2498-3::Invoke([FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x00000030][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Driver+ProcessCommandLineFlags@286-1::Invoke(string)][offset 0x0000000B][found Char] Unexpected type on the stack. [IL]: Error [StackUnexpected]: : FSharp.Compiler.Driver+ProcessCommandLineFlags@286-1::Invoke(string)][offset 0x00000014][found Char] Unexpected type on the stack. From bd1965f7c1433858e0080297293c2015805ae37f Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Wed, 6 Aug 2025 22:36:45 +0800 Subject: [PATCH 10/22] fix test --- .../ImportDeclarations/openInTypeDecl.fs | 2 +- ...iler.Service.SurfaceArea.netstandard20.release.bsl | 11 +++++++++++ .../AddMissingEqualsToTypeDefinitionTests.fs | 1 - 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs index 4740d2d30f3..dcca61fa898 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs @@ -9,7 +9,7 @@ type Foo() = [] val mutable x: Int64 let x = 42 - let timeConstructed = Now.TemporarilySuspendReportingTypecheckResultsToSink + let timeConstructed = Now.Ticks do printfn "%d" Int32.MaxValue static member Now () = DateTime.Now member val TimeConstructed = timeConstructed with get, set diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 79894ad0ccc..b15a41f2b82 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -7351,6 +7351,12 @@ FSharp.Compiler.Syntax.SynExpr+ObjExpr: Microsoft.FSharp.Core.FSharpOption`1[FSh FSharp.Compiler.Syntax.SynExpr+ObjExpr: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] withKeyword FSharp.Compiler.Syntax.SynExpr+ObjExpr: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[FSharp.Compiler.Syntax.SynExpr,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident]]] argOptions FSharp.Compiler.Syntax.SynExpr+ObjExpr: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[FSharp.Compiler.Syntax.SynExpr,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident]]] get_argOptions() +FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Syntax.SynExpr body +FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Syntax.SynExpr get_body() +FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Syntax.SynOpenDeclTarget get_target() +FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Syntax.SynOpenDeclTarget target +FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Text.Range get_range() +FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynExpr+Paren: FSharp.Compiler.Syntax.SynExpr expr FSharp.Compiler.Syntax.SynExpr+Paren: FSharp.Compiler.Syntax.SynExpr get_expr() FSharp.Compiler.Syntax.SynExpr+Paren: FSharp.Compiler.Text.Range get_leftParenRange() @@ -7456,6 +7462,7 @@ FSharp.Compiler.Syntax.SynExpr+Tags: Int32 NamedIndexedPropertySet FSharp.Compiler.Syntax.SynExpr+Tags: Int32 New FSharp.Compiler.Syntax.SynExpr+Tags: Int32 Null FSharp.Compiler.Syntax.SynExpr+Tags: Int32 ObjExpr +FSharp.Compiler.Syntax.SynExpr+Tags: Int32 Open FSharp.Compiler.Syntax.SynExpr+Tags: Int32 Paren FSharp.Compiler.Syntax.SynExpr+Tags: Int32 Quote FSharp.Compiler.Syntax.SynExpr+Tags: Int32 Record @@ -7635,6 +7642,7 @@ FSharp.Compiler.Syntax.SynExpr: Boolean IsNamedIndexedPropertySet FSharp.Compiler.Syntax.SynExpr: Boolean IsNew FSharp.Compiler.Syntax.SynExpr: Boolean IsNull FSharp.Compiler.Syntax.SynExpr: Boolean IsObjExpr +FSharp.Compiler.Syntax.SynExpr: Boolean IsOpen FSharp.Compiler.Syntax.SynExpr: Boolean IsParen FSharp.Compiler.Syntax.SynExpr: Boolean IsQuote FSharp.Compiler.Syntax.SynExpr: Boolean IsRecord @@ -7706,6 +7714,7 @@ FSharp.Compiler.Syntax.SynExpr: Boolean get_IsNamedIndexedPropertySet() FSharp.Compiler.Syntax.SynExpr: Boolean get_IsNew() FSharp.Compiler.Syntax.SynExpr: Boolean get_IsNull() FSharp.Compiler.Syntax.SynExpr: Boolean get_IsObjExpr() +FSharp.Compiler.Syntax.SynExpr: Boolean get_IsOpen() FSharp.Compiler.Syntax.SynExpr: Boolean get_IsParen() FSharp.Compiler.Syntax.SynExpr: Boolean get_IsQuote() FSharp.Compiler.Syntax.SynExpr: Boolean get_IsRecord() @@ -7776,6 +7785,7 @@ FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewNamedIndexedPr FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewNew(Boolean, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewNull(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewObjExpr(FSharp.Compiler.Syntax.SynType, Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[FSharp.Compiler.Syntax.SynExpr,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident]]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynBinding], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynMemberDefn], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynInterfaceImpl], FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewOpen(FSharp.Compiler.Syntax.SynOpenDeclTarget, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewParen(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewQuote(FSharp.Compiler.Syntax.SynExpr, Boolean, FSharp.Compiler.Syntax.SynExpr, Boolean, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewRecord(Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`5[FSharp.Compiler.Syntax.SynType,FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Text.Range,Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[FSharp.Compiler.Text.Range,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Position]]],FSharp.Compiler.Text.Range]], Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[FSharp.Compiler.Syntax.SynExpr,System.Tuple`2[FSharp.Compiler.Text.Range,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Position]]]], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynExprRecordField], FSharp.Compiler.Text.Range) @@ -7846,6 +7856,7 @@ FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+NamedIndexedPrope FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+New FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+Null FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+ObjExpr +FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+Open FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+Paren FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+Quote FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr+Record diff --git a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingEqualsToTypeDefinitionTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingEqualsToTypeDefinitionTests.fs index c81dbe99611..ee758c93768 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingEqualsToTypeDefinitionTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingEqualsToTypeDefinitionTests.fs @@ -52,7 +52,6 @@ type Name = Name of string Assert.Equal(expected, actual) [] -[] [ Date: Wed, 6 Aug 2025 23:15:51 +0800 Subject: [PATCH 11/22] fix test --- .../ImportDeclarations/ImportDeclarations.fs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs index fe4b92e228a..47ab90c06e1 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs @@ -69,6 +69,7 @@ module ImportDeclarations = [] let ``E_openInTypeDecl_fs`` compilation = compilation + |> withOptions ["--nowarn:52"] // The value has been copied to ensure the original is not mutated by this operation or because the copy is implicit when returning a struct from a member and another member is then accessed |> withLangVersionPreview |> typecheck |> shouldFail @@ -97,7 +98,7 @@ module ImportDeclarations = [] let ``openInTypeDecl_fs`` compilation = compilation - |> withOptions ["--nowarn:52"] + |> withOptions ["--nowarn:52"] // The value has been copied to ensure the original is not mutated by this operation or because the copy is implicit when returning a struct from a member and another member is then accessed |> withLangVersionPreview |> typecheck |> shouldSucceed From a9b1d09794f4bc69390fdf6bd9445e460a2da0e1 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Thu, 7 Aug 2025 07:50:06 +0800 Subject: [PATCH 12/22] test --- .../.FSharp.Compiler.Service/10.0.100.md | 2 +- docs/release-notes/.Language/preview.md | 1 + src/Compiler/Service/ServiceAnalysis.fs | 1 + .../ImportDeclarations/E_openInTypeDecl.fs | 8 + .../ImportDeclarations/ImportDeclarations.fs | 1 + .../OpenDeclaration/E_openInTypeDecl.fs | 63 ++ .../OpenDeclaration/E_openInTypeDecl.fs.bsl | 677 ++++++++++++++ .../OpenInObjExprOrInterface.fs | 9 + .../OpenInObjExprOrInterface.fs.bsl | 99 ++ .../OpenDeclaration/OpenInTypeWithWrongPos.fs | 11 + .../OpenInTypeWithWrongPos.fs.bsl | 13 + .../OpenDeclaration/OpenTypeNotOnSameLine.fs | 2 + .../OpenTypeNotOnSameLine.fs.bsl | 17 + .../OpenDeclaration/OpenTypeNotOnSameLine2.fs | 2 + .../OpenTypeNotOnSameLine2.fs.bsl | 16 + .../OpenDeclaration/OpenTypeOnSameIndent.fs | 2 + .../OpenTypeOnSameIndent.fs.bsl | 25 + .../OpenDeclaration/OpenTypeOnSameIndent2.fs | 2 + .../OpenTypeOnSameIndent2.fs.bsl | 18 + .../OpenDeclaration/openInTypeDecl.fs | 51 ++ .../OpenDeclaration/openInTypeDecl.fs.bsl | 604 +++++++++++++ .../OpenDeclaration/openModInFun.fs | 93 ++ .../OpenDeclaration/openModInFun.fs.bsl | 843 ++++++++++++++++++ .../AddMissingEqualsToTypeDefinitionTests.fs | 2 + .../Tests.LanguageService.ParameterInfo.fs | 2 +- 25 files changed, 2562 insertions(+), 2 deletions(-) create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine2.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine2.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent2.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent2.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs.bsl diff --git a/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md index c4846732f42..b149c92a7d4 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md @@ -3,7 +3,7 @@ * Add support for `when 'T : Enum` library-only static optimization constraint. ([PR #18546](https://github.com/dotnet/fsharp/pull/18546)) * Add support for tail calls in computation expressions ([PR #18804](https://github.com/dotnet/fsharp/pull/18804)) * Add `--typecheck-only` flag support for F# Interactive (FSI) scripts to type-check without execution. ([Issue #18686](https://github.com/dotnet/fsharp/issues/18686)) -* [RFC-1331] Allow opens in expression/type scoped. ([Suggestion](https://github.com/fsharp/fslang-suggestions/issues/96), [PR #18814](https://github.com/dotnet/fsharp/pull/18814)) +* Allow opens in expression/type scoped. ([Suggestion](https://github.com/fsharp/fslang-suggestions/issues/96), [PR #18814](https://github.com/dotnet/fsharp/pull/18814)) ### Fixed diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md index b9afee7582e..55d9310a6a5 100644 --- a/docs/release-notes/.Language/preview.md +++ b/docs/release-notes/.Language/preview.md @@ -11,6 +11,7 @@ * Allow `let!`, `use!`, `and!` type annotations without requiring parentheses (([PR #18508](https://github.com/dotnet/fsharp/pull/18508) and [PR #18682](https://github.com/dotnet/fsharp/pull/18682))) * Exception names are now validated for illegal characters using the same mechanism as types/modules/namespaces ([Issue #18763](https://github.com/dotnet/fsharp/issues/18763)) * Support tail calls in computation expressions ([PR #18804](https://github.com/dotnet/fsharp/pull/18804)) +* Allow opens in expression/type scoped. ([Suggestion](https://github.com/fsharp/fslang-suggestions/issues/96), [PR #18814](https://github.com/dotnet/fsharp/pull/18814)) ### Fixed diff --git a/src/Compiler/Service/ServiceAnalysis.fs b/src/Compiler/Service/ServiceAnalysis.fs index 6455d9f0ff3..a4b0d9d2709 100644 --- a/src/Compiler/Service/ServiceAnalysis.fs +++ b/src/Compiler/Service/ServiceAnalysis.fs @@ -118,6 +118,7 @@ module UnusedOpens = AppliedScope = openDecl.AppliedScope } | _ -> None) + |> Array.sortBy (fun openStmt -> openStmt.Range.StartLine) /// Only consider symbol uses which are the first part of a long ident, i.e. with no qualifying identifiers let filterSymbolUses (getSourceLineStr: int -> string) (symbolUses: seq) = diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs index 1d95c4c623e..6136df8c1ee 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs @@ -61,3 +61,11 @@ type ABC = type System.Int32 with member this.Abs111 = Abs(this) open type System.Math + +type A = + | A + open System + member _.F _ = 3 +and B = + | B + member _.F _ = Console.WriteLine() \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs index 47ab90c06e1..8c719ec90ac 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs @@ -92,6 +92,7 @@ module ImportDeclarations = (Warning 1178, Line 48, Col 6, Line 48, Col 13, "The struct, record or union type 'BRecord' is not structurally comparable because the type 'obj' does not satisfy the 'comparison' constraint. Consider adding the 'NoComparison' attribute to the type 'BRecord' to clarify that the type is not comparable") (Error 3879, Line 59, Col 5, Line 59, Col 16, "'open' declarations must come before all other definitions in type definitions or augmentation") (Error 3879, Line 63, Col 5, Line 63, Col 26, "'open' declarations must come before all other definitions in type definitions or augmentation") + (Error 0039, Line 71, Col 20, Line 71, Col 27, "The value, namespace, type or module 'Console' is not defined. Maybe you want one of the following:\n Control\n cosh") ] // SOURCE=openInTypeDecl.fs # openInTypeDecl.fs diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs b/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs new file mode 100644 index 00000000000..1d95c4c623e --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs @@ -0,0 +1,63 @@ +// #Regression #Conformance #DeclarationElements #Import +module openInTypeDecl + +type Foo() = + open type System.DateTime + + inherit Object() + + [] val mutable x: Int64 + let x = 42 + let timeConstructed = Now.Ticks + do printfn "%d" Int32.MaxValue + static member Now () = DateTime.Now + member val TimeConstructed = timeConstructed with get, set + + member _.M() = + open type System.ArgumentException + Int32.MaxValue + + interface IDisposable with + member this.Dispose (): unit = + raise (NotImplementedException()) + open global.System + +type A = A of int + with + member _.RandomNumber with get() = Random().Next() + open System + +type ARecord = { A : int } + with + member _.RandomNumber with get() = Random().Next() + open System + +exception AException of int + with + member _.RandomNumber with get() = Random().Next() + open System + +type B = A of Int32 + with + open System + +exception BException of Int32 + with + open System + +type BRecord = { A : Int32 } + with + open System + +[] +type ABC = + val a: Int32 + val b: Int32 + new (a) = + open type System.Int32 + { a = a; b = MinValue } + open System + +type System.Int32 with + member this.Abs111 = Abs(this) + open type System.Math diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs.bsl new file mode 100644 index 00000000000..001a847c944 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs.bsl @@ -0,0 +1,677 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/E_openInTypeDecl.fs", false, + QualifiedNameOfFile openInTypeDecl, [], + [SynModuleOrNamespace + ([openInTypeDecl], false, NamedModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [Foo], + PreXmlDoc ((4,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (4,5--4,8)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], Const (Unit, (4,8--4,10)), None, + PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), + (4,5--4,8), { AsKeyword = None }); + Open + (Type + (LongIdent + (SynLongIdent + ([System; DateTime], [(5,20--5,21)], + [None; None])), (5,14--5,29)), (5,4--5,29)); + ImplicitInherit + (LongIdent (SynLongIdent ([Object], [], [None])), + Const (Unit, (7,18--7,20)), None, (7,4--7,20), + { InheritKeyword = (7,4--7,11) }); + ValField + (SynField + ([{ Attributes = + [{ TypeName = + SynLongIdent ([DefaultValue], [], [None]) + ArgExpr = Const (Unit, (9,6--9,18)) + Target = None + AppliesToGetterAndSetter = false + Range = (9,6--9,18) }] + Range = (9,4--9,20) }], false, Some x, + LongIdent (SynLongIdent ([Int64], [], [None])), true, + PreXmlDoc ((9,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (9,4--9,41), + { LeadingKeyword = Some (Val (9,21--9,24)) + MutableKeyword = Some (9,25--9,32) }), (9,4--9,41)); + LetBindings + ([SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((10,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo ([], SynArgInfo ([], false, None)), + None), + Named + (SynIdent (x, None), false, None, (10,8--10,9)), + None, Const (Int32 42, (10,12--10,14)), + (10,8--10,9), Yes (10,4--10,14), + { LeadingKeyword = Let (10,4--10,7) + InlineKeyword = None + EqualsRange = Some (10,10--10,11) })], false, + false, (10,4--10,14)); + LetBindings + ([SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((11,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo ([], SynArgInfo ([], false, None)), + None), + Named + (SynIdent (timeConstructed, None), false, None, + (11,8--11,23)), None, + LongIdent + (false, + SynLongIdent + ([Now; Ticks], [(11,29--11,30)], [None; None]), + None, (11,26--11,35)), (11,8--11,23), + Yes (11,4--11,35), + { LeadingKeyword = Let (11,4--11,7) + InlineKeyword = None + EqualsRange = Some (11,24--11,25) })], false, + false, (11,4--11,35)); + LetBindings + ([SynBinding + (None, Do, false, false, [], PreXmlDocEmpty, + SynValData + (None, + SynValInfo ([], SynArgInfo ([], false, None)), + None), Const (Unit, (12,4--12,34)), None, + App + (NonAtomic, false, + App + (NonAtomic, false, Ident printfn, + Const + (String ("%d", Regular, (12,15--12,19)), + (12,15--12,19)), (12,7--12,19)), + LongIdent + (false, + SynLongIdent + ([Int32; MaxValue], [(12,25--12,26)], + [None; None]), None, (12,20--12,34)), + (12,7--12,34)), (12,4--12,34), NoneAtDo, + { LeadingKeyword = Do (12,4--12,6) + InlineKeyword = None + EqualsRange = None })], false, false, + (12,4--12,34)); + Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((13,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = false + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo ([[]], SynArgInfo ([], false, None)), + None), + LongIdent + (SynLongIdent ([Now], [], [None]), None, None, + Pats + [Paren + (Const (Unit, (13,22--13,24)), + (13,22--13,24))], None, (13,18--13,24)), + None, + LongIdent + (false, + SynLongIdent + ([DateTime; Now], [(13,35--13,36)], + [None; None]), None, (13,27--13,39)), + (13,18--13,24), NoneAtInvisible, + { LeadingKeyword = + StaticMember ((13,4--13,10), (13,11--13,17)) + InlineKeyword = None + EqualsRange = Some (13,25--13,26) }), + (13,4--13,39)); + AutoProperty + ([], false, TimeConstructed, None, PropertyGetSet, + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertySet }, + PreXmlDoc ((14,4), FSharp.Compiler.Xml.XmlDocCollector), + GetSet (None, None, None), Ident timeConstructed, + (14,4--14,62), + { LeadingKeyword = + MemberVal ((14,4--14,10), (14,11--14,14)) + WithKeyword = Some (14,49--14,53) + EqualsRange = Some (14,31--14,32) + GetSetKeywords = + Some (GetSet ((14,54--14,57), (14,59--14,62))) }); + Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((16,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; M], [(16,12--16,13)], [None; None]), None, + None, + Pats + [Paren + (Const (Unit, (16,14--16,16)), + (16,14--16,16))], None, (16,11--16,16)), + None, + Open + (Type + (LongIdent + (SynLongIdent + ([System; ArgumentException], + [(17,24--17,25)], [None; None])), + (17,18--17,42)), (17,8--17,42), + LongIdent + (false, + SynLongIdent + ([Int32; MaxValue], [(18,13--18,14)], + [None; None]), None, (18,8--18,22))), + (16,11--16,16), NoneAtInvisible, + { LeadingKeyword = Member (16,4--16,10) + InlineKeyword = None + EqualsRange = Some (16,17--16,18) }), + (16,4--17,42)); + Interface + (LongIdent (SynLongIdent ([IDisposable], [], [None])), + Some (20,26--20,30), + Some + [Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((21,8), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = true + IsFinal = false + GetterOrSetterIsCompilerGenerated = + false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([this; Dispose], [(21,19--21,20)], + [None; None]), None, None, + Pats + [Paren + (Const (Unit, (21,28--21,30)), + (21,28--21,30))], None, + (21,15--21,30)), + Some + (SynBindingReturnInfo + (LongIdent + (SynLongIdent ([unit], [], [None])), + (21,32--21,36), [], + { ColonRange = Some (21,30--21,31) })), + Typed + (App + (NonAtomic, false, Ident raise, + Paren + (App + (Atomic, false, + Ident NotImplementedException, + Const (Unit, (22,42--22,44)), + (22,19--22,44)), (22,18--22,19), + Some (22,44--22,45), (22,18--22,45)), + (22,12--22,45)), + LongIdent + (SynLongIdent ([unit], [], [None])), + (22,12--22,45)), (21,15--21,30), + NoneAtInvisible, + { LeadingKeyword = Member (21,8--21,14) + InlineKeyword = None + EqualsRange = Some (21,37--21,38) }), + (21,8--22,45))], (20,4--22,45)); + Open + (ModuleOrNamespace + (SynLongIdent + ([`global`; System], [(23,15--23,16)], + [Some (OriginalNotation "global"); None]), + (23,9--23,22)), (23,4--23,22))], (5,4--23,22)), [], + Some + (ImplicitCtor + (None, [], Const (Unit, (4,8--4,10)), None, + PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), + (4,5--4,8), { AsKeyword = None })), (4,5--23,22), + { LeadingKeyword = Type (4,0--4,4) + EqualsRange = Some (4,11--4,12) + WithKeyword = None })], (4,0--23,22)); + Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [A], + PreXmlDoc ((25,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (25,5--25,6)), + Simple + (Union + (None, + [SynUnionCase + ([], SynIdent (A, None), + Fields + [SynField + ([], false, None, + LongIdent (SynLongIdent ([int], [], [None])), + false, + PreXmlDoc ((25,14), FSharp.Compiler.Xml.XmlDocCollector), + None, (25,14--25,17), + { LeadingKeyword = None + MutableKeyword = None })], + PreXmlDoc ((25,9), FSharp.Compiler.Xml.XmlDocCollector), + None, (25,9--25,17), { BarRange = None })], + (25,9--25,17)), (25,9--25,17)), + [GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((27,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; RandomNumber], [(27,16--27,17)], + [None; None]), Some get, None, + Pats + [Paren + (Const (Unit, (27,38--27,40)), + (27,38--27,40))], None, (27,35--27,40)), + None, + App + (Atomic, false, + DotGet + (App + (Atomic, false, Ident Random, + Const (Unit, (27,49--27,51)), + (27,43--27,51)), (27,51--27,52), + SynLongIdent ([Next], [], [None]), + (27,43--27,56)), Const (Unit, (27,56--27,58)), + (27,43--27,58)), (27,35--27,40), NoneAtInvisible, + { LeadingKeyword = Member (27,8--27,14) + InlineKeyword = None + EqualsRange = Some (27,41--27,42) })), None, + (27,8--27,58), { InlineKeyword = None + WithKeyword = (27,30--27,34) + GetKeyword = Some (27,35--27,38) + AndKeyword = None + SetKeyword = None }); + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (28,13--28,19)), + (28,8--28,19))], None, (25,5--28,19), + { LeadingKeyword = Type (25,0--25,4) + EqualsRange = Some (25,7--25,8) + WithKeyword = Some (26,4--26,8) })], (25,0--28,19)); + Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [ARecord], + PreXmlDoc ((30,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (30,5--30,12)), + Simple + (Record + (None, + [SynField + ([], false, Some A, + LongIdent (SynLongIdent ([int], [], [None])), false, + PreXmlDoc ((30,17), FSharp.Compiler.Xml.XmlDocCollector), + None, (30,17--30,24), { LeadingKeyword = None + MutableKeyword = None })], + (30,15--30,26)), (30,15--30,26)), + [GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((32,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; RandomNumber], [(32,16--32,17)], + [None; None]), Some get, None, + Pats + [Paren + (Const (Unit, (32,38--32,40)), + (32,38--32,40))], None, (32,35--32,40)), + None, + App + (Atomic, false, + DotGet + (App + (Atomic, false, Ident Random, + Const (Unit, (32,49--32,51)), + (32,43--32,51)), (32,51--32,52), + SynLongIdent ([Next], [], [None]), + (32,43--32,56)), Const (Unit, (32,56--32,58)), + (32,43--32,58)), (32,35--32,40), NoneAtInvisible, + { LeadingKeyword = Member (32,8--32,14) + InlineKeyword = None + EqualsRange = Some (32,41--32,42) })), None, + (32,8--32,58), { InlineKeyword = None + WithKeyword = (32,30--32,34) + GetKeyword = Some (32,35--32,38) + AndKeyword = None + SetKeyword = None }); + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (33,13--33,19)), + (33,8--33,19))], None, (30,5--33,19), + { LeadingKeyword = Type (30,0--30,4) + EqualsRange = Some (30,13--30,14) + WithKeyword = Some (31,4--31,8) })], (30,0--33,19)); + Exception + (SynExceptionDefn + (SynExceptionDefnRepr + ([], + SynUnionCase + ([], SynIdent (AException, None), + Fields + [SynField + ([], false, None, + LongIdent (SynLongIdent ([int], [], [None])), false, + PreXmlDoc ((35,24), FSharp.Compiler.Xml.XmlDocCollector), + None, (35,24--35,27), { LeadingKeyword = None + MutableKeyword = None })], + PreXmlDocEmpty, None, (35,10--35,27), { BarRange = None }), + None, + PreXmlDoc ((35,0), FSharp.Compiler.Xml.XmlDocCollector), + None, (35,0--35,27)), Some (36,4--36,8), + [GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((37,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; RandomNumber], [(37,16--37,17)], + [None; None]), Some get, None, + Pats + [Paren + (Const (Unit, (37,38--37,40)), (37,38--37,40))], + None, (37,35--37,40)), None, + App + (Atomic, false, + DotGet + (App + (Atomic, false, Ident Random, + Const (Unit, (37,49--37,51)), (37,43--37,51)), + (37,51--37,52), + SynLongIdent ([Next], [], [None]), + (37,43--37,56)), Const (Unit, (37,56--37,58)), + (37,43--37,58)), (37,35--37,40), NoneAtInvisible, + { LeadingKeyword = Member (37,8--37,14) + InlineKeyword = None + EqualsRange = Some (37,41--37,42) })), None, + (37,8--37,58), { InlineKeyword = None + WithKeyword = (37,30--37,34) + GetKeyword = Some (37,35--37,38) + AndKeyword = None + SetKeyword = None }); + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (38,13--38,19)), + (38,8--38,19))], (35,0--38,19)), (35,0--38,19)); + Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [B], + PreXmlDoc ((40,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (40,5--40,6)), + Simple + (Union + (None, + [SynUnionCase + ([], SynIdent (A, None), + Fields + [SynField + ([], false, None, + LongIdent (SynLongIdent ([Int32], [], [None])), + false, + PreXmlDoc ((40,14), FSharp.Compiler.Xml.XmlDocCollector), + None, (40,14--40,19), + { LeadingKeyword = None + MutableKeyword = None })], + PreXmlDoc ((40,9), FSharp.Compiler.Xml.XmlDocCollector), + None, (40,9--40,19), { BarRange = None })], + (40,9--40,19)), (40,9--40,19)), + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (42,13--42,19)), + (42,8--42,19))], None, (40,5--42,19), + { LeadingKeyword = Type (40,0--40,4) + EqualsRange = Some (40,7--40,8) + WithKeyword = Some (41,4--41,8) })], (40,0--42,19)); + Exception + (SynExceptionDefn + (SynExceptionDefnRepr + ([], + SynUnionCase + ([], SynIdent (BException, None), + Fields + [SynField + ([], false, None, + LongIdent (SynLongIdent ([Int32], [], [None])), + false, + PreXmlDoc ((44,24), FSharp.Compiler.Xml.XmlDocCollector), + None, (44,24--44,29), { LeadingKeyword = None + MutableKeyword = None })], + PreXmlDocEmpty, None, (44,10--44,29), { BarRange = None }), + None, + PreXmlDoc ((44,0), FSharp.Compiler.Xml.XmlDocCollector), + None, (44,0--44,29)), Some (45,4--45,8), + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (46,13--46,19)), + (46,8--46,19))], (44,0--46,19)), (44,0--46,19)); + Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [BRecord], + PreXmlDoc ((48,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (48,5--48,12)), + Simple + (Record + (None, + [SynField + ([], false, Some A, + LongIdent (SynLongIdent ([Int32], [], [None])), + false, + PreXmlDoc ((48,17), FSharp.Compiler.Xml.XmlDocCollector), + None, (48,17--48,26), { LeadingKeyword = None + MutableKeyword = None })], + (48,15--48,28)), (48,15--48,28)), + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (50,13--50,19)), + (50,8--50,19))], None, (48,5--50,19), + { LeadingKeyword = Type (48,0--48,4) + EqualsRange = Some (48,13--48,14) + WithKeyword = Some (49,4--49,8) })], (48,0--50,19)); + Types + ([SynTypeDefn + (SynComponentInfo + ([{ Attributes = + [{ TypeName = SynLongIdent ([Struct], [], [None]) + ArgExpr = Const (Unit, (52,2--52,8)) + Target = None + AppliesToGetterAndSetter = false + Range = (52,2--52,8) }] + Range = (52,0--52,10) }], None, [], [ABC], + PreXmlDoc ((52,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (53,5--53,8)), + ObjectModel + (Unspecified, + [ValField + (SynField + ([], false, Some a, + LongIdent (SynLongIdent ([Int32], [], [None])), + false, + PreXmlDoc ((54,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (54,4--54,16), + { LeadingKeyword = Some (Val (54,4--54,7)) + MutableKeyword = None }), (54,4--54,16)); + ValField + (SynField + ([], false, Some b, + LongIdent (SynLongIdent ([Int32], [], [None])), + false, + PreXmlDoc ((55,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (55,4--55,16), + { LeadingKeyword = Some (Val (55,4--55,7)) + MutableKeyword = None }), (55,4--55,16)); + Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((56,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = false + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Constructor }, + SynValInfo + ([[SynArgInfo ([], false, Some a)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([new], [], [None]), None, + Some (SynValTyparDecls (None, false)), + Pats + [Paren + (Named + (SynIdent (a, None), false, None, + (56,9--56,10)), (56,8--56,11))], None, + (56,4--56,7)), None, + Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(57,24--57,25)], + [None; None])), (57,18--57,30)), + (57,8--57,30), + Record + (None, None, + [SynExprRecordField + ((SynLongIdent ([a], [], [None]), true), + Some (58,12--58,13), Some (Ident a), + (58,10--58,15), + Some ((58,15--58,16), Some (58,16))); + SynExprRecordField + ((SynLongIdent ([b], [], [None]), true), + Some (58,19--58,20), Some (Ident MinValue), + (58,17--58,29), None)], (58,8--58,31))), + (56,4--56,11), NoneAtInvisible, + { LeadingKeyword = New (56,4--56,7) + InlineKeyword = None + EqualsRange = Some (56,12--56,13) }), + (56,4--57,30)); + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (59,9--59,15)), + (59,4--59,15))], (54,4--59,15)), [], None, + (52,0--59,15), { LeadingKeyword = Type (53,0--53,4) + EqualsRange = Some (53,9--53,10) + WithKeyword = None })], (52,0--59,15)); + Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [System; Int32], + PreXmlDoc ((61,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (61,5--61,17)), + ObjectModel (Augmentation (61,18--61,22), [], (61,5--63,25)), + [Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((62,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([this; Abs111], [(62,15--62,16)], [None; None]), + None, None, Pats [], None, (62,11--62,22)), None, + App + (Atomic, false, Ident Abs, + Paren + (Ident this, (62,28--62,29), Some (62,33--62,34), + (62,28--62,34)), (62,25--62,34)), (62,11--62,22), + NoneAtInvisible, + { LeadingKeyword = Member (62,4--62,10) + InlineKeyword = None + EqualsRange = Some (62,23--62,24) }), (62,4--62,34)); + Open + (Type + (LongIdent + (SynLongIdent + ([System; Math], [(63,20--63,21)], [None; None])), + (63,14--63,25)), (63,4--63,25))], None, (61,5--63,25), + { LeadingKeyword = Type (61,0--61,4) + EqualsRange = None + WithKeyword = None })], (61,0--63,25))], + PreXmlDoc ((2,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (2,0--63,25), { LeadingKeyword = Module (2,0--2,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [LineComment (1,0--1,57)] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs b/tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs new file mode 100644 index 00000000000..1aad8bc7ae1 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs @@ -0,0 +1,9 @@ +{ new System.IDisposable with + open System + member _.F _ = 3 +} + +type A() = + interface System.IDisposable with + open System + member _.F _ = 3 diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs.bsl new file mode 100644 index 00000000000..9d7c15b3886 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs.bsl @@ -0,0 +1,99 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/OpenInObjExprOrInterface.fs", false, + QualifiedNameOfFile OpenInObjExprOrInterface, [], + [SynModuleOrNamespace + ([OpenInObjExprOrInterface], false, AnonModule, + [Expr + (ObjExpr + (LongIdent + (SynLongIdent + ([System; IDisposable], [(1,12--1,13)], [None; None])), + None, Some (1,25--1,29), [], + [Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = true + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; + [SynArgInfo ([], false, None)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([_; F], [(3,12--3,13)], [None; None]), + None, None, Pats [Wild (3,15--3,16)], None, + (3,11--3,16)), None, Const (Int32 3, (3,19--3,20)), + (3,11--3,16), NoneAtInvisible, + { LeadingKeyword = Member (3,4--3,10) + InlineKeyword = None + EqualsRange = Some (3,17--3,18) }), (3,4--3,20))], [], + (1,2--1,24), (1,0--4,1)), (1,0--4,1)); + Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [A], + PreXmlDoc ((6,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (6,5--6,6)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], Const (Unit, (6,6--6,8)), None, + PreXmlDoc ((6,6), FSharp.Compiler.Xml.XmlDocCollector), + (6,5--6,6), { AsKeyword = None }); + Interface + (LongIdent + (SynLongIdent + ([System; IDisposable], [(7,20--7,21)], + [None; None])), Some (7,33--7,37), + Some + [Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((9,8), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = true + IsFinal = false + GetterOrSetterIsCompilerGenerated = + false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; + [SynArgInfo ([], false, None)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; F], [(9,16--9,17)], [None; None]), + None, None, Pats [Wild (9,19--9,20)], None, + (9,15--9,20)), None, + Const (Int32 3, (9,23--9,24)), (9,15--9,20), + NoneAtInvisible, + { LeadingKeyword = Member (9,8--9,14) + InlineKeyword = None + EqualsRange = Some (9,21--9,22) }), + (9,8--9,24))], (7,4--9,24))], (7,4--9,24)), [], + Some + (ImplicitCtor + (None, [], Const (Unit, (6,6--6,8)), None, + PreXmlDoc ((6,6), FSharp.Compiler.Xml.XmlDocCollector), + (6,5--6,6), { AsKeyword = None })), (6,5--9,24), + { LeadingKeyword = Type (6,0--6,4) + EqualsRange = Some (6,9--6,10) + WithKeyword = None })], (6,0--9,24))], PreXmlDocEmpty, [], + None, (1,0--10,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(2,4)-(2,8) parse error Unexpected keyword 'open' in object expression. Expected 'member', 'override', 'static' or other token. +(2,16)-(3,4) parse error Expecting member body +(8,8)-(8,12) parse error Unexpected keyword 'open' in member definition. Expected 'member', 'override', 'static' or other token. +(8,20)-(9,8) parse error Expecting member body diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs b/tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs new file mode 100644 index 00000000000..6275e58273c --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs @@ -0,0 +1,11 @@ +type R = + open System + { A : int } + open System + member _.F _ = 3 + +type T = + open System + | A of int + open System + | B of string \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs.bsl new file mode 100644 index 00000000000..f5267d8b5f7 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs.bsl @@ -0,0 +1,13 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/OpenInTypeWithWrongPos.fs", false, + QualifiedNameOfFile OpenInTypeWithWrongPos, [], + [SynModuleOrNamespace + ([OpenInTypeWithWrongPos], false, AnonModule, [], PreXmlDocEmpty, [], + None, (11,17--11,17), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(3,4)-(3,5) parse error Unexpected symbol '{' in member definition +(9,4)-(9,5) parse error Unexpected symbol '|' in member definition diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine.fs b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine.fs new file mode 100644 index 00000000000..06d15f5ce9e --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine.fs @@ -0,0 +1,2 @@ +open + type System.Collections.Generic \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine.fs.bsl new file mode 100644 index 00000000000..260b28fb169 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine.fs.bsl @@ -0,0 +1,17 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/OpenTypeNotOnSameLine.fs", false, + QualifiedNameOfFile OpenTypeNotOnSameLine, [], + [SynModuleOrNamespace + ([OpenTypeNotOnSameLine], false, AnonModule, + [Open + (Type + (LongIdent + (SynLongIdent + ([System; Collections; Generic], + [(2,15--2,16); (2,27--2,28)], [None; None; None])), + (2,9--2,35)), (1,0--2,35))], PreXmlDocEmpty, [], None, + (1,0--2,35), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine2.fs new file mode 100644 index 00000000000..02ec76e42d8 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine2.fs @@ -0,0 +1,2 @@ +(open + type System.Collections.Generic) \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine2.fs.bsl new file mode 100644 index 00000000000..c32edbf565b --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeNotOnSameLine2.fs.bsl @@ -0,0 +1,16 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/OpenTypeNotOnSameLine2.fs", false, + QualifiedNameOfFile OpenTypeNotOnSameLine2, [], + [SynModuleOrNamespace + ([OpenTypeNotOnSameLine2], false, AnonModule, + [Expr + (Paren + (ArbitraryAfterError ("parenExpr1", (1,1--1,1)), (1,0--1,1), + Some (2,35--2,36), (1,0--2,36)), (1,0--2,36))], PreXmlDocEmpty, + [], None, (1,0--2,36), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(2,35)-(2,36) parse error Unexpected symbol ')' in expression. Expected ';' or other token. diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent.fs b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent.fs new file mode 100644 index 00000000000..ddd4b6f726c --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent.fs @@ -0,0 +1,2 @@ +open +type System \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent.fs.bsl new file mode 100644 index 00000000000..445673f2c77 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent.fs.bsl @@ -0,0 +1,25 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/OpenTypeOnSameIndent.fs", false, + QualifiedNameOfFile OpenTypeOnSameIndent, [], + [SynModuleOrNamespace + ([OpenTypeOnSameIndent], false, AnonModule, + [Open + (ModuleOrNamespace (SynLongIdent ([], [], []), (1,4--1,4)), + (1,0--1,4)); + Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [System], + PreXmlDoc ((2,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (2,5--2,11)), + Simple (None (2,5--2,11), (2,5--2,11)), [], None, (2,5--2,11), + { LeadingKeyword = Type (2,0--2,4) + EqualsRange = None + WithKeyword = None })], (2,0--2,11))], PreXmlDocEmpty, [], + None, (1,0--2,11), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(1,5)-(2,0) parse error Incomplete structured construct at or before this point in open declaration. Expected identifier, 'global', 'type' or other token. diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent2.fs new file mode 100644 index 00000000000..d5d5af6bc71 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent2.fs @@ -0,0 +1,2 @@ +(open + type System) \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent2.fs.bsl new file mode 100644 index 00000000000..a2e05a0e576 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent2.fs.bsl @@ -0,0 +1,18 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/OpenTypeOnSameIndent2.fs", false, + QualifiedNameOfFile OpenTypeOnSameIndent2, [], + [SynModuleOrNamespace + ([OpenTypeOnSameIndent2], false, AnonModule, + [Expr + (Paren + (Open + (ModuleOrNamespace (SynLongIdent ([], [], []), (1,5--1,5)), + (1,1--1,5), Ident System), (1,0--1,1), Some (2,12--2,13), + (1,0--2,13)), (1,0--2,13))], PreXmlDocEmpty, [], None, + (1,0--2,13), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(1,6)-(2,1) parse error Incomplete structured construct at or before this point in open declaration. Expected identifier, 'global', 'type' or other token. diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs b/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs new file mode 100644 index 00000000000..dcca61fa898 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs @@ -0,0 +1,51 @@ +// #Regression #Conformance #DeclarationElements #Import +module openInTypeDecl + +type Foo() = + open global.System + open type DateTime + + inherit Object() + + [] val mutable x: Int64 + let x = 42 + let timeConstructed = Now.Ticks + do printfn "%d" Int32.MaxValue + static member Now () = DateTime.Now + member val TimeConstructed = timeConstructed with get, set + + member _.M() = + open type System.ArgumentException + Int32.MaxValue + + interface IDisposable with + member this.Dispose (): unit = + raise (NotImplementedException()) + +type A = A of int + with + open System + member _.RandomNumber with get() = Random().Next() + +type ARecord = { A : int } + with + open System + member _.RandomNumber with get() = Random().Next() + +exception AException of int + with + open System + member _.RandomNumber with get() = Random().Next() + +[] +type ABC = + open System + val a: Int32 + val b: Int32 + new (a) = + open type System.Int32 + { a = a; b = MinValue } + +type System.Int32 with + open type System.Math + member this.Abs111 = Abs(this) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs.bsl new file mode 100644 index 00000000000..221b4285a4d --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs.bsl @@ -0,0 +1,604 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/openInTypeDecl.fs", false, + QualifiedNameOfFile openInTypeDecl, [], + [SynModuleOrNamespace + ([openInTypeDecl], false, NamedModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [Foo], + PreXmlDoc ((4,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (4,5--4,8)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], Const (Unit, (4,8--4,10)), None, + PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), + (4,5--4,8), { AsKeyword = None }); + Open + (ModuleOrNamespace + (SynLongIdent + ([`global`; System], [(5,15--5,16)], + [Some (OriginalNotation "global"); None]), + (5,9--5,22)), (5,4--5,22)); + Open + (Type + (LongIdent (SynLongIdent ([DateTime], [], [None])), + (6,14--6,22)), (6,4--6,22)); + ImplicitInherit + (LongIdent (SynLongIdent ([Object], [], [None])), + Const (Unit, (8,18--8,20)), None, (8,4--8,20), + { InheritKeyword = (8,4--8,11) }); + ValField + (SynField + ([{ Attributes = + [{ TypeName = + SynLongIdent ([DefaultValue], [], [None]) + ArgExpr = Const (Unit, (10,6--10,18)) + Target = None + AppliesToGetterAndSetter = false + Range = (10,6--10,18) }] + Range = (10,4--10,20) }], false, Some x, + LongIdent (SynLongIdent ([Int64], [], [None])), true, + PreXmlDoc ((10,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (10,4--10,41), + { LeadingKeyword = Some (Val (10,21--10,24)) + MutableKeyword = Some (10,25--10,32) }), + (10,4--10,41)); + LetBindings + ([SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((11,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo ([], SynArgInfo ([], false, None)), + None), + Named + (SynIdent (x, None), false, None, (11,8--11,9)), + None, Const (Int32 42, (11,12--11,14)), + (11,8--11,9), Yes (11,4--11,14), + { LeadingKeyword = Let (11,4--11,7) + InlineKeyword = None + EqualsRange = Some (11,10--11,11) })], false, + false, (11,4--11,14)); + LetBindings + ([SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((12,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo ([], SynArgInfo ([], false, None)), + None), + Named + (SynIdent (timeConstructed, None), false, None, + (12,8--12,23)), None, + LongIdent + (false, + SynLongIdent + ([Now; Ticks], [(12,29--12,30)], [None; None]), + None, (12,26--12,35)), (12,8--12,23), + Yes (12,4--12,35), + { LeadingKeyword = Let (12,4--12,7) + InlineKeyword = None + EqualsRange = Some (12,24--12,25) })], false, + false, (12,4--12,35)); + LetBindings + ([SynBinding + (None, Do, false, false, [], PreXmlDocEmpty, + SynValData + (None, + SynValInfo ([], SynArgInfo ([], false, None)), + None), Const (Unit, (13,4--13,34)), None, + App + (NonAtomic, false, + App + (NonAtomic, false, Ident printfn, + Const + (String ("%d", Regular, (13,15--13,19)), + (13,15--13,19)), (13,7--13,19)), + LongIdent + (false, + SynLongIdent + ([Int32; MaxValue], [(13,25--13,26)], + [None; None]), None, (13,20--13,34)), + (13,7--13,34)), (13,4--13,34), NoneAtDo, + { LeadingKeyword = Do (13,4--13,6) + InlineKeyword = None + EqualsRange = None })], false, false, + (13,4--13,34)); + Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((14,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = false + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo ([[]], SynArgInfo ([], false, None)), + None), + LongIdent + (SynLongIdent ([Now], [], [None]), None, None, + Pats + [Paren + (Const (Unit, (14,22--14,24)), + (14,22--14,24))], None, (14,18--14,24)), + None, + LongIdent + (false, + SynLongIdent + ([DateTime; Now], [(14,35--14,36)], + [None; None]), None, (14,27--14,39)), + (14,18--14,24), NoneAtInvisible, + { LeadingKeyword = + StaticMember ((14,4--14,10), (14,11--14,17)) + InlineKeyword = None + EqualsRange = Some (14,25--14,26) }), + (14,4--14,39)); + AutoProperty + ([], false, TimeConstructed, None, PropertyGetSet, + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertySet }, + PreXmlDoc ((15,4), FSharp.Compiler.Xml.XmlDocCollector), + GetSet (None, None, None), Ident timeConstructed, + (15,4--15,62), + { LeadingKeyword = + MemberVal ((15,4--15,10), (15,11--15,14)) + WithKeyword = Some (15,49--15,53) + EqualsRange = Some (15,31--15,32) + GetSetKeywords = + Some (GetSet ((15,54--15,57), (15,59--15,62))) }); + Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((17,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; M], [(17,12--17,13)], [None; None]), None, + None, + Pats + [Paren + (Const (Unit, (17,14--17,16)), + (17,14--17,16))], None, (17,11--17,16)), + None, + Open + (Type + (LongIdent + (SynLongIdent + ([System; ArgumentException], + [(18,24--18,25)], [None; None])), + (18,18--18,42)), (18,8--18,42), + LongIdent + (false, + SynLongIdent + ([Int32; MaxValue], [(19,13--19,14)], + [None; None]), None, (19,8--19,22))), + (17,11--17,16), NoneAtInvisible, + { LeadingKeyword = Member (17,4--17,10) + InlineKeyword = None + EqualsRange = Some (17,17--17,18) }), + (17,4--18,42)); + Interface + (LongIdent (SynLongIdent ([IDisposable], [], [None])), + Some (21,26--21,30), + Some + [Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((22,8), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = true + IsFinal = false + GetterOrSetterIsCompilerGenerated = + false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([this; Dispose], [(22,19--22,20)], + [None; None]), None, None, + Pats + [Paren + (Const (Unit, (22,28--22,30)), + (22,28--22,30))], None, + (22,15--22,30)), + Some + (SynBindingReturnInfo + (LongIdent + (SynLongIdent ([unit], [], [None])), + (22,32--22,36), [], + { ColonRange = Some (22,30--22,31) })), + Typed + (App + (NonAtomic, false, Ident raise, + Paren + (App + (Atomic, false, + Ident NotImplementedException, + Const (Unit, (23,42--23,44)), + (23,19--23,44)), (23,18--23,19), + Some (23,44--23,45), (23,18--23,45)), + (23,12--23,45)), + LongIdent + (SynLongIdent ([unit], [], [None])), + (23,12--23,45)), (22,15--22,30), + NoneAtInvisible, + { LeadingKeyword = Member (22,8--22,14) + InlineKeyword = None + EqualsRange = Some (22,37--22,38) }), + (22,8--23,45))], (21,4--23,45))], (5,4--23,45)), + [], + Some + (ImplicitCtor + (None, [], Const (Unit, (4,8--4,10)), None, + PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), + (4,5--4,8), { AsKeyword = None })), (4,5--23,45), + { LeadingKeyword = Type (4,0--4,4) + EqualsRange = Some (4,11--4,12) + WithKeyword = None })], (4,0--23,45)); + Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [A], + PreXmlDoc ((25,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (25,5--25,6)), + Simple + (Union + (None, + [SynUnionCase + ([], SynIdent (A, None), + Fields + [SynField + ([], false, None, + LongIdent (SynLongIdent ([int], [], [None])), + false, + PreXmlDoc ((25,14), FSharp.Compiler.Xml.XmlDocCollector), + None, (25,14--25,17), + { LeadingKeyword = None + MutableKeyword = None })], + PreXmlDoc ((25,9), FSharp.Compiler.Xml.XmlDocCollector), + None, (25,9--25,17), { BarRange = None })], + (25,9--25,17)), (25,9--25,17)), + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (27,13--27,19)), + (27,8--27,19)); + GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((28,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; RandomNumber], [(28,16--28,17)], + [None; None]), Some get, None, + Pats + [Paren + (Const (Unit, (28,38--28,40)), + (28,38--28,40))], None, (28,35--28,40)), + None, + App + (Atomic, false, + DotGet + (App + (Atomic, false, Ident Random, + Const (Unit, (28,49--28,51)), + (28,43--28,51)), (28,51--28,52), + SynLongIdent ([Next], [], [None]), + (28,43--28,56)), Const (Unit, (28,56--28,58)), + (28,43--28,58)), (28,35--28,40), NoneAtInvisible, + { LeadingKeyword = Member (28,8--28,14) + InlineKeyword = None + EqualsRange = Some (28,41--28,42) })), None, + (28,8--28,58), { InlineKeyword = None + WithKeyword = (28,30--28,34) + GetKeyword = Some (28,35--28,38) + AndKeyword = None + SetKeyword = None })], None, + (25,5--28,58), { LeadingKeyword = Type (25,0--25,4) + EqualsRange = Some (25,7--25,8) + WithKeyword = Some (26,4--26,8) })], + (25,0--28,58)); + Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [ARecord], + PreXmlDoc ((30,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (30,5--30,12)), + Simple + (Record + (None, + [SynField + ([], false, Some A, + LongIdent (SynLongIdent ([int], [], [None])), false, + PreXmlDoc ((30,17), FSharp.Compiler.Xml.XmlDocCollector), + None, (30,17--30,24), { LeadingKeyword = None + MutableKeyword = None })], + (30,15--30,26)), (30,15--30,26)), + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (32,13--32,19)), + (32,8--32,19)); + GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((33,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; RandomNumber], [(33,16--33,17)], + [None; None]), Some get, None, + Pats + [Paren + (Const (Unit, (33,38--33,40)), + (33,38--33,40))], None, (33,35--33,40)), + None, + App + (Atomic, false, + DotGet + (App + (Atomic, false, Ident Random, + Const (Unit, (33,49--33,51)), + (33,43--33,51)), (33,51--33,52), + SynLongIdent ([Next], [], [None]), + (33,43--33,56)), Const (Unit, (33,56--33,58)), + (33,43--33,58)), (33,35--33,40), NoneAtInvisible, + { LeadingKeyword = Member (33,8--33,14) + InlineKeyword = None + EqualsRange = Some (33,41--33,42) })), None, + (33,8--33,58), { InlineKeyword = None + WithKeyword = (33,30--33,34) + GetKeyword = Some (33,35--33,38) + AndKeyword = None + SetKeyword = None })], None, + (30,5--33,58), { LeadingKeyword = Type (30,0--30,4) + EqualsRange = Some (30,13--30,14) + WithKeyword = Some (31,4--31,8) })], + (30,0--33,58)); + Exception + (SynExceptionDefn + (SynExceptionDefnRepr + ([], + SynUnionCase + ([], SynIdent (AException, None), + Fields + [SynField + ([], false, None, + LongIdent (SynLongIdent ([int], [], [None])), false, + PreXmlDoc ((35,24), FSharp.Compiler.Xml.XmlDocCollector), + None, (35,24--35,27), { LeadingKeyword = None + MutableKeyword = None })], + PreXmlDocEmpty, None, (35,10--35,27), { BarRange = None }), + None, + PreXmlDoc ((35,0), FSharp.Compiler.Xml.XmlDocCollector), + None, (35,0--35,27)), Some (36,4--36,8), + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (37,13--37,19)), + (37,8--37,19)); + GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((38,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; RandomNumber], [(38,16--38,17)], + [None; None]), Some get, None, + Pats + [Paren + (Const (Unit, (38,38--38,40)), (38,38--38,40))], + None, (38,35--38,40)), None, + App + (Atomic, false, + DotGet + (App + (Atomic, false, Ident Random, + Const (Unit, (38,49--38,51)), (38,43--38,51)), + (38,51--38,52), + SynLongIdent ([Next], [], [None]), + (38,43--38,56)), Const (Unit, (38,56--38,58)), + (38,43--38,58)), (38,35--38,40), NoneAtInvisible, + { LeadingKeyword = Member (38,8--38,14) + InlineKeyword = None + EqualsRange = Some (38,41--38,42) })), None, + (38,8--38,58), { InlineKeyword = None + WithKeyword = (38,30--38,34) + GetKeyword = Some (38,35--38,38) + AndKeyword = None + SetKeyword = None })], (35,0--38,58)), + (35,0--38,58)); + Types + ([SynTypeDefn + (SynComponentInfo + ([{ Attributes = + [{ TypeName = SynLongIdent ([Struct], [], [None]) + ArgExpr = Const (Unit, (40,2--40,8)) + Target = None + AppliesToGetterAndSetter = false + Range = (40,2--40,8) }] + Range = (40,0--40,10) }], None, [], [ABC], + PreXmlDoc ((40,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (41,5--41,8)), + ObjectModel + (Unspecified, + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (42,9--42,15)), + (42,4--42,15)); + ValField + (SynField + ([], false, Some a, + LongIdent (SynLongIdent ([Int32], [], [None])), + false, + PreXmlDoc ((43,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (43,4--43,16), + { LeadingKeyword = Some (Val (43,4--43,7)) + MutableKeyword = None }), (43,4--43,16)); + ValField + (SynField + ([], false, Some b, + LongIdent (SynLongIdent ([Int32], [], [None])), + false, + PreXmlDoc ((44,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (44,4--44,16), + { LeadingKeyword = Some (Val (44,4--44,7)) + MutableKeyword = None }), (44,4--44,16)); + Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((45,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = false + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Constructor }, + SynValInfo + ([[SynArgInfo ([], false, Some a)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([new], [], [None]), None, + Some (SynValTyparDecls (None, false)), + Pats + [Paren + (Named + (SynIdent (a, None), false, None, + (45,9--45,10)), (45,8--45,11))], None, + (45,4--45,7)), None, + Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(46,24--46,25)], + [None; None])), (46,18--46,30)), + (46,8--46,30), + Record + (None, None, + [SynExprRecordField + ((SynLongIdent ([a], [], [None]), true), + Some (47,12--47,13), Some (Ident a), + (47,10--47,15), + Some ((47,15--47,16), Some (47,16))); + SynExprRecordField + ((SynLongIdent ([b], [], [None]), true), + Some (47,19--47,20), Some (Ident MinValue), + (47,17--47,29), None)], (47,8--47,31))), + (45,4--45,11), NoneAtInvisible, + { LeadingKeyword = New (45,4--45,7) + InlineKeyword = None + EqualsRange = Some (45,12--45,13) }), + (45,4--46,30))], (42,4--46,30)), [], None, + (40,0--46,30), { LeadingKeyword = Type (41,0--41,4) + EqualsRange = Some (41,9--41,10) + WithKeyword = None })], (40,0--46,30)); + Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [System; Int32], + PreXmlDoc ((49,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (49,5--49,17)), + ObjectModel (Augmentation (49,18--49,22), [], (49,5--51,34)), + [Open + (Type + (LongIdent + (SynLongIdent + ([System; Math], [(50,20--50,21)], [None; None])), + (50,14--50,25)), (50,4--50,25)); + Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((51,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([this; Abs111], [(51,15--51,16)], [None; None]), + None, None, Pats [], None, (51,11--51,22)), None, + App + (Atomic, false, Ident Abs, + Paren + (Ident this, (51,28--51,29), Some (51,33--51,34), + (51,28--51,34)), (51,25--51,34)), (51,11--51,22), + NoneAtInvisible, + { LeadingKeyword = Member (51,4--51,10) + InlineKeyword = None + EqualsRange = Some (51,23--51,24) }), (51,4--51,34))], + None, (49,5--51,34), { LeadingKeyword = Type (49,0--49,4) + EqualsRange = None + WithKeyword = None })], (49,0--51,34))], + PreXmlDoc ((2,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (2,0--51,34), { LeadingKeyword = Module (2,0--2,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [LineComment (1,0--1,57)] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs b/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs new file mode 100644 index 00000000000..38e95c7ded1 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs @@ -0,0 +1,93 @@ +// #Regression #Conformance #DeclarationElements #Import +module openModInFun + +let f x y = + let result = x + y + open System + Console.WriteLine(result.ToString()) + + open type Console + WriteLine(result.ToString()) + +let top x y = + let r1 = x + y + let r2 = x * y + let nested x y = + open System + Console.WriteLine(r1.ToString()) + nested r1 r2 + +type Foo() = + do + open System + open type Console + WriteLine 123 + member public this.PrintHello() = + open System + Console.WriteLine("Hello!") + + +( + open type + System.Console + WriteLine() +) + + +// In `match` +match Some 1 with +| Some 1 when open System; Int32.MinValue < 0 -> + open type System.Console + WriteLine "Is 1" +| _ -> () + +// In `for` +for _ in open System.Linq; Enumerable.Range(0, 10) do + open type System.Console + WriteLine "Hello, World!" + +// In `while` +while + (open type System.Int32 + MaxValue < 0) do + open type System.Console + WriteLine "MaxValue is negative" + +// In `if` +if (open type System.Int32; MaxValue <> MinValue) then + open type System.Console + WriteLine "MaxValue is not equal to MinValue" +elif (open type System.Int32; MaxValue < 0) then + open type System.Console + WriteLine "MaxValue is negative" +else + open type System.Console + WriteLine "MaxValue is positive" + +// In `try` +try + open type System.Int32 + open Checked + ignore(MaxValue + 1) +with | exn -> open type System.Console; WriteLine exn.Message + +// In lambdas +let fun1 = fun x -> open System; x + 1 +let fun2 = function x -> open type System.Int32; x + MinValue + +// In computation expressions +let res = async { + open System + Console.WriteLine("Hello, World!") + let! x = Async.Sleep 1000 + return x +} + +// In `query` +let q = + query { + open type System.Linq.Enumerable + for i in Range(1, 10) do + open type int + yield MinValue + i + } |> Seq.toArray diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs.bsl new file mode 100644 index 00000000000..40f1912421f --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs.bsl @@ -0,0 +1,843 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/openModInFun.fs", false, + QualifiedNameOfFile openModInFun, [], + [SynModuleOrNamespace + ([openModInFun], false, NamedModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((4,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some x)]; + [SynArgInfo ([], false, Some y)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([f], [], [None]), None, None, + Pats + [Named (SynIdent (x, None), false, None, (4,6--4,7)); + Named (SynIdent (y, None), false, None, (4,8--4,9))], + None, (4,4--4,9)), None, + LetOrUse + (false, false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), + None), + Named + (SynIdent (result, None), false, None, (5,8--5,14)), + None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Addition], [], + [Some (OriginalNotation "+")]), None, + (5,19--5,20)), Ident x, (5,17--5,20)), Ident y, + (5,17--5,22)), (5,8--5,14), Yes (5,4--5,22), + { LeadingKeyword = Let (5,4--5,7) + InlineKeyword = None + EqualsRange = Some (5,15--5,16) })], + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (6,9--6,15)), + (6,4--6,15), + Sequential + (SuppressNeither, true, + App + (Atomic, false, + LongIdent + (false, + SynLongIdent + ([Console; WriteLine], [(7,11--7,12)], + [None; None]), None, (7,4--7,21)), + Paren + (App + (Atomic, false, + LongIdent + (false, + SynLongIdent + ([result; ToString], [(7,28--7,29)], + [None; None]), None, (7,22--7,37)), + Const (Unit, (7,37--7,39)), (7,22--7,39)), + (7,21--7,22), Some (7,39--7,40), (7,21--7,40)), + (7,4--7,40)), + Open + (Type + (LongIdent + (SynLongIdent ([Console], [], [None])), + (9,14--9,21)), (9,4--9,21), + App + (Atomic, false, Ident WriteLine, + Paren + (App + (Atomic, false, + LongIdent + (false, + SynLongIdent + ([result; ToString], + [(10,20--10,21)], [None; None]), + None, (10,14--10,29)), + Const (Unit, (10,29--10,31)), + (10,14--10,31)), (10,13--10,14), + Some (10,31--10,32), (10,13--10,32)), + (10,4--10,32))), (7,4--9,21), + { SeparatorRange = None })), (5,4--6,15), + { LetOrUseKeyword = (5,4--5,7) + InKeyword = None + EqualsRange = Some (5,15--5,16) }), (4,4--4,9), NoneAtLet, + { LeadingKeyword = Let (4,0--4,3) + InlineKeyword = None + EqualsRange = Some (4,10--4,11) })], (4,0--6,15)); + Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((12,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some x)]; + [SynArgInfo ([], false, Some y)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([top], [], [None]), None, None, + Pats + [Named (SynIdent (x, None), false, None, (12,8--12,9)); + Named (SynIdent (y, None), false, None, (12,10--12,11))], + None, (12,4--12,11)), None, + LetOrUse + (false, false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((13,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), + None), + Named (SynIdent (r1, None), false, None, (13,8--13,10)), + None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Addition], [], + [Some (OriginalNotation "+")]), None, + (13,15--13,16)), Ident x, (13,13--13,16)), + Ident y, (13,13--13,18)), (13,8--13,10), + Yes (13,4--13,18), + { LeadingKeyword = Let (13,4--13,7) + InlineKeyword = None + EqualsRange = Some (13,11--13,12) })], + LetOrUse + (false, false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((14,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo ([], SynArgInfo ([], false, None)), + None), + Named + (SynIdent (r2, None), false, None, (14,8--14,10)), + None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Multiply], [], + [Some (OriginalNotation "*")]), None, + (14,15--14,16)), Ident x, (14,13--14,16)), + Ident y, (14,13--14,18)), (14,8--14,10), + Yes (14,4--14,18), + { LeadingKeyword = Let (14,4--14,7) + InlineKeyword = None + EqualsRange = Some (14,11--14,12) })], + LetOrUse + (false, false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((15,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some x)]; + [SynArgInfo ([], false, Some y)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([nested], [], [None]), None, + None, + Pats + [Named + (SynIdent (x, None), false, None, + (15,15--15,16)); + Named + (SynIdent (y, None), false, None, + (15,17--15,18))], None, (15,8--15,18)), + None, + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), + (16,13--16,19)), (16,8--16,19), + App + (Atomic, false, + LongIdent + (false, + SynLongIdent + ([Console; WriteLine], + [(17,15--17,16)], [None; None]), None, + (17,8--17,25)), + Paren + (App + (Atomic, false, + LongIdent + (false, + SynLongIdent + ([r1; ToString], + [(17,28--17,29)], [None; None]), + None, (17,26--17,37)), + Const (Unit, (17,37--17,39)), + (17,26--17,39)), (17,25--17,26), + Some (17,39--17,40), (17,25--17,40)), + (17,8--17,40))), (15,8--15,18), NoneAtLet, + { LeadingKeyword = Let (15,4--15,7) + InlineKeyword = None + EqualsRange = Some (15,19--15,20) })], + App + (NonAtomic, false, + App + (NonAtomic, false, Ident nested, Ident r1, + (18,4--18,13)), Ident r2, (18,4--18,16)), + (15,4--18,16), { LetOrUseKeyword = (15,4--15,7) + InKeyword = None + EqualsRange = Some (15,19--15,20) }), + (14,4--18,16), { LetOrUseKeyword = (14,4--14,7) + InKeyword = None + EqualsRange = Some (14,11--14,12) }), + (13,4--18,16), { LetOrUseKeyword = (13,4--13,7) + InKeyword = None + EqualsRange = Some (13,11--13,12) }), + (12,4--12,11), NoneAtLet, + { LeadingKeyword = Let (12,0--12,3) + InlineKeyword = None + EqualsRange = Some (12,12--12,13) })], (12,0--18,16)); + Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [Foo], + PreXmlDoc ((20,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (20,5--20,8)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], Const (Unit, (20,8--20,10)), None, + PreXmlDoc ((20,8), FSharp.Compiler.Xml.XmlDocCollector), + (20,5--20,8), { AsKeyword = None }); + LetBindings + ([SynBinding + (None, Do, false, false, [], PreXmlDocEmpty, + SynValData + (None, + SynValInfo ([], SynArgInfo ([], false, None)), + None), Const (Unit, (21,4--22,19)), None, + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), + (22,13--22,19)), (22,8--22,19), + Open + (Type + (LongIdent + (SynLongIdent ([Console], [], [None])), + (23,18--23,25)), (23,8--23,25), + App + (NonAtomic, false, Ident WriteLine, + Const (Int32 123, (24,18--24,21)), + (24,8--24,21)))), (21,4--22,19), NoneAtDo, + { LeadingKeyword = Do (21,4--21,6) + InlineKeyword = None + EqualsRange = None })], false, false, + (21,4--22,19)); + Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((25,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([this; PrintHello], [(25,22--25,23)], + [None; None]), None, None, + Pats + [Paren + (Const (Unit, (25,33--25,35)), + (25,33--25,35))], + Some (Public (25,11--25,17)), (25,11--25,35)), + None, + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), + (26,13--26,19)), (26,8--26,19), + App + (Atomic, false, + LongIdent + (false, + SynLongIdent + ([Console; WriteLine], [(27,15--27,16)], + [None; None]), None, (27,8--27,25)), + Paren + (Const + (String + ("Hello!", Regular, (27,26--27,34)), + (27,26--27,34)), (27,25--27,26), + Some (27,34--27,35), (27,25--27,35)), + (27,8--27,35))), (25,11--25,35), + NoneAtInvisible, + { LeadingKeyword = Member (25,4--25,10) + InlineKeyword = None + EqualsRange = Some (25,36--25,37) }), + (25,4--26,19))], (21,4--26,19)), [], + Some + (ImplicitCtor + (None, [], Const (Unit, (20,8--20,10)), None, + PreXmlDoc ((20,8), FSharp.Compiler.Xml.XmlDocCollector), + (20,5--20,8), { AsKeyword = None })), (20,5--26,19), + { LeadingKeyword = Type (20,0--20,4) + EqualsRange = Some (20,11--20,12) + WithKeyword = None })], (20,0--26,19)); + Expr + (Paren + (Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(32,14--32,15)], [None; None])), + (32,8--32,22)), (31,4--32,22), + App + (Atomic, false, Ident WriteLine, + Const (Unit, (33,13--33,15)), (33,4--33,15))), + (30,0--30,1), Some (34,0--34,1), (30,0--34,1)), (30,0--34,1)); + Expr + (Match + (Yes (38,0--38,17), + App + (NonAtomic, false, Ident Some, + Const (Int32 1, (38,11--38,12)), (38,6--38,12)), + [SynMatchClause + (LongIdent + (SynLongIdent ([Some], [], [None]), None, None, + Pats [Const (Int32 1, (39,7--39,8))], None, (39,2--39,8)), + Some + (Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), + (39,19--39,25)), (39,14--39,25), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_LessThan], [], + [Some (OriginalNotation "<")]), None, + (39,42--39,43)), + LongIdent + (false, + SynLongIdent + ([Int32; MinValue], [(39,32--39,33)], + [None; None]), None, (39,27--39,41)), + (39,27--39,43)), + Const (Int32 0, (39,44--39,45)), (39,27--39,45)))), + Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(40,20--40,21)], + [None; None])), (40,14--40,28)), (40,4--40,28), + App + (NonAtomic, false, Ident WriteLine, + Const + (String ("Is 1", Regular, (41,14--41,20)), + (41,14--41,20)), (41,4--41,20))), (39,2--40,28), + Yes, { ArrowRange = Some (39,46--39,48) + BarRange = Some (39,0--39,1) }); + SynMatchClause + (Wild (42,2--42,3), None, Const (Unit, (42,7--42,9)), + (42,2--42,9), Yes, { ArrowRange = Some (42,4--42,6) + BarRange = Some (42,0--42,1) })], + (38,0--42,9), { MatchKeyword = (38,0--38,5) + WithKeyword = (38,13--38,17) }), (38,0--42,9)); + Expr + (ForEach + (Yes (45,0--45,3), Yes (45,6--45,8), SeqExprOnly false, true, + Wild (45,4--45,5), + Open + (ModuleOrNamespace + (SynLongIdent + ([System; Linq], [(45,20--45,21)], [None; None]), + (45,14--45,25)), (45,9--45,25), + App + (Atomic, false, + LongIdent + (false, + SynLongIdent + ([Enumerable; Range], [(45,37--45,38)], [None; None]), + None, (45,27--45,43)), + Paren + (Tuple + (false, + [Const (Int32 0, (45,44--45,45)); + Const (Int32 10, (45,47--45,49))], + [(45,45--45,46)], (45,44--45,49)), (45,43--45,44), + Some (45,49--45,50), (45,43--45,50)), (45,27--45,50))), + Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(46,20--46,21)], [None; None])), + (46,14--46,28)), (46,4--46,28), + App + (NonAtomic, false, Ident WriteLine, + Const + (String ("Hello, World!", Regular, (47,14--47,29)), + (47,14--47,29)), (47,4--47,29))), (45,0--47,29)), + (45,0--47,29)); + Expr + (While + (Yes (50,0--52,18), + Paren + (Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(51,21--51,22)], [None; None])), + (51,15--51,27)), (51,5--51,27), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_LessThan], [], + [Some (OriginalNotation "<")]), None, + (52,14--52,15)), Ident MaxValue, (52,5--52,15)), + Const (Int32 0, (52,16--52,17)), (52,5--52,17))), + (51,4--51,5), Some (52,17--52,18), (51,4--52,18)), + Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(53,20--53,21)], [None; None])), + (53,14--53,28)), (53,4--53,28), + App + (NonAtomic, false, Ident WriteLine, + Const + (String + ("MaxValue is negative", Regular, (54,14--54,36)), + (54,14--54,36)), (54,4--54,36))), (50,0--54,36)), + (50,0--54,36)); + Expr + (IfThenElse + (Paren + (Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(57,20--57,21)], [None; None])), + (57,14--57,26)), (57,4--57,26), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Inequality], [], + [Some (OriginalNotation "<>")]), None, + (57,37--57,39)), Ident MaxValue, (57,28--57,39)), + Ident MinValue, (57,28--57,48))), (57,3--57,4), + Some (57,48--57,49), (57,3--57,49)), + Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(58,20--58,21)], [None; None])), + (58,14--58,28)), (58,4--58,28), + App + (NonAtomic, false, Ident WriteLine, + Const + (String + ("MaxValue is not equal to MinValue", Regular, + (59,14--59,49)), (59,14--59,49)), (59,4--59,49))), + Some + (IfThenElse + (Paren + (Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(60,22--60,23)], + [None; None])), (60,16--60,28)), + (60,6--60,28), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_LessThan], [], + [Some (OriginalNotation "<")]), None, + (60,39--60,40)), Ident MaxValue, + (60,30--60,40)), + Const (Int32 0, (60,41--60,42)), (60,30--60,42))), + (60,5--60,6), Some (60,42--60,43), (60,5--60,43)), + Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(61,20--61,21)], + [None; None])), (61,14--61,28)), + (61,4--61,28), + App + (NonAtomic, false, Ident WriteLine, + Const + (String + ("MaxValue is negative", Regular, + (62,14--62,36)), (62,14--62,36)), + (62,4--62,36))), + Some + (Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(64,20--64,21)], + [None; None])), (64,14--64,28)), + (64,4--64,28), + App + (NonAtomic, false, Ident WriteLine, + Const + (String + ("MaxValue is positive", Regular, + (65,14--65,36)), (65,14--65,36)), + (65,4--65,36)))), Yes (60,0--60,48), false, + (60,0--64,28), { IfKeyword = (60,0--60,4) + IsElif = true + ThenKeyword = (60,44--60,48) + ElseKeyword = Some (63,0--63,4) + IfToThenRange = (60,0--60,48) })), + Yes (57,0--57,54), false, (57,0--64,28), + { IfKeyword = (57,0--57,2) + IsElif = false + ThenKeyword = (57,50--57,54) + ElseKeyword = None + IfToThenRange = (57,0--57,54) }), (57,0--64,28)); + Expr + (TryWith + (Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(69,20--69,21)], [None; None])), + (69,14--69,26)), (69,4--69,26), + Open + (ModuleOrNamespace + (SynLongIdent ([Checked], [], [None]), (70,9--70,16)), + (70,4--70,16), + App + (Atomic, false, Ident ignore, + Paren + (App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Addition], [], + [Some (OriginalNotation "+")]), None, + (71,20--71,21)), Ident MaxValue, + (71,11--71,21)), + Const (Int32 1, (71,22--71,23)), (71,11--71,23)), + (71,10--71,11), Some (71,23--71,24), (71,10--71,24)), + (71,4--71,24)))), + [SynMatchClause + (Named (SynIdent (exn, None), false, None, (72,7--72,10)), + None, + Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(72,30--72,31)], + [None; None])), (72,24--72,38)), (72,14--72,38), + App + (NonAtomic, false, Ident WriteLine, + LongIdent + (false, + SynLongIdent + ([exn; Message], [(72,53--72,54)], [None; None]), + None, (72,50--72,61)), (72,40--72,61))), + (72,7--72,38), Yes, { ArrowRange = Some (72,11--72,13) + BarRange = Some (72,5--72,6) })], + (68,0--72,38), Yes (68,0--68,3), Yes (72,0--72,4), + { TryKeyword = (68,0--68,3) + TryToWithRange = (68,0--72,4) + WithKeyword = (72,0--72,4) + WithToEndRange = (72,0--72,38) }), (68,0--72,38)); + Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((75,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some x)]], + SynArgInfo ([], false, None)), None), + Named (SynIdent (fun1, None), false, None, (75,4--75,8)), None, + Lambda + (false, false, + SimplePats + ([Id (x, None, false, false, false, (75,15--75,16))], [], + (75,15--75,16)), + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (75,25--75,31)), + (75,20--75,31), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Addition], [], + [Some (OriginalNotation "+")]), None, + (75,35--75,36)), Ident x, (75,33--75,36)), + Const (Int32 1, (75,37--75,38)), (75,33--75,38))), + Some + ([Named (SynIdent (x, None), false, None, (75,15--75,16))], + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), + (75,25--75,31)), (75,20--75,31), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Addition], [], + [Some (OriginalNotation "+")]), None, + (75,35--75,36)), Ident x, (75,33--75,36)), + Const (Int32 1, (75,37--75,38)), (75,33--75,38)))), + (75,11--75,31), { ArrowRange = Some (75,17--75,19) }), + (75,4--75,8), NoneAtLet, { LeadingKeyword = Let (75,0--75,3) + InlineKeyword = None + EqualsRange = Some (75,9--75,10) })], + (75,0--75,31)); + Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((76,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Named (SynIdent (fun2, None), false, None, (76,4--76,8)), None, + MatchLambda + (false, (76,11--76,19), + [SynMatchClause + (Named (SynIdent (x, None), false, None, (76,20--76,21)), + None, + Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(76,41--76,42)], + [None; None])), (76,35--76,47)), + (76,25--76,47), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Addition], [], + [Some (OriginalNotation "+")]), None, + (76,51--76,52)), Ident x, (76,49--76,52)), + Ident MinValue, (76,49--76,61))), (76,20--76,47), + Yes, { ArrowRange = Some (76,22--76,24) + BarRange = None })], NoneAtInvisible, + (76,11--76,47)), (76,4--76,8), NoneAtLet, + { LeadingKeyword = Let (76,0--76,3) + InlineKeyword = None + EqualsRange = Some (76,9--76,10) })], (76,0--76,47)); + Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((79,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Named (SynIdent (res, None), false, None, (79,4--79,7)), None, + App + (NonAtomic, false, Ident async, + ComputationExpr + (false, + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (80,9--80,15)), + (80,4--80,15), + Sequential + (SuppressNeither, true, + App + (Atomic, false, + LongIdent + (false, + SynLongIdent + ([Console; WriteLine], [(81,11--81,12)], + [None; None]), None, (81,4--81,21)), + Paren + (Const + (String + ("Hello, World!", Regular, + (81,22--81,37)), (81,22--81,37)), + (81,21--81,22), Some (81,37--81,38), + (81,21--81,38)), (81,4--81,38)), + LetOrUseBang + (Yes (82,4--82,29), false, true, + Named + (SynIdent (x, None), false, None, + (82,9--82,10)), + App + (NonAtomic, false, + LongIdent + (false, + SynLongIdent + ([Async; Sleep], [(82,18--82,19)], + [None; None]), None, (82,13--82,24)), + Const (Int32 1000, (82,25--82,29)), + (82,13--82,29)), [], + YieldOrReturn + ((false, true), Ident x, (83,4--83,12), + { YieldOrReturnKeyword = (83,4--83,10) }), + (82,4--83,12), + { LetOrUseKeyword = (82,4--82,8) + InKeyword = None + EqualsRange = Some (82,11--82,12) }), + (81,4--83,12), { SeparatorRange = None })), + (79,16--84,1)), (79,10--84,1)), (79,4--79,7), NoneAtLet, + { LeadingKeyword = Let (79,0--79,3) + InlineKeyword = None + EqualsRange = Some (79,8--79,9) })], (79,0--84,1)); + Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((87,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Named (SynIdent (q, None), false, None, (87,4--87,5)), None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_PipeRight], [], [Some (OriginalNotation "|>")]), + None, (93,6--93,8)), + App + (NonAtomic, false, Ident query, + ComputationExpr + (false, + Open + (Type + (LongIdent + (SynLongIdent + ([System; Linq; Enumerable], + [(89,24--89,25); (89,29--89,30)], + [None; None; None])), (89,18--89,40)), + (89,8--89,40), + ForEach + (Yes (90,8--90,11), Yes (90,14--90,16), + SeqExprOnly false, true, + Named + (SynIdent (i, None), false, None, + (90,12--90,13)), + App + (Atomic, false, Ident Range, + Paren + (Tuple + (false, + [Const (Int32 1, (90,23--90,24)); + Const (Int32 10, (90,26--90,28))], + [(90,24--90,25)], (90,23--90,28)), + (90,22--90,23), Some (90,28--90,29), + (90,22--90,29)), (90,17--90,29)), + Open + (Type + (LongIdent + (SynLongIdent ([int], [], [None])), + (91,22--91,25)), (91,12--91,25), + YieldOrReturn + ((true, false), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Addition], [], + [Some + (OriginalNotation "+")]), + None, (92,27--92,28)), + Ident MinValue, (92,18--92,28)), + Ident i, (92,18--92,30)), + (92,12--92,30), + { YieldOrReturnKeyword = + (92,12--92,17) })), (90,8--92,30))), + (88,10--93,5)), (88,4--93,5)), (88,4--93,8)), + LongIdent + (false, + SynLongIdent + ([Seq; toArray], [(93,12--93,13)], [None; None]), None, + (93,9--93,20)), (88,4--93,20)), (87,4--87,5), NoneAtLet, + { LeadingKeyword = Let (87,0--87,3) + InlineKeyword = None + EqualsRange = Some (87,6--87,7) })], (87,0--93,20))], + PreXmlDoc ((2,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (2,0--93,20), { LeadingKeyword = Module (2,0--2,6) })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = + [LineComment (1,0--1,57); LineComment (37,0--37,13); + LineComment (44,0--44,11); LineComment (49,0--49,13); + LineComment (56,0--56,10); LineComment (67,0--67,11); + LineComment (74,0--74,13); LineComment (78,0--78,29); + LineComment (86,0--86,13)] }, set [])) diff --git a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingEqualsToTypeDefinitionTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingEqualsToTypeDefinitionTests.fs index ee758c93768..4605621658d 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingEqualsToTypeDefinitionTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingEqualsToTypeDefinitionTests.fs @@ -52,6 +52,8 @@ type Name = Name of string Assert.Equal(expected, actual) [] +// [] // This case will not trigger the code fix in VS because the error message of + // this is not related with missing equals now. [] + [] member public this.``LocationOfParams.UnmatchedParens.Bug91609.OtherCases.Open``() = this.TestParameterInfoLocationOfParams(""" let arr = Array.create 4 1 From 3ec4016ab58ee61211d27fac3b04ec206fbca9f7 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Thu, 7 Aug 2025 07:58:03 +0800 Subject: [PATCH 13/22] format --- .../CodeFixes/AddMissingEqualsToTypeDefinitionTests.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingEqualsToTypeDefinitionTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingEqualsToTypeDefinitionTests.fs index 4605621658d..716f97610d5 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingEqualsToTypeDefinitionTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingEqualsToTypeDefinitionTests.fs @@ -52,8 +52,8 @@ type Name = Name of string Assert.Equal(expected, actual) [] -// [] // This case will not trigger the code fix in VS because the error message of - // this is not related with missing equals now. +// [] // This case will not trigger the code fix in VS because the error message of +// // this is not related with missing equals now. [ Date: Thu, 7 Aug 2025 08:43:21 +0800 Subject: [PATCH 14/22] fix test --- .../ImportDeclarations/E_openInTypeDecl.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs index 6136df8c1ee..875d221f369 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs @@ -62,10 +62,10 @@ type System.Int32 with member this.Abs111 = Abs(this) open type System.Math -type A = +type A123 = | A open System member _.F _ = 3 -and B = +and B123 = | B member _.F _ = Console.WriteLine() \ No newline at end of file From 51caf8400361b0ea33e82b4fcf6f76a648cdcaf4 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Thu, 7 Aug 2025 20:40:56 +0800 Subject: [PATCH 15/22] fix test --- src/Compiler/Checking/CheckDeclarations.fs | 39 ++++---- .../CheckComputationExpressions.fs | 4 +- .../Checking/Expressions/CheckExpressions.fs | 8 +- src/Compiler/Service/ServiceAnalysis.fs | 1 - src/Compiler/Service/ServiceParsedInputOps.fs | 2 +- src/Compiler/SyntaxTree/SyntaxTree.fs | 2 +- src/Compiler/SyntaxTree/SyntaxTree.fsi | 2 +- src/Compiler/pars.fsy | 5 +- ...vice.SurfaceArea.netstandard20.release.bsl | 4 +- .../OpenDeclaration/E_openInTypeDecl.fs.bsl | 8 +- .../OpenTypeOnSameIndent2.fs.bsl | 6 +- .../OpenDeclaration/openInTypeDecl.fs.bsl | 12 +-- .../OpenDeclaration/openModInFun.fs.bsl | 91 ++++++++++--------- .../tests/UnitTests/UnusedOpensTests.fs | 14 +++ 14 files changed, 109 insertions(+), 89 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 8efb519d8a9..9071ac3d2b3 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -676,26 +676,20 @@ let TcTyconMemberSpecs cenv env containerInfo declKind tpenv augSpfn = let TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) = CheckBasics.TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) -let private buildTcEnvWithTypeScopedOpensApplied (cenv: cenv) parent mFallback synMembers env = - // Because 'MemberInfo is not SynMemberDefn list when it is in a signature file, +let private buildTcEnvWithTypeScopedOpensApplied (cenv: cenv) scopem (synMembers: 'MemberInfo) env = + // Because 'MemberInfo is not SynMemberDefn list when it is in signature files, // we need to check the type first match box synMembers with | :? (SynMemberDefn list) as synMembers -> - // Get the whole range that containing the type definition - // Used to add `open`s to the environment - let mParent = - match parent with - | Parent parent -> parent.DefinitionRange - | ParentNone -> mFallback - // Since type-scoped opens are always at the top of the type definition, // we can just go through until we hit a non-open declaration let rec loop env = function | SynMemberDefn.Open (target, mOpen) :: rest -> checkLanguageFeatureAndRecover cenv.g.langVersion LanguageFeature.ExpressionAndTypeScopedOpens mOpen - - let env, _openDecl = TcOpenDecl cenv mOpen mParent env target + let env, _openDecl = TcOpenDecl cenv mOpen scopem env target loop env rest + + // The implicit constructor maybe on the first one, skip them. | SynMemberDefn.ImplicitCtor _ :: rest -> loop env rest | _ -> env @@ -1400,7 +1394,8 @@ module MutRecBindingChecking = [Phase2BMember rbind.RecBindingInfo.Index], innerState | Phase2AOpen (target, m) -> - let scopem = unionRanges m.EndRange scopem + // excepts the line before 'open' + let scopem = withStart m.End scopem let envInstance, _openDecls = TcOpenDecl cenv m scopem envInstance target let envStatic, _openDecls = TcOpenDecl cenv m scopem envStatic target let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) @@ -2028,7 +2023,7 @@ let TcMutRecDefns_Phase2 (cenv: cenv) envInitial mBinds scopem mutRecNSInfo (env let binds: MutRecDefnsPhase2Info = (envMutRec, mutRecDefns) ||> MutRecShapes.mapTyconsWithEnv (fun envForDecls tyconData -> - let (MutRecDefnsPhase2DataForTycon(tyconOpt, parent, declKind, tcref, _, _, declaredTyconTypars, synMembers, _, _, fixupFinalAttrs)) = tyconData + let (MutRecDefnsPhase2DataForTycon(tyconOpt, _x, declKind, tcref, _, _, declaredTyconTypars, synMembers, _, _, fixupFinalAttrs)) = tyconData // If a tye uses both [] and [] attributes it means it is a static class. let isStaticClass = HasFSharpAttribute g g.attrib_SealedAttribute tcref.Attribs && HasFSharpAttribute g g.attrib_AbstractClassAttribute tcref.Attribs @@ -2056,7 +2051,7 @@ let TcMutRecDefns_Phase2 (cenv: cenv) envInitial mBinds scopem mutRecNSInfo (env let obinds = tyconBindingsOfTypeDefn tyconData let ibinds = // The env with type-scoped `open`s applied - let envForDecls = buildTcEnvWithTypeScopedOpensApplied cenv parent tcref.Range synMembers envForDecls + let envForDecls = buildTcEnvWithTypeScopedOpensApplied cenv scopem synMembers envForDecls let intfTypes = interfacesFromTypeDefn envForDecls tyconData let slotImplSets = DispatchSlotChecking.GetSlotImplSets cenv.infoReader envForDecls.DisplayEnv envForDecls.AccessRights false (List.map (fun (intfTy, _, m) -> (intfTy, m)) intfTypes) (intfTypes, slotImplSets) ||> List.map2 (interfaceMembersFromTypeDefn tyconData) |> List.concat @@ -2345,6 +2340,7 @@ let CheckForDuplicateModule env nm m = // Check the ordering of opens // 'open' declarations must come before all other definitions in type definitions let rec private CheckOpensOrderInTypeDefinition metNonOpen = function +// The implicit constructor maybe on the first one, skip them. | (SynMemberDefn.Open _ | SynMemberDefn.ImplicitCtor _) :: ds when not metNonOpen -> CheckOpensOrderInTypeDefinition false ds | SynMemberDefn.Open (range = m) :: _ -> errorR(Error(FSComp.SR.tcTypeDefinitionsMustHaveOpensBeforeOtherMembers(), m)) | _ :: ds -> CheckOpensOrderInTypeDefinition true ds @@ -3241,7 +3237,7 @@ module EstablishTypeDefinitionCores = let tyconWithImplementsL = (envMutRec, mutRecDefns) ||> MutRecShapes.mapTyconsWithEnv (fun envinner (origInfo, tyconAndAttrsOpt) -> match origInfo, tyconAndAttrsOpt with - | (typeDefCore, memberDefns, parent), Some (tycon, (attrs, _)) -> + | (typeDefCore, memberDefns, _), Some (tycon, (attrs, _)) -> let (MutRecDefnsPhase1DataForTycon(_, synTyconRepr, explicitImplements, _, _, _)) = typeDefCore let m = tycon.Range let tcref = mkLocalTyconRef tycon @@ -3249,7 +3245,8 @@ module EstablishTypeDefinitionCores = let envinner = MakeInnerEnvForTyconRef envinner tcref false // The env with type-scoped `open`s applied - let envinner = buildTcEnvWithTypeScopedOpensApplied cenv parent m memberDefns envinner + // Used to type check TYPENAME in `interface TYPENAME with ...` or `inherit TYPENAME` + let envinner = buildTcEnvWithTypeScopedOpensApplied cenv synTyconRepr.Range memberDefns envinner let implementedTys, _ = List.mapFold (mapFoldFst (TcTypeAndRecover cenv NoNewTypars checkConstraints ItemOccurrence.UseInType WarnOnIWSAM.No envinner)) tpenv explicitImplements if firstPass then @@ -4071,13 +4068,14 @@ module EstablishTypeDefinitionCores = (envMutRecPrelim, withEnvs) ||> MutRecShapes.mapTyconsWithEnv (fun envForDecls (origInfo, tyconOpt) -> match origInfo, tyconOpt with - | (MutRecDefnsPhase1DataForTycon(_, synTyconRepr, _, _, _, _) as typeDefCore, memberDefns, parent), Some tycon -> + | (MutRecDefnsPhase1DataForTycon(_, synTyconRepr, _, _, _, _) as typeDefCore, memberDefns, _), Some tycon -> // The env with type-scoped `open`s applied. + // Used for type check fields on structs. // Only apply when the type is not a union/record/exception, to avoid the field types // can reference a type open in the `with` section. let envForDecls = if synTyconRepr.IsGeneral then - buildTcEnvWithTypeScopedOpensApplied cenv parent m memberDefns envForDecls + buildTcEnvWithTypeScopedOpensApplied cenv synTyconRepr.Range memberDefns envForDecls else envForDecls Some (tycon, GetStructuralElementsOfTyconDefn cenv envForDecls tpenv typeDefCore tycon) | _ -> None) @@ -4125,13 +4123,14 @@ module EstablishTypeDefinitionCores = (envMutRecPrelim, withAttrs) ||> MutRecShapes.mapTyconsWithEnv (fun envForDecls (origInfo, tyconAndAttrsOpt) -> let info = match origInfo, tyconAndAttrsOpt with - | (MutRecDefnsPhase1DataForTycon(_, synTyconRepr, _, _, _, _) as typeDefCore, memberDefns, parent), Some (tycon, (attrs, _)) -> + | (MutRecDefnsPhase1DataForTycon(_, synTyconRepr, _, _, _, _) as typeDefCore, memberDefns, _), Some (tycon, (attrs, _)) -> // The env with type-scoped `open`s applied. + // Used for type check fields. // Only apply when the type is not a union/record/exception, to avoid the field types // can reference a type open in the `with` section. let envForDecls = if synTyconRepr.IsGeneral then - buildTcEnvWithTypeScopedOpensApplied cenv parent m memberDefns envForDecls + buildTcEnvWithTypeScopedOpensApplied cenv synTyconRepr.Range memberDefns envForDecls else envForDecls TcTyconDefnCore_Phase1G_EstablishRepresentation cenv envForDecls tpenv inSig typeDefCore tycon attrs | _ -> None, NoSafeInitInfo diff --git a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs index 1515616a3a0..2c18e15f312 100644 --- a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs @@ -2242,9 +2242,9 @@ let rec TryTranslateComputationExpression Some(translatedCtxt yieldOrReturnCall) - | SynExpr.Open(target, m, body) -> + | SynExpr.Open(target, mOpen, m, body) -> let body = TranslateComputationExpressionNoQueryOps ceenv body - Some(translatedCtxt (SynExpr.Open(target, m, body))) + Some(translatedCtxt (SynExpr.Open(target, mOpen, m, body))) | _ -> None diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index e48153abeec..7b48d510676 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -6091,10 +6091,10 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE | SynExpr.IndexRange (range=m) -> error(Error(FSComp.SR.tcInvalidIndexerExpression(), m)) - | SynExpr.Open (target, m, body) -> - checkLanguageFeatureAndRecover g.langVersion LanguageFeature.ExpressionAndTypeScopedOpens m - let env, _openDecls = TcOpenDecl cenv m body.Range env target - TcLinearExprs (TcExprThatCanBeCtorBody cenv) cenv env overallTy tpenv false body id + | SynExpr.Open (target, mOpen, _m, body) -> + checkLanguageFeatureAndRecover g.langVersion LanguageFeature.ExpressionAndTypeScopedOpens mOpen + let env, _openDecls = TcOpenDecl cenv mOpen body.Range env target + TcExpr cenv overallTy env tpenv body and TcExprMatch (cenv: cenv) overallTy env tpenv synInputExpr spMatch synClauses = let inputExpr, inputTy, tpenv = diff --git a/src/Compiler/Service/ServiceAnalysis.fs b/src/Compiler/Service/ServiceAnalysis.fs index a4b0d9d2709..6455d9f0ff3 100644 --- a/src/Compiler/Service/ServiceAnalysis.fs +++ b/src/Compiler/Service/ServiceAnalysis.fs @@ -118,7 +118,6 @@ module UnusedOpens = AppliedScope = openDecl.AppliedScope } | _ -> None) - |> Array.sortBy (fun openStmt -> openStmt.Range.StartLine) /// Only consider symbol uses which are the first part of a long ident, i.e. with no qualifying identifiers let filterSymbolUses (getSourceLineStr: int -> string) (symbolUses: seq) = diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index 067308e8234..6237d2d4914 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -1495,7 +1495,7 @@ module ParsedInput = -> Some(CompletionContext.Inherit(InheritanceContext.Unknown, ([], None))) - | SynExpr.Open(target, m, _) -> tryMakeOpenDeclarationCtx target m pos + | SynExpr.Open(target, mOpen, _, _) -> tryMakeOpenDeclarationCtx target mOpen pos | _ -> defaultTraverse expr diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index 770ed8da79d..e5c637ebae0 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -773,7 +773,7 @@ type SynExpr = | Dynamic of funcExpr: SynExpr * qmark: range * argExpr: SynExpr * range: range - | Open of target: SynOpenDeclTarget * range: range * body: SynExpr + | Open of target: SynOpenDeclTarget * openDeclRange: range * range: range * body: SynExpr member e.Range = match e with diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index fb96b399429..8ac208a2a22 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -966,7 +966,7 @@ type SynExpr = /// An 'open' definition within an expr /// let open System in ... - | Open of target: SynOpenDeclTarget * range: range * body: SynExpr + | Open of target: SynOpenDeclTarget * openDeclRange: range * range: range * body: SynExpr /// Gets the syntax range of this construct member Range: range diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index f3abb018fa8..20a7dac4058 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -4210,8 +4210,9 @@ declExpr: SynExpr.Do(e, unionRanges (rhs parseState 1).StartRange e.Range) } | openDecl seps typedSequentialExprBlock - { let target, mOpen = $1 - SynExpr.Open(target, mOpen, $3) } + { let target, mOpenDecl = $1 + let mWhole = unionRanges mOpenDecl $3.Range + SynExpr.Open(target, mOpenDecl, mWhole, $3) } | anonMatchingExpr %prec expr_function { $1 } diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 1133ff6e07e..61c16d415ba 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -7355,7 +7355,9 @@ FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Syntax.SynExpr body FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Syntax.SynExpr get_body() FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Syntax.SynOpenDeclTarget get_target() FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Syntax.SynOpenDeclTarget target +FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Text.Range get_openDeclRange() FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Text.Range get_range() +FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Text.Range openDeclRange FSharp.Compiler.Syntax.SynExpr+Open: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynExpr+Paren: FSharp.Compiler.Syntax.SynExpr expr FSharp.Compiler.Syntax.SynExpr+Paren: FSharp.Compiler.Syntax.SynExpr get_expr() @@ -7785,7 +7787,7 @@ FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewNamedIndexedPr FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewNew(Boolean, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewNull(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewObjExpr(FSharp.Compiler.Syntax.SynType, Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[FSharp.Compiler.Syntax.SynExpr,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident]]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynBinding], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynMemberDefn], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynInterfaceImpl], FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) -FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewOpen(FSharp.Compiler.Syntax.SynOpenDeclTarget, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr) +FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewOpen(FSharp.Compiler.Syntax.SynOpenDeclTarget, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewParen(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewQuote(FSharp.Compiler.Syntax.SynExpr, Boolean, FSharp.Compiler.Syntax.SynExpr, Boolean, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewRecord(Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`5[FSharp.Compiler.Syntax.SynType,FSharp.Compiler.Syntax.SynExpr,FSharp.Compiler.Text.Range,Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[FSharp.Compiler.Text.Range,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Position]]],FSharp.Compiler.Text.Range]], Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[FSharp.Compiler.Syntax.SynExpr,System.Tuple`2[FSharp.Compiler.Text.Range,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Position]]]], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynExprRecordField], FSharp.Compiler.Text.Range) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs.bsl index 001a847c944..c19cb62145c 100644 --- a/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs.bsl +++ b/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs.bsl @@ -185,7 +185,7 @@ ImplFile (SynLongIdent ([System; ArgumentException], [(17,24--17,25)], [None; None])), - (17,18--17,42)), (17,8--17,42), + (17,18--17,42)), (17,8--17,42), (17,8--18,22), LongIdent (false, SynLongIdent @@ -195,7 +195,7 @@ ImplFile { LeadingKeyword = Member (16,4--16,10) InlineKeyword = None EqualsRange = Some (16,17--16,18) }), - (16,4--17,42)); + (16,4--18,22)); Interface (LongIdent (SynLongIdent ([IDisposable], [], [None])), Some (20,26--20,30), @@ -603,7 +603,7 @@ ImplFile (SynLongIdent ([System; Int32], [(57,24--57,25)], [None; None])), (57,18--57,30)), - (57,8--57,30), + (57,8--57,30), (57,8--58,31), Record (None, None, [SynExprRecordField @@ -619,7 +619,7 @@ ImplFile { LeadingKeyword = New (56,4--56,7) InlineKeyword = None EqualsRange = Some (56,12--56,13) }), - (56,4--57,30)); + (56,4--58,31)); Open (ModuleOrNamespace (SynLongIdent ([System], [], [None]), (59,9--59,15)), diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent2.fs.bsl index a2e05a0e576..22f893fd43c 100644 --- a/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent2.fs.bsl +++ b/tests/service/data/SyntaxTree/OpenDeclaration/OpenTypeOnSameIndent2.fs.bsl @@ -8,9 +8,9 @@ ImplFile (Paren (Open (ModuleOrNamespace (SynLongIdent ([], [], []), (1,5--1,5)), - (1,1--1,5), Ident System), (1,0--1,1), Some (2,12--2,13), - (1,0--2,13)), (1,0--2,13))], PreXmlDocEmpty, [], None, - (1,0--2,13), { LeadingKeyword = None })], (true, true), + (1,1--1,5), (1,1--2,12), Ident System), (1,0--1,1), + Some (2,12--2,13), (1,0--2,13)), (1,0--2,13))], PreXmlDocEmpty, + [], None, (1,0--2,13), { LeadingKeyword = None })], (true, true), { ConditionalDirectives = [] WarnDirectives = [] CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs.bsl index 221b4285a4d..e510de1d1c6 100644 --- a/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs.bsl +++ b/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs.bsl @@ -190,7 +190,7 @@ ImplFile (SynLongIdent ([System; ArgumentException], [(18,24--18,25)], [None; None])), - (18,18--18,42)), (18,8--18,42), + (18,18--18,42)), (18,8--18,42), (18,8--19,22), LongIdent (false, SynLongIdent @@ -200,7 +200,7 @@ ImplFile { LeadingKeyword = Member (17,4--17,10) InlineKeyword = None EqualsRange = Some (17,17--17,18) }), - (17,4--18,42)); + (17,4--19,22)); Interface (LongIdent (SynLongIdent ([IDisposable], [], [None])), Some (21,26--21,30), @@ -534,7 +534,7 @@ ImplFile (SynLongIdent ([System; Int32], [(46,24--46,25)], [None; None])), (46,18--46,30)), - (46,8--46,30), + (46,8--46,30), (46,8--47,31), Record (None, None, [SynExprRecordField @@ -550,10 +550,10 @@ ImplFile { LeadingKeyword = New (45,4--45,7) InlineKeyword = None EqualsRange = Some (45,12--45,13) }), - (45,4--46,30))], (42,4--46,30)), [], None, - (40,0--46,30), { LeadingKeyword = Type (41,0--41,4) + (45,4--47,31))], (42,4--47,31)), [], None, + (40,0--47,31), { LeadingKeyword = Type (41,0--41,4) EqualsRange = Some (41,9--41,10) - WithKeyword = None })], (40,0--46,30)); + WithKeyword = None })], (40,0--47,31)); Types ([SynTypeDefn (SynComponentInfo diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs.bsl index 40f1912421f..c92c72b1cd2 100644 --- a/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs.bsl +++ b/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs.bsl @@ -49,7 +49,7 @@ ImplFile Open (ModuleOrNamespace (SynLongIdent ([System], [], [None]), (6,9--6,15)), - (6,4--6,15), + (6,4--6,15), (6,4--10,32), Sequential (SuppressNeither, true, App @@ -74,7 +74,7 @@ ImplFile (Type (LongIdent (SynLongIdent ([Console], [], [None])), - (9,14--9,21)), (9,4--9,21), + (9,14--9,21)), (9,4--9,21), (9,4--10,32), App (Atomic, false, Ident WriteLine, Paren @@ -89,14 +89,14 @@ ImplFile Const (Unit, (10,29--10,31)), (10,14--10,31)), (10,13--10,14), Some (10,31--10,32), (10,13--10,32)), - (10,4--10,32))), (7,4--9,21), - { SeparatorRange = None })), (5,4--6,15), + (10,4--10,32))), (7,4--10,32), + { SeparatorRange = None })), (5,4--10,32), { LetOrUseKeyword = (5,4--5,7) InKeyword = None EqualsRange = Some (5,15--5,16) }), (4,4--4,9), NoneAtLet, { LeadingKeyword = Let (4,0--4,3) InlineKeyword = None - EqualsRange = Some (4,10--4,11) })], (4,0--6,15)); + EqualsRange = Some (4,10--4,11) })], (4,0--10,32)); Let (false, [SynBinding @@ -192,6 +192,7 @@ ImplFile (ModuleOrNamespace (SynLongIdent ([System], [], [None]), (16,13--16,19)), (16,8--16,19), + (16,8--17,40), App (Atomic, false, LongIdent @@ -252,24 +253,25 @@ ImplFile SynValData (None, SynValInfo ([], SynArgInfo ([], false, None)), - None), Const (Unit, (21,4--22,19)), None, + None), Const (Unit, (21,4--24,21)), None, Open (ModuleOrNamespace (SynLongIdent ([System], [], [None]), - (22,13--22,19)), (22,8--22,19), + (22,13--22,19)), (22,8--22,19), (22,8--24,21), Open (Type (LongIdent (SynLongIdent ([Console], [], [None])), (23,18--23,25)), (23,8--23,25), + (23,8--24,21), App (NonAtomic, false, Ident WriteLine, Const (Int32 123, (24,18--24,21)), - (24,8--24,21)))), (21,4--22,19), NoneAtDo, + (24,8--24,21)))), (21,4--24,21), NoneAtDo, { LeadingKeyword = Do (21,4--21,6) InlineKeyword = None EqualsRange = None })], false, false, - (21,4--22,19)); + (21,4--24,21)); Member (SynBinding (None, Normal, false, false, [], @@ -297,7 +299,7 @@ ImplFile Open (ModuleOrNamespace (SynLongIdent ([System], [], [None]), - (26,13--26,19)), (26,8--26,19), + (26,13--26,19)), (26,8--26,19), (26,8--27,35), App (Atomic, false, LongIdent @@ -316,15 +318,15 @@ ImplFile { LeadingKeyword = Member (25,4--25,10) InlineKeyword = None EqualsRange = Some (25,36--25,37) }), - (25,4--26,19))], (21,4--26,19)), [], + (25,4--27,35))], (21,4--27,35)), [], Some (ImplicitCtor (None, [], Const (Unit, (20,8--20,10)), None, PreXmlDoc ((20,8), FSharp.Compiler.Xml.XmlDocCollector), - (20,5--20,8), { AsKeyword = None })), (20,5--26,19), + (20,5--20,8), { AsKeyword = None })), (20,5--27,35), { LeadingKeyword = Type (20,0--20,4) EqualsRange = Some (20,11--20,12) - WithKeyword = None })], (20,0--26,19)); + WithKeyword = None })], (20,0--27,35)); Expr (Paren (Open @@ -332,7 +334,7 @@ ImplFile (LongIdent (SynLongIdent ([System; Console], [(32,14--32,15)], [None; None])), - (32,8--32,22)), (31,4--32,22), + (32,8--32,22)), (31,4--32,22), (31,4--33,15), App (Atomic, false, Ident WriteLine, Const (Unit, (33,13--33,15)), (33,4--33,15))), @@ -351,7 +353,7 @@ ImplFile (Open (ModuleOrNamespace (SynLongIdent ([System], [], [None]), - (39,19--39,25)), (39,14--39,25), + (39,19--39,25)), (39,14--39,25), (39,14--39,45), App (NonAtomic, false, App @@ -375,11 +377,12 @@ ImplFile (SynLongIdent ([System; Console], [(40,20--40,21)], [None; None])), (40,14--40,28)), (40,4--40,28), + (40,4--41,20), App (NonAtomic, false, Ident WriteLine, Const (String ("Is 1", Regular, (41,14--41,20)), - (41,14--41,20)), (41,4--41,20))), (39,2--40,28), + (41,14--41,20)), (41,4--41,20))), (39,2--41,20), Yes, { ArrowRange = Some (39,46--39,48) BarRange = Some (39,0--39,1) }); SynMatchClause @@ -396,7 +399,7 @@ ImplFile (ModuleOrNamespace (SynLongIdent ([System; Linq], [(45,20--45,21)], [None; None]), - (45,14--45,25)), (45,9--45,25), + (45,14--45,25)), (45,9--45,25), (45,9--45,50), App (Atomic, false, LongIdent @@ -416,7 +419,7 @@ ImplFile (LongIdent (SynLongIdent ([System; Console], [(46,20--46,21)], [None; None])), - (46,14--46,28)), (46,4--46,28), + (46,14--46,28)), (46,4--46,28), (46,4--47,29), App (NonAtomic, false, Ident WriteLine, Const @@ -432,7 +435,7 @@ ImplFile (LongIdent (SynLongIdent ([System; Int32], [(51,21--51,22)], [None; None])), - (51,15--51,27)), (51,5--51,27), + (51,15--51,27)), (51,5--51,27), (51,5--52,17), App (NonAtomic, false, App @@ -450,7 +453,7 @@ ImplFile (LongIdent (SynLongIdent ([System; Console], [(53,20--53,21)], [None; None])), - (53,14--53,28)), (53,4--53,28), + (53,14--53,28)), (53,4--53,28), (53,4--54,36), App (NonAtomic, false, Ident WriteLine, Const @@ -466,7 +469,7 @@ ImplFile (LongIdent (SynLongIdent ([System; Int32], [(57,20--57,21)], [None; None])), - (57,14--57,26)), (57,4--57,26), + (57,14--57,26)), (57,4--57,26), (57,4--57,48), App (NonAtomic, false, App @@ -484,7 +487,7 @@ ImplFile (LongIdent (SynLongIdent ([System; Console], [(58,20--58,21)], [None; None])), - (58,14--58,28)), (58,4--58,28), + (58,14--58,28)), (58,4--58,28), (58,4--59,49), App (NonAtomic, false, Ident WriteLine, Const @@ -500,7 +503,7 @@ ImplFile (SynLongIdent ([System; Int32], [(60,22--60,23)], [None; None])), (60,16--60,28)), - (60,6--60,28), + (60,6--60,28), (60,6--60,42), App (NonAtomic, false, App @@ -520,7 +523,7 @@ ImplFile (SynLongIdent ([System; Console], [(61,20--61,21)], [None; None])), (61,14--61,28)), - (61,4--61,28), + (61,4--61,28), (61,4--62,36), App (NonAtomic, false, Ident WriteLine, Const @@ -535,7 +538,7 @@ ImplFile (SynLongIdent ([System; Console], [(64,20--64,21)], [None; None])), (64,14--64,28)), - (64,4--64,28), + (64,4--64,28), (64,4--65,36), App (NonAtomic, false, Ident WriteLine, Const @@ -543,17 +546,17 @@ ImplFile ("MaxValue is positive", Regular, (65,14--65,36)), (65,14--65,36)), (65,4--65,36)))), Yes (60,0--60,48), false, - (60,0--64,28), { IfKeyword = (60,0--60,4) + (60,0--65,36), { IfKeyword = (60,0--60,4) IsElif = true ThenKeyword = (60,44--60,48) ElseKeyword = Some (63,0--63,4) IfToThenRange = (60,0--60,48) })), - Yes (57,0--57,54), false, (57,0--64,28), + Yes (57,0--57,54), false, (57,0--65,36), { IfKeyword = (57,0--57,2) IsElif = false ThenKeyword = (57,50--57,54) ElseKeyword = None - IfToThenRange = (57,0--57,54) }), (57,0--64,28)); + IfToThenRange = (57,0--57,54) }), (57,0--65,36)); Expr (TryWith (Open @@ -561,11 +564,11 @@ ImplFile (LongIdent (SynLongIdent ([System; Int32], [(69,20--69,21)], [None; None])), - (69,14--69,26)), (69,4--69,26), + (69,14--69,26)), (69,4--69,26), (69,4--71,24), Open (ModuleOrNamespace (SynLongIdent ([Checked], [], [None]), (70,9--70,16)), - (70,4--70,16), + (70,4--70,16), (70,4--71,24), App (Atomic, false, Ident ignore, Paren @@ -592,6 +595,7 @@ ImplFile (SynLongIdent ([System; Console], [(72,30--72,31)], [None; None])), (72,24--72,38)), (72,14--72,38), + (72,14--72,61), App (NonAtomic, false, Ident WriteLine, LongIdent @@ -599,13 +603,13 @@ ImplFile SynLongIdent ([exn; Message], [(72,53--72,54)], [None; None]), None, (72,50--72,61)), (72,40--72,61))), - (72,7--72,38), Yes, { ArrowRange = Some (72,11--72,13) + (72,7--72,61), Yes, { ArrowRange = Some (72,11--72,13) BarRange = Some (72,5--72,6) })], - (68,0--72,38), Yes (68,0--68,3), Yes (72,0--72,4), + (68,0--72,61), Yes (68,0--68,3), Yes (72,0--72,4), { TryKeyword = (68,0--68,3) TryToWithRange = (68,0--72,4) WithKeyword = (72,0--72,4) - WithToEndRange = (72,0--72,38) }), (68,0--72,38)); + WithToEndRange = (72,0--72,61) }), (68,0--72,61)); Let (false, [SynBinding @@ -625,7 +629,7 @@ ImplFile Open (ModuleOrNamespace (SynLongIdent ([System], [], [None]), (75,25--75,31)), - (75,20--75,31), + (75,20--75,31), (75,20--75,38), App (NonAtomic, false, App @@ -642,7 +646,7 @@ ImplFile Open (ModuleOrNamespace (SynLongIdent ([System], [], [None]), - (75,25--75,31)), (75,20--75,31), + (75,25--75,31)), (75,20--75,31), (75,20--75,38), App (NonAtomic, false, App @@ -654,11 +658,11 @@ ImplFile [Some (OriginalNotation "+")]), None, (75,35--75,36)), Ident x, (75,33--75,36)), Const (Int32 1, (75,37--75,38)), (75,33--75,38)))), - (75,11--75,31), { ArrowRange = Some (75,17--75,19) }), + (75,11--75,38), { ArrowRange = Some (75,17--75,19) }), (75,4--75,8), NoneAtLet, { LeadingKeyword = Let (75,0--75,3) InlineKeyword = None EqualsRange = Some (75,9--75,10) })], - (75,0--75,31)); + (75,0--75,38)); Let (false, [SynBinding @@ -678,7 +682,7 @@ ImplFile (SynLongIdent ([System; Int32], [(76,41--76,42)], [None; None])), (76,35--76,47)), - (76,25--76,47), + (76,25--76,47), (76,25--76,61), App (NonAtomic, false, App @@ -689,13 +693,13 @@ ImplFile ([op_Addition], [], [Some (OriginalNotation "+")]), None, (76,51--76,52)), Ident x, (76,49--76,52)), - Ident MinValue, (76,49--76,61))), (76,20--76,47), + Ident MinValue, (76,49--76,61))), (76,20--76,61), Yes, { ArrowRange = Some (76,22--76,24) BarRange = None })], NoneAtInvisible, - (76,11--76,47)), (76,4--76,8), NoneAtLet, + (76,11--76,61)), (76,4--76,8), NoneAtLet, { LeadingKeyword = Let (76,0--76,3) InlineKeyword = None - EqualsRange = Some (76,9--76,10) })], (76,0--76,47)); + EqualsRange = Some (76,9--76,10) })], (76,0--76,61)); Let (false, [SynBinding @@ -711,7 +715,7 @@ ImplFile Open (ModuleOrNamespace (SynLongIdent ([System], [], [None]), (80,9--80,15)), - (80,4--80,15), + (80,4--80,15), (80,4--83,12), Sequential (SuppressNeither, true, App @@ -782,7 +786,7 @@ ImplFile ([System; Linq; Enumerable], [(89,24--89,25); (89,29--89,30)], [None; None; None])), (89,18--89,40)), - (89,8--89,40), + (89,8--89,40), (89,8--92,30), ForEach (Yes (90,8--90,11), Yes (90,14--90,16), SeqExprOnly false, true, @@ -804,6 +808,7 @@ ImplFile (LongIdent (SynLongIdent ([int], [], [None])), (91,22--91,25)), (91,12--91,25), + (91,12--92,30), YieldOrReturn ((true, false), App diff --git a/vsintegration/tests/UnitTests/UnusedOpensTests.fs b/vsintegration/tests/UnitTests/UnusedOpensTests.fs index 418737fdf84..5fb4da21860 100644 --- a/vsintegration/tests/UnitTests/UnusedOpensTests.fs +++ b/vsintegration/tests/UnitTests/UnusedOpensTests.fs @@ -893,3 +893,17 @@ let _ = File.Create "" """ => [ 5, (9, 18) ] + + +[] +let ``type- and expression-scoped open declaration duplication in module is unused``() = + """ +module TopModule +open System.IO +type T() = + open System.IO + do + open System.IO + File.Create "" +""" + => [ 5, (9, 18); 5, (9, 18); 7, (13, 22) ] From 97705f76335557c56f16d438dc54ea0275cd6127 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Thu, 7 Aug 2025 22:15:11 +0800 Subject: [PATCH 16/22] test --- .../Checking/Expressions/CheckExpressions.fs | 2 +- .../ImportDeclarations/openInTypeDecl.fs | 7 + .../OpenDeclaration/E_openInTypeDecl.fs | 63 -- .../OpenDeclaration/E_openInTypeDecl.fs.bsl | 677 -------------- .../SyntaxTree/OpenDeclaration/InExp_ce.fs | 6 + .../OpenDeclaration/InExp_ce.fs.bsl | 67 ++ .../SyntaxTree/OpenDeclaration/InExp_ce2.fs | 7 + .../OpenDeclaration/InExp_ce2.fs.bsl | 88 ++ .../OpenDeclaration/InExp_dot_lambda.fs | 1 + .../OpenDeclaration/InExp_dot_lambda.fs.bsl | 62 ++ .../SyntaxTree/OpenDeclaration/InExp_for.fs | 3 + .../OpenDeclaration/InExp_for.fs.bsl | 45 + .../SyntaxTree/OpenDeclaration/InExp_fun.fs | 1 + .../OpenDeclaration/InExp_fun.fs.bsl | 63 ++ .../OpenDeclaration/InExp_function.fs | 1 + .../OpenDeclaration/InExp_function.fs.bsl | 47 + .../OpenDeclaration/InExp_if_elif.fs | 9 + .../OpenDeclaration/InExp_if_elif.fs.bsl | 104 +++ .../SyntaxTree/OpenDeclaration/InExp_match.fs | 5 + .../OpenDeclaration/InExp_match.fs.bsl | 61 ++ .../OpenDeclaration/InExp_parenthesis.fs | 5 + .../OpenDeclaration/InExp_parenthesis.fs.bsl | 22 + .../OpenDeclaration/InExp_parenthesis2.fs | 5 + .../OpenDeclaration/InExp_parenthesis2.fs.bsl | 25 + .../OpenDeclaration/InExp_try_with.fs | 5 + .../OpenDeclaration/InExp_try_with.fs.bsl | 44 + .../OpenDeclaration/InExp_type_do.fs | 5 + .../OpenDeclaration/InExp_type_do.fs.bsl | 54 ++ .../OpenDeclaration/InExp_type_let.fs | 5 + .../OpenDeclaration/InExp_type_let.fs.bsl | 56 ++ .../OpenDeclaration/InExp_type_member.fs | 4 + .../OpenDeclaration/InExp_type_member.fs.bsl | 73 ++ .../OpenDeclaration/InExp_type_member2.fs | 2 + .../OpenDeclaration/InExp_type_member2.fs.bsl | 65 ++ .../OpenDeclaration/InExp_type_member3.fs | 2 + .../OpenDeclaration/InExp_type_member3.fs.bsl | 106 +++ .../SyntaxTree/OpenDeclaration/InExp_while.fs | 5 + .../OpenDeclaration/InExp_while.fs.bsl | 44 + .../OpenDeclaration/InInterfaceImplement.fs | 4 + .../InInterfaceImplement.fs.bsl | 67 ++ .../OpenDeclaration/InInterfaceImplement2.fs | 4 + .../InInterfaceImplement2.fs.bsl | 67 ++ .../SyntaxTree/OpenDeclaration/InObjExpr.fs | 4 + .../OpenDeclaration/InObjExpr.fs.bsl | 43 + .../SyntaxTree/OpenDeclaration/InObjExpr2.fs | 4 + .../OpenDeclaration/InObjExpr2.fs.bsl | 43 + .../SyntaxTree/OpenDeclaration/InType_Enum.fs | 3 + .../OpenDeclaration/InType_Enum.fs.bsl | 32 + .../OpenDeclaration/InType_Exception.fs | 4 + .../OpenDeclaration/InType_Exception.fs.bsl | 72 ++ .../OpenDeclaration/InType_Extension.fs | 3 + .../OpenDeclaration/InType_Extension.fs.bsl | 53 ++ .../OpenDeclaration/InType_Extension2.fs | 3 + .../OpenDeclaration/InType_Extension2.fs.bsl | 53 ++ .../OpenDeclaration/InType_Record.fs | 4 + .../OpenDeclaration/InType_Record.fs.bsl | 75 ++ .../OpenDeclaration/InType_Record2.fs | 4 + .../OpenDeclaration/InType_Record2.fs.bsl | 75 ++ .../OpenDeclaration/InType_Record3.fs | 5 + .../OpenDeclaration/InType_Record3.fs.bsl | 71 ++ .../OpenDeclaration/InType_Record4.fs | 5 + .../OpenDeclaration/InType_Record4.fs.bsl | 12 + .../OpenDeclaration/InType_Struct.fs | 8 + .../OpenDeclaration/InType_Struct.fs.bsl | 95 ++ .../OpenDeclaration/InType_Struct2.fs | 8 + .../OpenDeclaration/InType_Struct2.fs.bsl | 95 ++ .../OpenDeclaration/InType_Union.fs | 4 + .../OpenDeclaration/InType_Union.fs.bsl | 81 ++ .../OpenDeclaration/InType_Union2.fs | 4 + .../OpenDeclaration/InType_Union2.fs.bsl | 81 ++ .../OpenDeclaration/InType_Union3.fs | 5 + .../OpenDeclaration/InType_Union3.fs.bsl | 71 ++ .../OpenDeclaration/InType_Union4.fs | 5 + .../OpenDeclaration/InType_Union4.fs.bsl | 12 + .../OpenInObjExprOrInterface.fs | 9 - .../OpenInObjExprOrInterface.fs.bsl | 99 -- .../OpenDeclaration/OpenInTypeWithWrongPos.fs | 11 - .../OpenInTypeWithWrongPos.fs.bsl | 13 - .../OpenDeclaration/openInTypeDecl.fs | 51 -- .../OpenDeclaration/openInTypeDecl.fs.bsl | 604 ------------- .../OpenDeclaration/openModInFun.fs | 93 -- .../OpenDeclaration/openModInFun.fs.bsl | 848 ------------------ 82 files changed, 2284 insertions(+), 2469 deletions(-) delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce2.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce2.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_dot_lambda.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_dot_lambda.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_for.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_for.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_fun.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_fun.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_function.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_function.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_if_elif.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_if_elif.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_match.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_match.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis2.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis2.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_try_with.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_try_with.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_do.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_do.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_let.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_let.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member2.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member2.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member3.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member3.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_while.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InExp_while.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr2.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr2.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs.bsl create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs create mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs.bsl diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 7b48d510676..eede534bafc 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -6094,7 +6094,7 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE | SynExpr.Open (target, mOpen, _m, body) -> checkLanguageFeatureAndRecover g.langVersion LanguageFeature.ExpressionAndTypeScopedOpens mOpen let env, _openDecls = TcOpenDecl cenv mOpen body.Range env target - TcExpr cenv overallTy env tpenv body + TcExprThatCanBeCtorBody cenv overallTy env tpenv body and TcExprMatch (cenv: cenv) overallTy env tpenv synInputExpr spMatch synClauses = let inputExpr, inputTy, tpenv = diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs index dcca61fa898..2bb588eaaa1 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs @@ -49,3 +49,10 @@ type ABC = type System.Int32 with open type System.Math member this.Abs111 = Abs(this) + +type IA = + open System + open type Int32 + open System.Collections.Generic + inherit IDisposable + inherit IEquatable diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs b/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs deleted file mode 100644 index 1d95c4c623e..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs +++ /dev/null @@ -1,63 +0,0 @@ -// #Regression #Conformance #DeclarationElements #Import -module openInTypeDecl - -type Foo() = - open type System.DateTime - - inherit Object() - - [] val mutable x: Int64 - let x = 42 - let timeConstructed = Now.Ticks - do printfn "%d" Int32.MaxValue - static member Now () = DateTime.Now - member val TimeConstructed = timeConstructed with get, set - - member _.M() = - open type System.ArgumentException - Int32.MaxValue - - interface IDisposable with - member this.Dispose (): unit = - raise (NotImplementedException()) - open global.System - -type A = A of int - with - member _.RandomNumber with get() = Random().Next() - open System - -type ARecord = { A : int } - with - member _.RandomNumber with get() = Random().Next() - open System - -exception AException of int - with - member _.RandomNumber with get() = Random().Next() - open System - -type B = A of Int32 - with - open System - -exception BException of Int32 - with - open System - -type BRecord = { A : Int32 } - with - open System - -[] -type ABC = - val a: Int32 - val b: Int32 - new (a) = - open type System.Int32 - { a = a; b = MinValue } - open System - -type System.Int32 with - member this.Abs111 = Abs(this) - open type System.Math diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs.bsl deleted file mode 100644 index c19cb62145c..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/E_openInTypeDecl.fs.bsl +++ /dev/null @@ -1,677 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/E_openInTypeDecl.fs", false, - QualifiedNameOfFile openInTypeDecl, [], - [SynModuleOrNamespace - ([openInTypeDecl], false, NamedModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [Foo], - PreXmlDoc ((4,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (4,5--4,8)), - ObjectModel - (Unspecified, - [ImplicitCtor - (None, [], Const (Unit, (4,8--4,10)), None, - PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), - (4,5--4,8), { AsKeyword = None }); - Open - (Type - (LongIdent - (SynLongIdent - ([System; DateTime], [(5,20--5,21)], - [None; None])), (5,14--5,29)), (5,4--5,29)); - ImplicitInherit - (LongIdent (SynLongIdent ([Object], [], [None])), - Const (Unit, (7,18--7,20)), None, (7,4--7,20), - { InheritKeyword = (7,4--7,11) }); - ValField - (SynField - ([{ Attributes = - [{ TypeName = - SynLongIdent ([DefaultValue], [], [None]) - ArgExpr = Const (Unit, (9,6--9,18)) - Target = None - AppliesToGetterAndSetter = false - Range = (9,6--9,18) }] - Range = (9,4--9,20) }], false, Some x, - LongIdent (SynLongIdent ([Int64], [], [None])), true, - PreXmlDoc ((9,4), FSharp.Compiler.Xml.XmlDocCollector), - None, (9,4--9,41), - { LeadingKeyword = Some (Val (9,21--9,24)) - MutableKeyword = Some (9,25--9,32) }), (9,4--9,41)); - LetBindings - ([SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((10,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, - SynValInfo ([], SynArgInfo ([], false, None)), - None), - Named - (SynIdent (x, None), false, None, (10,8--10,9)), - None, Const (Int32 42, (10,12--10,14)), - (10,8--10,9), Yes (10,4--10,14), - { LeadingKeyword = Let (10,4--10,7) - InlineKeyword = None - EqualsRange = Some (10,10--10,11) })], false, - false, (10,4--10,14)); - LetBindings - ([SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((11,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, - SynValInfo ([], SynArgInfo ([], false, None)), - None), - Named - (SynIdent (timeConstructed, None), false, None, - (11,8--11,23)), None, - LongIdent - (false, - SynLongIdent - ([Now; Ticks], [(11,29--11,30)], [None; None]), - None, (11,26--11,35)), (11,8--11,23), - Yes (11,4--11,35), - { LeadingKeyword = Let (11,4--11,7) - InlineKeyword = None - EqualsRange = Some (11,24--11,25) })], false, - false, (11,4--11,35)); - LetBindings - ([SynBinding - (None, Do, false, false, [], PreXmlDocEmpty, - SynValData - (None, - SynValInfo ([], SynArgInfo ([], false, None)), - None), Const (Unit, (12,4--12,34)), None, - App - (NonAtomic, false, - App - (NonAtomic, false, Ident printfn, - Const - (String ("%d", Regular, (12,15--12,19)), - (12,15--12,19)), (12,7--12,19)), - LongIdent - (false, - SynLongIdent - ([Int32; MaxValue], [(12,25--12,26)], - [None; None]), None, (12,20--12,34)), - (12,7--12,34)), (12,4--12,34), NoneAtDo, - { LeadingKeyword = Do (12,4--12,6) - InlineKeyword = None - EqualsRange = None })], false, false, - (12,4--12,34)); - Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((13,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = false - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - SynValInfo ([[]], SynArgInfo ([], false, None)), - None), - LongIdent - (SynLongIdent ([Now], [], [None]), None, None, - Pats - [Paren - (Const (Unit, (13,22--13,24)), - (13,22--13,24))], None, (13,18--13,24)), - None, - LongIdent - (false, - SynLongIdent - ([DateTime; Now], [(13,35--13,36)], - [None; None]), None, (13,27--13,39)), - (13,18--13,24), NoneAtInvisible, - { LeadingKeyword = - StaticMember ((13,4--13,10), (13,11--13,17)) - InlineKeyword = None - EqualsRange = Some (13,25--13,26) }), - (13,4--13,39)); - AutoProperty - ([], false, TimeConstructed, None, PropertyGetSet, - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertySet }, - PreXmlDoc ((14,4), FSharp.Compiler.Xml.XmlDocCollector), - GetSet (None, None, None), Ident timeConstructed, - (14,4--14,62), - { LeadingKeyword = - MemberVal ((14,4--14,10), (14,11--14,14)) - WithKeyword = Some (14,49--14,53) - EqualsRange = Some (14,31--14,32) - GetSetKeywords = - Some (GetSet ((14,54--14,57), (14,59--14,62))) }); - Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((16,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; M], [(16,12--16,13)], [None; None]), None, - None, - Pats - [Paren - (Const (Unit, (16,14--16,16)), - (16,14--16,16))], None, (16,11--16,16)), - None, - Open - (Type - (LongIdent - (SynLongIdent - ([System; ArgumentException], - [(17,24--17,25)], [None; None])), - (17,18--17,42)), (17,8--17,42), (17,8--18,22), - LongIdent - (false, - SynLongIdent - ([Int32; MaxValue], [(18,13--18,14)], - [None; None]), None, (18,8--18,22))), - (16,11--16,16), NoneAtInvisible, - { LeadingKeyword = Member (16,4--16,10) - InlineKeyword = None - EqualsRange = Some (16,17--16,18) }), - (16,4--18,22)); - Interface - (LongIdent (SynLongIdent ([IDisposable], [], [None])), - Some (20,26--20,30), - Some - [Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((21,8), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = true - IsFinal = false - GetterOrSetterIsCompilerGenerated = - false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([this; Dispose], [(21,19--21,20)], - [None; None]), None, None, - Pats - [Paren - (Const (Unit, (21,28--21,30)), - (21,28--21,30))], None, - (21,15--21,30)), - Some - (SynBindingReturnInfo - (LongIdent - (SynLongIdent ([unit], [], [None])), - (21,32--21,36), [], - { ColonRange = Some (21,30--21,31) })), - Typed - (App - (NonAtomic, false, Ident raise, - Paren - (App - (Atomic, false, - Ident NotImplementedException, - Const (Unit, (22,42--22,44)), - (22,19--22,44)), (22,18--22,19), - Some (22,44--22,45), (22,18--22,45)), - (22,12--22,45)), - LongIdent - (SynLongIdent ([unit], [], [None])), - (22,12--22,45)), (21,15--21,30), - NoneAtInvisible, - { LeadingKeyword = Member (21,8--21,14) - InlineKeyword = None - EqualsRange = Some (21,37--21,38) }), - (21,8--22,45))], (20,4--22,45)); - Open - (ModuleOrNamespace - (SynLongIdent - ([`global`; System], [(23,15--23,16)], - [Some (OriginalNotation "global"); None]), - (23,9--23,22)), (23,4--23,22))], (5,4--23,22)), [], - Some - (ImplicitCtor - (None, [], Const (Unit, (4,8--4,10)), None, - PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), - (4,5--4,8), { AsKeyword = None })), (4,5--23,22), - { LeadingKeyword = Type (4,0--4,4) - EqualsRange = Some (4,11--4,12) - WithKeyword = None })], (4,0--23,22)); - Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [A], - PreXmlDoc ((25,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (25,5--25,6)), - Simple - (Union - (None, - [SynUnionCase - ([], SynIdent (A, None), - Fields - [SynField - ([], false, None, - LongIdent (SynLongIdent ([int], [], [None])), - false, - PreXmlDoc ((25,14), FSharp.Compiler.Xml.XmlDocCollector), - None, (25,14--25,17), - { LeadingKeyword = None - MutableKeyword = None })], - PreXmlDoc ((25,9), FSharp.Compiler.Xml.XmlDocCollector), - None, (25,9--25,17), { BarRange = None })], - (25,9--25,17)), (25,9--25,17)), - [GetSetMember - (Some - (SynBinding - (None, Normal, false, false, [], - PreXmlMerge - (PreXmlDoc ((27,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertyGet }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; RandomNumber], [(27,16--27,17)], - [None; None]), Some get, None, - Pats - [Paren - (Const (Unit, (27,38--27,40)), - (27,38--27,40))], None, (27,35--27,40)), - None, - App - (Atomic, false, - DotGet - (App - (Atomic, false, Ident Random, - Const (Unit, (27,49--27,51)), - (27,43--27,51)), (27,51--27,52), - SynLongIdent ([Next], [], [None]), - (27,43--27,56)), Const (Unit, (27,56--27,58)), - (27,43--27,58)), (27,35--27,40), NoneAtInvisible, - { LeadingKeyword = Member (27,8--27,14) - InlineKeyword = None - EqualsRange = Some (27,41--27,42) })), None, - (27,8--27,58), { InlineKeyword = None - WithKeyword = (27,30--27,34) - GetKeyword = Some (27,35--27,38) - AndKeyword = None - SetKeyword = None }); - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (28,13--28,19)), - (28,8--28,19))], None, (25,5--28,19), - { LeadingKeyword = Type (25,0--25,4) - EqualsRange = Some (25,7--25,8) - WithKeyword = Some (26,4--26,8) })], (25,0--28,19)); - Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [ARecord], - PreXmlDoc ((30,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (30,5--30,12)), - Simple - (Record - (None, - [SynField - ([], false, Some A, - LongIdent (SynLongIdent ([int], [], [None])), false, - PreXmlDoc ((30,17), FSharp.Compiler.Xml.XmlDocCollector), - None, (30,17--30,24), { LeadingKeyword = None - MutableKeyword = None })], - (30,15--30,26)), (30,15--30,26)), - [GetSetMember - (Some - (SynBinding - (None, Normal, false, false, [], - PreXmlMerge - (PreXmlDoc ((32,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertyGet }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; RandomNumber], [(32,16--32,17)], - [None; None]), Some get, None, - Pats - [Paren - (Const (Unit, (32,38--32,40)), - (32,38--32,40))], None, (32,35--32,40)), - None, - App - (Atomic, false, - DotGet - (App - (Atomic, false, Ident Random, - Const (Unit, (32,49--32,51)), - (32,43--32,51)), (32,51--32,52), - SynLongIdent ([Next], [], [None]), - (32,43--32,56)), Const (Unit, (32,56--32,58)), - (32,43--32,58)), (32,35--32,40), NoneAtInvisible, - { LeadingKeyword = Member (32,8--32,14) - InlineKeyword = None - EqualsRange = Some (32,41--32,42) })), None, - (32,8--32,58), { InlineKeyword = None - WithKeyword = (32,30--32,34) - GetKeyword = Some (32,35--32,38) - AndKeyword = None - SetKeyword = None }); - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (33,13--33,19)), - (33,8--33,19))], None, (30,5--33,19), - { LeadingKeyword = Type (30,0--30,4) - EqualsRange = Some (30,13--30,14) - WithKeyword = Some (31,4--31,8) })], (30,0--33,19)); - Exception - (SynExceptionDefn - (SynExceptionDefnRepr - ([], - SynUnionCase - ([], SynIdent (AException, None), - Fields - [SynField - ([], false, None, - LongIdent (SynLongIdent ([int], [], [None])), false, - PreXmlDoc ((35,24), FSharp.Compiler.Xml.XmlDocCollector), - None, (35,24--35,27), { LeadingKeyword = None - MutableKeyword = None })], - PreXmlDocEmpty, None, (35,10--35,27), { BarRange = None }), - None, - PreXmlDoc ((35,0), FSharp.Compiler.Xml.XmlDocCollector), - None, (35,0--35,27)), Some (36,4--36,8), - [GetSetMember - (Some - (SynBinding - (None, Normal, false, false, [], - PreXmlMerge - (PreXmlDoc ((37,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertyGet }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; RandomNumber], [(37,16--37,17)], - [None; None]), Some get, None, - Pats - [Paren - (Const (Unit, (37,38--37,40)), (37,38--37,40))], - None, (37,35--37,40)), None, - App - (Atomic, false, - DotGet - (App - (Atomic, false, Ident Random, - Const (Unit, (37,49--37,51)), (37,43--37,51)), - (37,51--37,52), - SynLongIdent ([Next], [], [None]), - (37,43--37,56)), Const (Unit, (37,56--37,58)), - (37,43--37,58)), (37,35--37,40), NoneAtInvisible, - { LeadingKeyword = Member (37,8--37,14) - InlineKeyword = None - EqualsRange = Some (37,41--37,42) })), None, - (37,8--37,58), { InlineKeyword = None - WithKeyword = (37,30--37,34) - GetKeyword = Some (37,35--37,38) - AndKeyword = None - SetKeyword = None }); - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (38,13--38,19)), - (38,8--38,19))], (35,0--38,19)), (35,0--38,19)); - Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [B], - PreXmlDoc ((40,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (40,5--40,6)), - Simple - (Union - (None, - [SynUnionCase - ([], SynIdent (A, None), - Fields - [SynField - ([], false, None, - LongIdent (SynLongIdent ([Int32], [], [None])), - false, - PreXmlDoc ((40,14), FSharp.Compiler.Xml.XmlDocCollector), - None, (40,14--40,19), - { LeadingKeyword = None - MutableKeyword = None })], - PreXmlDoc ((40,9), FSharp.Compiler.Xml.XmlDocCollector), - None, (40,9--40,19), { BarRange = None })], - (40,9--40,19)), (40,9--40,19)), - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (42,13--42,19)), - (42,8--42,19))], None, (40,5--42,19), - { LeadingKeyword = Type (40,0--40,4) - EqualsRange = Some (40,7--40,8) - WithKeyword = Some (41,4--41,8) })], (40,0--42,19)); - Exception - (SynExceptionDefn - (SynExceptionDefnRepr - ([], - SynUnionCase - ([], SynIdent (BException, None), - Fields - [SynField - ([], false, None, - LongIdent (SynLongIdent ([Int32], [], [None])), - false, - PreXmlDoc ((44,24), FSharp.Compiler.Xml.XmlDocCollector), - None, (44,24--44,29), { LeadingKeyword = None - MutableKeyword = None })], - PreXmlDocEmpty, None, (44,10--44,29), { BarRange = None }), - None, - PreXmlDoc ((44,0), FSharp.Compiler.Xml.XmlDocCollector), - None, (44,0--44,29)), Some (45,4--45,8), - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (46,13--46,19)), - (46,8--46,19))], (44,0--46,19)), (44,0--46,19)); - Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [BRecord], - PreXmlDoc ((48,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (48,5--48,12)), - Simple - (Record - (None, - [SynField - ([], false, Some A, - LongIdent (SynLongIdent ([Int32], [], [None])), - false, - PreXmlDoc ((48,17), FSharp.Compiler.Xml.XmlDocCollector), - None, (48,17--48,26), { LeadingKeyword = None - MutableKeyword = None })], - (48,15--48,28)), (48,15--48,28)), - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (50,13--50,19)), - (50,8--50,19))], None, (48,5--50,19), - { LeadingKeyword = Type (48,0--48,4) - EqualsRange = Some (48,13--48,14) - WithKeyword = Some (49,4--49,8) })], (48,0--50,19)); - Types - ([SynTypeDefn - (SynComponentInfo - ([{ Attributes = - [{ TypeName = SynLongIdent ([Struct], [], [None]) - ArgExpr = Const (Unit, (52,2--52,8)) - Target = None - AppliesToGetterAndSetter = false - Range = (52,2--52,8) }] - Range = (52,0--52,10) }], None, [], [ABC], - PreXmlDoc ((52,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (53,5--53,8)), - ObjectModel - (Unspecified, - [ValField - (SynField - ([], false, Some a, - LongIdent (SynLongIdent ([Int32], [], [None])), - false, - PreXmlDoc ((54,4), FSharp.Compiler.Xml.XmlDocCollector), - None, (54,4--54,16), - { LeadingKeyword = Some (Val (54,4--54,7)) - MutableKeyword = None }), (54,4--54,16)); - ValField - (SynField - ([], false, Some b, - LongIdent (SynLongIdent ([Int32], [], [None])), - false, - PreXmlDoc ((55,4), FSharp.Compiler.Xml.XmlDocCollector), - None, (55,4--55,16), - { LeadingKeyword = Some (Val (55,4--55,7)) - MutableKeyword = None }), (55,4--55,16)); - Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((56,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = false - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Constructor }, - SynValInfo - ([[SynArgInfo ([], false, Some a)]], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent ([new], [], [None]), None, - Some (SynValTyparDecls (None, false)), - Pats - [Paren - (Named - (SynIdent (a, None), false, None, - (56,9--56,10)), (56,8--56,11))], None, - (56,4--56,7)), None, - Open - (Type - (LongIdent - (SynLongIdent - ([System; Int32], [(57,24--57,25)], - [None; None])), (57,18--57,30)), - (57,8--57,30), (57,8--58,31), - Record - (None, None, - [SynExprRecordField - ((SynLongIdent ([a], [], [None]), true), - Some (58,12--58,13), Some (Ident a), - (58,10--58,15), - Some ((58,15--58,16), Some (58,16))); - SynExprRecordField - ((SynLongIdent ([b], [], [None]), true), - Some (58,19--58,20), Some (Ident MinValue), - (58,17--58,29), None)], (58,8--58,31))), - (56,4--56,11), NoneAtInvisible, - { LeadingKeyword = New (56,4--56,7) - InlineKeyword = None - EqualsRange = Some (56,12--56,13) }), - (56,4--58,31)); - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (59,9--59,15)), - (59,4--59,15))], (54,4--59,15)), [], None, - (52,0--59,15), { LeadingKeyword = Type (53,0--53,4) - EqualsRange = Some (53,9--53,10) - WithKeyword = None })], (52,0--59,15)); - Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [System; Int32], - PreXmlDoc ((61,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (61,5--61,17)), - ObjectModel (Augmentation (61,18--61,22), [], (61,5--63,25)), - [Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((62,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([this; Abs111], [(62,15--62,16)], [None; None]), - None, None, Pats [], None, (62,11--62,22)), None, - App - (Atomic, false, Ident Abs, - Paren - (Ident this, (62,28--62,29), Some (62,33--62,34), - (62,28--62,34)), (62,25--62,34)), (62,11--62,22), - NoneAtInvisible, - { LeadingKeyword = Member (62,4--62,10) - InlineKeyword = None - EqualsRange = Some (62,23--62,24) }), (62,4--62,34)); - Open - (Type - (LongIdent - (SynLongIdent - ([System; Math], [(63,20--63,21)], [None; None])), - (63,14--63,25)), (63,4--63,25))], None, (61,5--63,25), - { LeadingKeyword = Type (61,0--61,4) - EqualsRange = None - WithKeyword = None })], (61,0--63,25))], - PreXmlDoc ((2,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, - (2,0--63,25), { LeadingKeyword = Module (2,0--2,6) })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [LineComment (1,0--1,57)] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce.fs new file mode 100644 index 00000000000..555f5c9c4d5 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce.fs @@ -0,0 +1,6 @@ +let res = async { + open System + Console.WriteLine("Hello, World!") + let! x = Async.Sleep 1000 + return x +} \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce.fs.bsl new file mode 100644 index 00000000000..283138192ba --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce.fs.bsl @@ -0,0 +1,67 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_ce.fs", false, QualifiedNameOfFile InExp_ce, + [], + [SynModuleOrNamespace + ([InExp_ce], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Named (SynIdent (res, None), false, None, (1,4--1,7)), None, + App + (NonAtomic, false, Ident async, + ComputationExpr + (false, + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (2,9--2,15)), + (2,4--2,15), (2,4--5,12), + Sequential + (SuppressNeither, true, + App + (Atomic, false, + LongIdent + (false, + SynLongIdent + ([Console; WriteLine], [(3,11--3,12)], + [None; None]), None, (3,4--3,21)), + Paren + (Const + (String + ("Hello, World!", Regular, (3,22--3,37)), + (3,22--3,37)), (3,21--3,22), + Some (3,37--3,38), (3,21--3,38)), + (3,4--3,38)), + LetOrUseBang + (Yes (4,4--4,29), false, true, + Named + (SynIdent (x, None), false, None, (4,9--4,10)), + App + (NonAtomic, false, + LongIdent + (false, + SynLongIdent + ([Async; Sleep], [(4,18--4,19)], + [None; None]), None, (4,13--4,24)), + Const (Int32 1000, (4,25--4,29)), + (4,13--4,29)), [], + YieldOrReturn + ((false, true), Ident x, (5,4--5,12), + { YieldOrReturnKeyword = (5,4--5,10) }), + (4,4--5,12), + { LetOrUseKeyword = (4,4--4,8) + InKeyword = None + EqualsRange = Some (4,11--4,12) }), + (3,4--5,12), { SeparatorRange = None })), + (1,16--6,1)), (1,10--6,1)), (1,4--1,7), NoneAtLet, + { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,8--1,9) })], (1,0--6,1))], + PreXmlDocEmpty, [], None, (1,0--6,1), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce2.fs new file mode 100644 index 00000000000..c60327445e9 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce2.fs @@ -0,0 +1,7 @@ +let q = + query { + open type System.Linq.Enumerable + for i in Range(1, 10) do + open type int + yield MinValue + i + } |> Seq.toArray diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce2.fs.bsl new file mode 100644 index 00000000000..00d49e26eae --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_ce2.fs.bsl @@ -0,0 +1,88 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_ce2.fs", false, QualifiedNameOfFile InExp_ce2, + [], + [SynModuleOrNamespace + ([InExp_ce2], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Named (SynIdent (q, None), false, None, (1,4--1,5)), None, + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_PipeRight], [], [Some (OriginalNotation "|>")]), + None, (7,6--7,8)), + App + (NonAtomic, false, Ident query, + ComputationExpr + (false, + Open + (Type + (LongIdent + (SynLongIdent + ([System; Linq; Enumerable], + [(3,24--3,25); (3,29--3,30)], + [None; None; None])), (3,18--3,40)), + (3,8--3,40), (3,8--6,30), + ForEach + (Yes (4,8--4,11), Yes (4,14--4,16), + SeqExprOnly false, true, + Named + (SynIdent (i, None), false, None, + (4,12--4,13)), + App + (Atomic, false, Ident Range, + Paren + (Tuple + (false, + [Const (Int32 1, (4,23--4,24)); + Const (Int32 10, (4,26--4,28))], + [(4,24--4,25)], (4,23--4,28)), + (4,22--4,23), Some (4,28--4,29), + (4,22--4,29)), (4,17--4,29)), + Open + (Type + (LongIdent + (SynLongIdent ([int], [], [None])), + (5,22--5,25)), (5,12--5,25), + (5,12--6,30), + YieldOrReturn + ((true, false), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Addition], [], + [Some + (OriginalNotation "+")]), + None, (6,27--6,28)), + Ident MinValue, (6,18--6,28)), + Ident i, (6,18--6,30)), + (6,12--6,30), + { YieldOrReturnKeyword = (6,12--6,17) })), + (4,8--6,30))), (2,10--7,5)), (2,4--7,5)), + (2,4--7,8)), + LongIdent + (false, + SynLongIdent + ([Seq; toArray], [(7,12--7,13)], [None; None]), None, + (7,9--7,20)), (2,4--7,20)), (1,4--1,5), NoneAtLet, + { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,6--1,7) })], (1,0--7,20))], + PreXmlDocEmpty, [], None, (1,0--8,0), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_dot_lambda.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_dot_lambda.fs new file mode 100644 index 00000000000..9175cec5bf1 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_dot_lambda.fs @@ -0,0 +1 @@ +1 |> _.(open Checked; fun x -> x + 1) \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_dot_lambda.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_dot_lambda.fs.bsl new file mode 100644 index 00000000000..71f6ffba31d --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_dot_lambda.fs.bsl @@ -0,0 +1,62 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_dot_lambda.fs", false, + QualifiedNameOfFile InExp_dot_lambda, [], + [SynModuleOrNamespace + ([InExp_dot_lambda], false, AnonModule, + [Expr + (App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_PipeRight], [], [Some (OriginalNotation "|>")]), + None, (1,2--1,4)), Const (Int32 1, (1,0--1,1)), + (1,0--1,4)), + DotLambda + (Paren + (Open + (ModuleOrNamespace + (SynLongIdent ([Checked], [], [None]), (1,13--1,20)), + (1,8--1,20), (1,8--1,36), + Lambda + (false, false, + SimplePats + ([Id (x, None, false, false, false, (1,26--1,27))], + [], (1,26--1,27)), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Addition], [], + [Some (OriginalNotation "+")]), None, + (1,33--1,34)), Ident x, (1,31--1,34)), + Const (Int32 1, (1,35--1,36)), (1,31--1,36)), + Some + ([Named + (SynIdent (x, None), false, None, + (1,26--1,27))], + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Addition], [], + [Some (OriginalNotation "+")]), None, + (1,33--1,34)), Ident x, (1,31--1,34)), + Const (Int32 1, (1,35--1,36)), (1,31--1,36))), + (1,22--1,36), { ArrowRange = Some (1,28--1,30) })), + (1,7--1,8), Some (1,36--1,37), (1,7--1,37)), (1,5--1,37), + { UnderscoreRange = (1,5--1,6) + DotRange = (1,6--1,7) }), (1,0--1,37)), (1,0--1,37))], + PreXmlDocEmpty, [], None, (1,0--1,37), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_for.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_for.fs new file mode 100644 index 00000000000..172ac0fc907 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_for.fs @@ -0,0 +1,3 @@ +for _ in open System.Linq; Enumerable.Range(0, 10) do + open type System.Console + WriteLine "Hello, World!" diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_for.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_for.fs.bsl new file mode 100644 index 00000000000..3edfbf4ded0 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_for.fs.bsl @@ -0,0 +1,45 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_for.fs", false, QualifiedNameOfFile InExp_for, + [], + [SynModuleOrNamespace + ([InExp_for], false, AnonModule, + [Expr + (ForEach + (Yes (1,0--1,3), Yes (1,6--1,8), SeqExprOnly false, true, + Wild (1,4--1,5), + Open + (ModuleOrNamespace + (SynLongIdent + ([System; Linq], [(1,20--1,21)], [None; None]), + (1,14--1,25)), (1,9--1,25), (1,9--1,50), + App + (Atomic, false, + LongIdent + (false, + SynLongIdent + ([Enumerable; Range], [(1,37--1,38)], [None; None]), + None, (1,27--1,43)), + Paren + (Tuple + (false, + [Const (Int32 0, (1,44--1,45)); + Const (Int32 10, (1,47--1,49))], [(1,45--1,46)], + (1,44--1,49)), (1,43--1,44), Some (1,49--1,50), + (1,43--1,50)), (1,27--1,50))), + Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(2,20--2,21)], [None; None])), + (2,14--2,28)), (2,4--2,28), (2,4--3,29), + App + (NonAtomic, false, Ident WriteLine, + Const + (String ("Hello, World!", Regular, (3,14--3,29)), + (3,14--3,29)), (3,4--3,29))), (1,0--3,29)), + (1,0--3,29))], PreXmlDocEmpty, [], None, (1,0--4,0), + { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_fun.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_fun.fs new file mode 100644 index 00000000000..f883dc3b2c2 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_fun.fs @@ -0,0 +1 @@ +let fun1 = fun x -> open System; x + 1 \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_fun.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_fun.fs.bsl new file mode 100644 index 00000000000..7ca76ee812f --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_fun.fs.bsl @@ -0,0 +1,63 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_fun.fs", false, QualifiedNameOfFile InExp_fun, + [], + [SynModuleOrNamespace + ([InExp_fun], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo + ([[SynArgInfo ([], false, Some x)]], + SynArgInfo ([], false, None)), None), + Named (SynIdent (fun1, None), false, None, (1,4--1,8)), None, + Lambda + (false, false, + SimplePats + ([Id (x, None, false, false, false, (1,15--1,16))], [], + (1,15--1,16)), + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (1,25--1,31)), + (1,20--1,31), (1,20--1,38), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Addition], [], + [Some (OriginalNotation "+")]), None, + (1,35--1,36)), Ident x, (1,33--1,36)), + Const (Int32 1, (1,37--1,38)), (1,33--1,38))), + Some + ([Named (SynIdent (x, None), false, None, (1,15--1,16))], + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (1,25--1,31)), + (1,20--1,31), (1,20--1,38), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Addition], [], + [Some (OriginalNotation "+")]), None, + (1,35--1,36)), Ident x, (1,33--1,36)), + Const (Int32 1, (1,37--1,38)), (1,33--1,38)))), + (1,11--1,38), { ArrowRange = Some (1,17--1,19) }), + (1,4--1,8), NoneAtLet, { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,9--1,10) })], + (1,0--1,38))], PreXmlDocEmpty, [], None, (1,0--1,38), + { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_function.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_function.fs new file mode 100644 index 00000000000..86a6b49be50 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_function.fs @@ -0,0 +1 @@ +let fun2 = function x -> open type System.Int32; x + MinValue \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_function.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_function.fs.bsl new file mode 100644 index 00000000000..95fd66562ae --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_function.fs.bsl @@ -0,0 +1,47 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_function.fs", false, + QualifiedNameOfFile InExp_function, [], + [SynModuleOrNamespace + ([InExp_function], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Named (SynIdent (fun2, None), false, None, (1,4--1,8)), None, + MatchLambda + (false, (1,11--1,19), + [SynMatchClause + (Named (SynIdent (x, None), false, None, (1,20--1,21)), + None, + Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(1,41--1,42)], + [None; None])), (1,35--1,47)), (1,25--1,47), + (1,25--1,61), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Addition], [], + [Some (OriginalNotation "+")]), None, + (1,51--1,52)), Ident x, (1,49--1,52)), + Ident MinValue, (1,49--1,61))), (1,20--1,61), Yes, + { ArrowRange = Some (1,22--1,24) + BarRange = None })], NoneAtInvisible, (1,11--1,61)), + (1,4--1,8), NoneAtLet, { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = Some (1,9--1,10) })], + (1,0--1,61))], PreXmlDocEmpty, [], None, (1,0--1,61), + { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_if_elif.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_if_elif.fs new file mode 100644 index 00000000000..8724ef79f71 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_if_elif.fs @@ -0,0 +1,9 @@ +if (open type System.Int32; MaxValue <> MinValue) then + open type System.Console + WriteLine "MaxValue is not equal to MinValue" +elif (open type System.Int32; MaxValue < 0) then + open type System.Console + WriteLine "MaxValue is negative" +else + open type System.Console + WriteLine "MaxValue is positive" diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_if_elif.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_if_elif.fs.bsl new file mode 100644 index 00000000000..c129c99b1cd --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_if_elif.fs.bsl @@ -0,0 +1,104 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_if_elif.fs", false, + QualifiedNameOfFile InExp_if_elif, [], + [SynModuleOrNamespace + ([InExp_if_elif], false, AnonModule, + [Expr + (IfThenElse + (Paren + (Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(1,20--1,21)], [None; None])), + (1,14--1,26)), (1,4--1,26), (1,4--1,48), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_Inequality], [], + [Some (OriginalNotation "<>")]), None, + (1,37--1,39)), Ident MaxValue, (1,28--1,39)), + Ident MinValue, (1,28--1,48))), (1,3--1,4), + Some (1,48--1,49), (1,3--1,49)), + Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(2,20--2,21)], [None; None])), + (2,14--2,28)), (2,4--2,28), (2,4--3,49), + App + (NonAtomic, false, Ident WriteLine, + Const + (String + ("MaxValue is not equal to MinValue", Regular, + (3,14--3,49)), (3,14--3,49)), (3,4--3,49))), + Some + (IfThenElse + (Paren + (Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(4,22--4,23)], + [None; None])), (4,16--4,28)), (4,6--4,28), + (4,6--4,42), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_LessThan], [], + [Some (OriginalNotation "<")]), None, + (4,39--4,40)), Ident MaxValue, + (4,30--4,40)), Const (Int32 0, (4,41--4,42)), + (4,30--4,42))), (4,5--4,6), Some (4,42--4,43), + (4,5--4,43)), + Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(5,20--5,21)], + [None; None])), (5,14--5,28)), (5,4--5,28), + (5,4--6,36), + App + (NonAtomic, false, Ident WriteLine, + Const + (String + ("MaxValue is negative", Regular, (6,14--6,36)), + (6,14--6,36)), (6,4--6,36))), + Some + (Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(8,20--8,21)], + [None; None])), (8,14--8,28)), (8,4--8,28), + (8,4--9,36), + App + (NonAtomic, false, Ident WriteLine, + Const + (String + ("MaxValue is positive", Regular, + (9,14--9,36)), (9,14--9,36)), (9,4--9,36)))), + Yes (4,0--4,48), false, (4,0--9,36), + { IfKeyword = (4,0--4,4) + IsElif = true + ThenKeyword = (4,44--4,48) + ElseKeyword = Some (7,0--7,4) + IfToThenRange = (4,0--4,48) })), Yes (1,0--1,54), false, + (1,0--9,36), { IfKeyword = (1,0--1,2) + IsElif = false + ThenKeyword = (1,50--1,54) + ElseKeyword = None + IfToThenRange = (1,0--1,54) }), (1,0--9,36))], + PreXmlDocEmpty, [], None, (1,0--10,0), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_match.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_match.fs new file mode 100644 index 00000000000..324ea3b8e8a --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_match.fs @@ -0,0 +1,5 @@ +match Some 1 with +| Some 1 when open System; Int32.MinValue < 0 -> + open type System.Console + WriteLine "Is 1" +| _ -> () diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_match.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_match.fs.bsl new file mode 100644 index 00000000000..80f9d9e9591 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_match.fs.bsl @@ -0,0 +1,61 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_match.fs", false, + QualifiedNameOfFile InExp_match, [], + [SynModuleOrNamespace + ([InExp_match], false, AnonModule, + [Expr + (Match + (Yes (1,0--1,17), + App + (NonAtomic, false, Ident Some, Const (Int32 1, (1,11--1,12)), + (1,6--1,12)), + [SynMatchClause + (LongIdent + (SynLongIdent ([Some], [], [None]), None, None, + Pats [Const (Int32 1, (2,7--2,8))], None, (2,2--2,8)), + Some + (Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (2,19--2,25)), + (2,14--2,25), (2,14--2,45), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_LessThan], [], + [Some (OriginalNotation "<")]), None, + (2,42--2,43)), + LongIdent + (false, + SynLongIdent + ([Int32; MinValue], [(2,32--2,33)], + [None; None]), None, (2,27--2,41)), + (2,27--2,43)), Const (Int32 0, (2,44--2,45)), + (2,27--2,45)))), + Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(3,20--3,21)], [None; None])), + (3,14--3,28)), (3,4--3,28), (3,4--4,20), + App + (NonAtomic, false, Ident WriteLine, + Const + (String ("Is 1", Regular, (4,14--4,20)), + (4,14--4,20)), (4,4--4,20))), (2,2--4,20), Yes, + { ArrowRange = Some (2,46--2,48) + BarRange = Some (2,0--2,1) }); + SynMatchClause + (Wild (5,2--5,3), None, Const (Unit, (5,7--5,9)), (5,2--5,9), + Yes, { ArrowRange = Some (5,4--5,6) + BarRange = Some (5,0--5,1) })], (1,0--5,9), + { MatchKeyword = (1,0--1,5) + WithKeyword = (1,13--1,17) }), (1,0--5,9))], PreXmlDocEmpty, + [], None, (1,0--6,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis.fs new file mode 100644 index 00000000000..a28003a378c --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis.fs @@ -0,0 +1,5 @@ +( + open type + System.Console + WriteLine() +) \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis.fs.bsl new file mode 100644 index 00000000000..2e3d7d8840c --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis.fs.bsl @@ -0,0 +1,22 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_parenthesis.fs", false, + QualifiedNameOfFile InExp_parenthesis, [], + [SynModuleOrNamespace + ([InExp_parenthesis], false, AnonModule, + [Expr + (Paren + (Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(3,14--3,15)], [None; None])), + (3,8--3,22)), (2,4--3,22), (2,4--4,15), + App + (Atomic, false, Ident WriteLine, + Const (Unit, (4,13--4,15)), (4,4--4,15))), (1,0--1,1), + Some (5,0--5,1), (1,0--5,1)), (1,0--5,1))], PreXmlDocEmpty, [], + None, (1,0--5,1), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis2.fs new file mode 100644 index 00000000000..7cd11dd966b --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis2.fs @@ -0,0 +1,5 @@ +( + open + System + Console.WriteLine() +) \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis2.fs.bsl new file mode 100644 index 00000000000..46de96310a9 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_parenthesis2.fs.bsl @@ -0,0 +1,25 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_parenthesis2.fs", false, + QualifiedNameOfFile InExp_parenthesis2, [], + [SynModuleOrNamespace + ([InExp_parenthesis2], false, AnonModule, + [Expr + (Paren + (Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (3,8--3,14)), + (2,4--3,14), (2,4--4,23), + App + (Atomic, false, + LongIdent + (false, + SynLongIdent + ([Console; WriteLine], [(4,11--4,12)], [None; None]), + None, (4,4--4,21)), Const (Unit, (4,21--4,23)), + (4,4--4,23))), (1,0--1,1), Some (5,0--5,1), (1,0--5,1)), + (1,0--5,1))], PreXmlDocEmpty, [], None, (1,0--5,1), + { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_try_with.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_try_with.fs new file mode 100644 index 00000000000..7b54a395123 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_try_with.fs @@ -0,0 +1,5 @@ +while + (open type System.Int32 + MaxValue < 0) do + open type System.Console + WriteLine "MaxValue is negative" diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_try_with.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_try_with.fs.bsl new file mode 100644 index 00000000000..6c88c67eba3 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_try_with.fs.bsl @@ -0,0 +1,44 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_try_with.fs", false, + QualifiedNameOfFile InExp_try_with, [], + [SynModuleOrNamespace + ([InExp_try_with], false, AnonModule, + [Expr + (While + (Yes (1,0--3,18), + Paren + (Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(2,21--2,22)], [None; None])), + (2,15--2,27)), (2,5--2,27), (2,5--3,17), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_LessThan], [], + [Some (OriginalNotation "<")]), None, + (3,14--3,15)), Ident MaxValue, (3,5--3,15)), + Const (Int32 0, (3,16--3,17)), (3,5--3,17))), + (2,4--2,5), Some (3,17--3,18), (2,4--3,18)), + Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(4,20--4,21)], [None; None])), + (4,14--4,28)), (4,4--4,28), (4,4--5,36), + App + (NonAtomic, false, Ident WriteLine, + Const + (String ("MaxValue is negative", Regular, (5,14--5,36)), + (5,14--5,36)), (5,4--5,36))), (1,0--5,36)), + (1,0--5,36))], PreXmlDocEmpty, [], None, (1,0--6,0), + { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_do.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_do.fs new file mode 100644 index 00000000000..3738f1bd763 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_do.fs @@ -0,0 +1,5 @@ +type Foo() = + do + open System + open type Console + WriteLine 123 \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_do.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_do.fs.bsl new file mode 100644 index 00000000000..a5bc43b7012 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_do.fs.bsl @@ -0,0 +1,54 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_type_do.fs", false, + QualifiedNameOfFile InExp_type_do, [], + [SynModuleOrNamespace + ([InExp_type_do], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [Foo], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,8)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], Const (Unit, (1,8--1,10)), None, + PreXmlDoc ((1,8), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,8), { AsKeyword = None }); + LetBindings + ([SynBinding + (None, Do, false, false, [], PreXmlDocEmpty, + SynValData + (None, + SynValInfo ([], SynArgInfo ([], false, None)), + None), Const (Unit, (2,4--5,21)), None, + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), + (3,13--3,19)), (3,8--3,19), (3,8--5,21), + Open + (Type + (LongIdent + (SynLongIdent ([Console], [], [None])), + (4,18--4,25)), (4,8--4,25), (4,8--5,21), + App + (NonAtomic, false, Ident WriteLine, + Const (Int32 123, (5,18--5,21)), + (5,8--5,21)))), (2,4--5,21), NoneAtDo, + { LeadingKeyword = Do (2,4--2,6) + InlineKeyword = None + EqualsRange = None })], false, false, (2,4--5,21))], + (2,4--5,21)), [], + Some + (ImplicitCtor + (None, [], Const (Unit, (1,8--1,10)), None, + PreXmlDoc ((1,8), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,8), { AsKeyword = None })), (1,5--5,21), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,11--1,12) + WithKeyword = None })], (1,0--5,21))], PreXmlDocEmpty, [], + None, (1,0--5,21), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_let.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_let.fs new file mode 100644 index 00000000000..d3386c2fdcb --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_let.fs @@ -0,0 +1,5 @@ +type Foo() = + let _ = + open System + open type Console + WriteLine 123 \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_let.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_let.fs.bsl new file mode 100644 index 00000000000..d037f58a9af --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_let.fs.bsl @@ -0,0 +1,56 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_type_let.fs", false, + QualifiedNameOfFile InExp_type_let, [], + [SynModuleOrNamespace + ([InExp_type_let], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [Foo], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,8)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], Const (Unit, (1,8--1,10)), None, + PreXmlDoc ((1,8), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,8), { AsKeyword = None }); + LetBindings + ([SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((2,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, + SynValInfo ([], SynArgInfo ([], false, None)), + None), Wild (2,8--2,9), None, + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), + (3,13--3,19)), (3,8--3,19), (3,8--5,21), + Open + (Type + (LongIdent + (SynLongIdent ([Console], [], [None])), + (4,18--4,25)), (4,8--4,25), (4,8--5,21), + App + (NonAtomic, false, Ident WriteLine, + Const (Int32 123, (5,18--5,21)), + (5,8--5,21)))), (2,8--2,9), + Yes (2,4--5,21), + { LeadingKeyword = Let (2,4--2,7) + InlineKeyword = None + EqualsRange = Some (2,10--2,11) })], false, false, + (2,4--5,21))], (2,4--5,21)), [], + Some + (ImplicitCtor + (None, [], Const (Unit, (1,8--1,10)), None, + PreXmlDoc ((1,8), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,8), { AsKeyword = None })), (1,5--5,21), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,11--1,12) + WithKeyword = None })], (1,0--5,21))], PreXmlDocEmpty, [], + None, (1,0--5,21), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member.fs new file mode 100644 index 00000000000..8687ba3faf0 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member.fs @@ -0,0 +1,4 @@ +type Foo() = + member public this.PrintHello() = + open System + Console.WriteLine("Hello!") \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member.fs.bsl new file mode 100644 index 00000000000..aae34b60b99 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member.fs.bsl @@ -0,0 +1,73 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_type_member.fs", false, + QualifiedNameOfFile InExp_type_member, [], + [SynModuleOrNamespace + ([InExp_type_member], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [Foo], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,8)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], Const (Unit, (1,8--1,10)), None, + PreXmlDoc ((1,8), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,8), { AsKeyword = None }); + Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((2,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([this; PrintHello], [(2,22--2,23)], + [None; None]), None, None, + Pats + [Paren + (Const (Unit, (2,33--2,35)), (2,33--2,35))], + Some (Public (2,11--2,17)), (2,11--2,35)), None, + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), + (3,13--3,19)), (3,8--3,19), (3,8--4,35), + App + (Atomic, false, + LongIdent + (false, + SynLongIdent + ([Console; WriteLine], [(4,15--4,16)], + [None; None]), None, (4,8--4,25)), + Paren + (Const + (String ("Hello!", Regular, (4,26--4,34)), + (4,26--4,34)), (4,25--4,26), + Some (4,34--4,35), (4,25--4,35)), + (4,8--4,35))), (2,11--2,35), NoneAtInvisible, + { LeadingKeyword = Member (2,4--2,10) + InlineKeyword = None + EqualsRange = Some (2,36--2,37) }), (2,4--4,35))], + (2,4--4,35)), [], + Some + (ImplicitCtor + (None, [], Const (Unit, (1,8--1,10)), None, + PreXmlDoc ((1,8), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,8), { AsKeyword = None })), (1,5--4,35), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,11--1,12) + WithKeyword = None })], (1,0--4,35))], PreXmlDocEmpty, [], + None, (1,0--4,35), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member2.fs new file mode 100644 index 00000000000..60ee722abe1 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member2.fs @@ -0,0 +1,2 @@ +type Foo() = + member val MinValue: int = (open type System.Int32; MinValue) with get, set diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member2.fs.bsl new file mode 100644 index 00000000000..f8727cc3011 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member2.fs.bsl @@ -0,0 +1,65 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_type_member2.fs", false, + QualifiedNameOfFile InExp_type_member2, [], + [SynModuleOrNamespace + ([InExp_type_member2], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [Foo], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,8)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], Const (Unit, (1,8--1,10)), None, + PreXmlDoc ((1,8), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,8), { AsKeyword = None }); + AutoProperty + ([], false, MinValue, + Some (LongIdent (SynLongIdent ([int], [], [None]))), + PropertyGetSet, + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertySet }, + PreXmlDoc ((2,4), FSharp.Compiler.Xml.XmlDocCollector), + GetSet (None, None, None), + Paren + (Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(2,48--2,49)], + [None; None])), (2,42--2,54)), + (2,32--2,54), (2,32--2,64), Ident MinValue), + (2,31--2,32), Some (2,64--2,65), (2,31--2,65)), + (2,4--2,79), + { LeadingKeyword = + MemberVal ((2,4--2,10), (2,11--2,14)) + WithKeyword = Some (2,66--2,70) + EqualsRange = Some (2,29--2,30) + GetSetKeywords = + Some (GetSet ((2,71--2,74), (2,76--2,79))) })], + (2,4--2,79)), [], + Some + (ImplicitCtor + (None, [], Const (Unit, (1,8--1,10)), None, + PreXmlDoc ((1,8), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,8), { AsKeyword = None })), (1,5--2,79), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,11--1,12) + WithKeyword = None })], (1,0--2,79))], PreXmlDocEmpty, [], + None, (1,0--3,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member3.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member3.fs new file mode 100644 index 00000000000..0b47d23b956 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member3.fs @@ -0,0 +1,2 @@ +type Foo() = + member _.MinValue with get() = open type System.Int32; MinValue and set (_: int) = () diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member3.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member3.fs.bsl new file mode 100644 index 00000000000..2df9383a59b --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_type_member3.fs.bsl @@ -0,0 +1,106 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_type_member3.fs", false, + QualifiedNameOfFile InExp_type_member3, [], + [SynModuleOrNamespace + ([InExp_type_member3], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [Foo], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,8)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], Const (Unit, (1,8--1,10)), None, + PreXmlDoc ((1,8), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,8), { AsKeyword = None }); + GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((2,4), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; MinValue], [(2,12--2,13)], [None; None]), + Some get, None, + Pats + [Paren + (Const (Unit, (2,30--2,32)), (2,30--2,32))], + None, (2,27--2,32)), None, + Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(2,51--2,52)], + [None; None])), (2,45--2,57)), + (2,35--2,57), (2,35--2,67), Ident MinValue), + (2,27--2,32), NoneAtInvisible, + { LeadingKeyword = Member (2,4--2,10) + InlineKeyword = None + EqualsRange = Some (2,33--2,34) })), + Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((2,4), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertySet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; + [SynArgInfo ([], false, None)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; MinValue], [(2,12--2,13)], [None; None]), + Some set, None, + Pats + [Paren + (Typed + (Wild (2,77--2,78), + LongIdent + (SynLongIdent ([int], [], [None])), + (2,77--2,83)), (2,76--2,84))], None, + (2,72--2,84)), None, + Const (Unit, (2,87--2,89)), (2,72--2,84), + NoneAtInvisible, + { LeadingKeyword = Member (2,4--2,10) + InlineKeyword = None + EqualsRange = Some (2,85--2,86) })), + (2,4--2,89), { InlineKeyword = None + WithKeyword = (2,22--2,26) + GetKeyword = Some (2,27--2,30) + AndKeyword = Some (2,68--2,71) + SetKeyword = Some (2,72--2,75) })], + (2,4--2,89)), [], + Some + (ImplicitCtor + (None, [], Const (Unit, (1,8--1,10)), None, + PreXmlDoc ((1,8), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,8), { AsKeyword = None })), (1,5--2,89), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,11--1,12) + WithKeyword = None })], (1,0--2,89))], PreXmlDocEmpty, [], + None, (1,0--3,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_while.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_while.fs new file mode 100644 index 00000000000..7b54a395123 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_while.fs @@ -0,0 +1,5 @@ +while + (open type System.Int32 + MaxValue < 0) do + open type System.Console + WriteLine "MaxValue is negative" diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InExp_while.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_while.fs.bsl new file mode 100644 index 00000000000..b47a35f6fa6 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InExp_while.fs.bsl @@ -0,0 +1,44 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InExp_while.fs", false, + QualifiedNameOfFile InExp_while, [], + [SynModuleOrNamespace + ([InExp_while], false, AnonModule, + [Expr + (While + (Yes (1,0--3,18), + Paren + (Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(2,21--2,22)], [None; None])), + (2,15--2,27)), (2,5--2,27), (2,5--3,17), + App + (NonAtomic, false, + App + (NonAtomic, true, + LongIdent + (false, + SynLongIdent + ([op_LessThan], [], + [Some (OriginalNotation "<")]), None, + (3,14--3,15)), Ident MaxValue, (3,5--3,15)), + Const (Int32 0, (3,16--3,17)), (3,5--3,17))), + (2,4--2,5), Some (3,17--3,18), (2,4--3,18)), + Open + (Type + (LongIdent + (SynLongIdent + ([System; Console], [(4,20--4,21)], [None; None])), + (4,14--4,28)), (4,4--4,28), (4,4--5,36), + App + (NonAtomic, false, Ident WriteLine, + Const + (String ("MaxValue is negative", Regular, (5,14--5,36)), + (5,14--5,36)), (5,4--5,36))), (1,0--5,36)), + (1,0--5,36))], PreXmlDocEmpty, [], None, (1,0--6,0), + { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs new file mode 100644 index 00000000000..5754c954550 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs @@ -0,0 +1,4 @@ +type A() = + interface System.IDisposable with + open System + member _.F _ = 3 \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs.bsl new file mode 100644 index 00000000000..9ca8369c442 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs.bsl @@ -0,0 +1,67 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InInterfaceImplement.fs", false, + QualifiedNameOfFile InInterfaceImplement, [], + [SynModuleOrNamespace + ([InInterfaceImplement], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [A], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,6)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], Const (Unit, (1,6--1,8)), None, + PreXmlDoc ((1,6), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,6), { AsKeyword = None }); + Interface + (LongIdent + (SynLongIdent + ([System; IDisposable], [(2,20--2,21)], + [None; None])), Some (2,33--2,37), + Some + [Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = true + IsFinal = false + GetterOrSetterIsCompilerGenerated = + false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; + [SynArgInfo ([], false, None)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; F], [(4,16--4,17)], [None; None]), + None, None, Pats [Wild (4,19--4,20)], None, + (4,15--4,20)), None, + Const (Int32 3, (4,23--4,24)), (4,15--4,20), + NoneAtInvisible, + { LeadingKeyword = Member (4,8--4,14) + InlineKeyword = None + EqualsRange = Some (4,21--4,22) }), + (4,8--4,24))], (2,4--4,24))], (2,4--4,24)), [], + Some + (ImplicitCtor + (None, [], Const (Unit, (1,6--1,8)), None, + PreXmlDoc ((1,6), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,6), { AsKeyword = None })), (1,5--4,24), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,9--1,10) + WithKeyword = None })], (1,0--4,24))], PreXmlDocEmpty, [], + None, (1,0--4,24), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(3,8)-(3,12) parse error Unexpected keyword 'open' in member definition. Expected 'member', 'override', 'static' or other token. +(3,20)-(4,8) parse error Expecting member body diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs new file mode 100644 index 00000000000..e2255c01fbe --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs @@ -0,0 +1,4 @@ +type A() = + interface System.IDisposable with + member _.F _ = 3 + open System \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs.bsl new file mode 100644 index 00000000000..d9580603e86 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs.bsl @@ -0,0 +1,67 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InInterfaceImplement2.fs", false, + QualifiedNameOfFile InInterfaceImplement2, [], + [SynModuleOrNamespace + ([InInterfaceImplement2], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [A], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,6)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], Const (Unit, (1,6--1,8)), None, + PreXmlDoc ((1,6), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,6), { AsKeyword = None }); + Interface + (LongIdent + (SynLongIdent + ([System; IDisposable], [(2,20--2,21)], + [None; None])), Some (2,33--2,37), + Some + [Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,8), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = true + IsFinal = false + GetterOrSetterIsCompilerGenerated = + false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; + [SynArgInfo ([], false, None)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; F], [(3,16--3,17)], [None; None]), + None, None, Pats [Wild (3,19--3,20)], None, + (3,15--3,20)), None, + Const (Int32 3, (3,23--3,24)), (3,15--3,20), + NoneAtInvisible, + { LeadingKeyword = Member (3,8--3,14) + InlineKeyword = None + EqualsRange = Some (3,21--3,22) }), + (3,8--3,24))], (2,4--3,24))], (2,4--3,24)), [], + Some + (ImplicitCtor + (None, [], Const (Unit, (1,6--1,8)), None, + PreXmlDoc ((1,6), FSharp.Compiler.Xml.XmlDocCollector), + (1,5--1,6), { AsKeyword = None })), (1,5--3,24), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,9--1,10) + WithKeyword = None })], (1,0--3,24))], PreXmlDocEmpty, [], + None, (1,0--4,19), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(4,8)-(4,12) parse error Unexpected keyword 'open' in object expression. Expected 'member', 'override', 'static' or other token. +(4,0)-(4,19) parse error Expecting member body diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr.fs new file mode 100644 index 00000000000..c499a980d38 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr.fs @@ -0,0 +1,4 @@ +{ new System.IDisposable with + open System + member _.F _ = 3 +} diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr.fs.bsl new file mode 100644 index 00000000000..87332d7d957 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr.fs.bsl @@ -0,0 +1,43 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InObjExpr.fs", false, QualifiedNameOfFile InObjExpr, + [], + [SynModuleOrNamespace + ([InObjExpr], false, AnonModule, + [Expr + (ObjExpr + (LongIdent + (SynLongIdent + ([System; IDisposable], [(1,12--1,13)], [None; None])), + None, Some (1,25--1,29), [], + [Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = true + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; + [SynArgInfo ([], false, None)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([_; F], [(3,12--3,13)], [None; None]), + None, None, Pats [Wild (3,15--3,16)], None, + (3,11--3,16)), None, Const (Int32 3, (3,19--3,20)), + (3,11--3,16), NoneAtInvisible, + { LeadingKeyword = Member (3,4--3,10) + InlineKeyword = None + EqualsRange = Some (3,17--3,18) }), (3,4--3,20))], [], + (1,2--1,24), (1,0--4,1)), (1,0--4,1))], PreXmlDocEmpty, [], + None, (1,0--4,1), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(2,4)-(2,8) parse error Unexpected keyword 'open' in object expression. Expected 'member', 'override', 'static' or other token. +(2,16)-(3,4) parse error Expecting member body diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr2.fs new file mode 100644 index 00000000000..f51664a532c --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr2.fs @@ -0,0 +1,4 @@ +{ new System.IDisposable with + member _.F _ = 3 + open System +} diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr2.fs.bsl new file mode 100644 index 00000000000..8b67bf48f1e --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InObjExpr2.fs.bsl @@ -0,0 +1,43 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InObjExpr2.fs", false, + QualifiedNameOfFile InObjExpr2, [], + [SynModuleOrNamespace + ([InObjExpr2], false, AnonModule, + [Expr + (ObjExpr + (LongIdent + (SynLongIdent + ([System; IDisposable], [(1,12--1,13)], [None; None])), + None, Some (1,25--1,29), [], + [Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((2,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = true + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; + [SynArgInfo ([], false, None)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([_; F], [(2,12--2,13)], [None; None]), + None, None, Pats [Wild (2,15--2,16)], None, + (2,11--2,16)), None, Const (Int32 3, (2,19--2,20)), + (2,11--2,16), NoneAtInvisible, + { LeadingKeyword = Member (2,4--2,10) + InlineKeyword = None + EqualsRange = Some (2,17--2,18) }), (2,4--2,20))], [], + (1,2--1,24), (1,0--4,1)), (1,0--4,1))], PreXmlDocEmpty, [], + None, (1,0--4,1), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(3,4)-(3,8) parse error Unexpected keyword 'open' in object expression. Expected 'member', 'override', 'static' or other token. +(4,0)-(4,1) parse error Expecting member body diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs new file mode 100644 index 00000000000..45bf16a072a --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs @@ -0,0 +1,3 @@ +type AUnion = + | A = 0 + open System diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs.bsl new file mode 100644 index 00000000000..c510d2ae685 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs.bsl @@ -0,0 +1,32 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Enum.fs", false, + QualifiedNameOfFile InType_Enum, [], + [SynModuleOrNamespace + ([InType_Enum], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [AUnion], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,11)), + Simple + (Enum + ([SynEnumCase + ([], SynIdent (A, None), + Const (Int32 0, (2,10--2,11)), + PreXmlDoc ((2,4), FSharp.Compiler.Xml.XmlDocCollector), + (2,6--2,11), { BarRange = Some (2,4--2,5) + EqualsRange = (2,8--2,9) })], + (2,4--2,11)), (2,4--2,11)), + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (3,9--3,15)), + (3,4--3,15))], None, (1,5--3,15), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,12--1,13) + WithKeyword = None })], (1,0--3,15))], PreXmlDocEmpty, [], + None, (1,0--4,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs new file mode 100644 index 00000000000..d063e0ce02a --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs @@ -0,0 +1,4 @@ +exception AException of int + with + open System + member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs.bsl new file mode 100644 index 00000000000..a38f182f6f1 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs.bsl @@ -0,0 +1,72 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Exception.fs", false, + QualifiedNameOfFile InType_Exception, [], + [SynModuleOrNamespace + ([InType_Exception], false, AnonModule, + [Exception + (SynExceptionDefn + (SynExceptionDefnRepr + ([], + SynUnionCase + ([], SynIdent (AException, None), + Fields + [SynField + ([], false, None, + LongIdent (SynLongIdent ([int], [], [None])), false, + PreXmlDoc ((1,24), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,24--1,27), { LeadingKeyword = None + MutableKeyword = None })], + PreXmlDocEmpty, None, (1,10--1,27), { BarRange = None }), + None, PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,0--1,27)), Some (2,4--2,8), + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (3,13--3,19)), + (3,8--3,19)); + GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; RandomNumber], [(4,16--4,17)], [None; None]), + Some get, None, + Pats + [Paren + (Const (Unit, (4,38--4,40)), (4,38--4,40))], + None, (4,35--4,40)), None, + App + (Atomic, false, + DotGet + (App + (Atomic, false, Ident Random, + Const (Unit, (4,49--4,51)), (4,43--4,51)), + (4,51--4,52), SynLongIdent ([Next], [], [None]), + (4,43--4,56)), Const (Unit, (4,56--4,58)), + (4,43--4,58)), (4,35--4,40), NoneAtInvisible, + { LeadingKeyword = Member (4,8--4,14) + InlineKeyword = None + EqualsRange = Some (4,41--4,42) })), None, + (4,8--4,58), { InlineKeyword = None + WithKeyword = (4,30--4,34) + GetKeyword = Some (4,35--4,38) + AndKeyword = None + SetKeyword = None })], (1,0--4,58)), + (1,0--4,58))], PreXmlDocEmpty, [], None, (1,0--5,0), + { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs new file mode 100644 index 00000000000..ed43c7ee697 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs @@ -0,0 +1,3 @@ +type System.Int32 with + open type System.Math + member this.Abs111 = Abs(this) \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs.bsl new file mode 100644 index 00000000000..7005e434ccf --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs.bsl @@ -0,0 +1,53 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Extension.fs", false, + QualifiedNameOfFile InType_Extension, [], + [SynModuleOrNamespace + ([InType_Extension], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [System; Int32], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,17)), + ObjectModel (Augmentation (1,18--1,22), [], (1,5--3,34)), + [Open + (Type + (LongIdent + (SynLongIdent + ([System; Math], [(2,20--2,21)], [None; None])), + (2,14--2,25)), (2,4--2,25)); + Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([this; Abs111], [(3,15--3,16)], [None; None]), + None, None, Pats [], None, (3,11--3,22)), None, + App + (Atomic, false, Ident Abs, + Paren + (Ident this, (3,28--3,29), Some (3,33--3,34), + (3,28--3,34)), (3,25--3,34)), (3,11--3,22), + NoneAtInvisible, { LeadingKeyword = Member (3,4--3,10) + InlineKeyword = None + EqualsRange = Some (3,23--3,24) }), + (3,4--3,34))], None, (1,5--3,34), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = None + WithKeyword = None })], (1,0--3,34))], PreXmlDocEmpty, [], + None, (1,0--3,34), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs new file mode 100644 index 00000000000..7910f8a7a92 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs @@ -0,0 +1,3 @@ +type System.Int32 with + member this.Abs111 = Abs(this) + open type System.Math \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs.bsl new file mode 100644 index 00000000000..7e5c8ca55a6 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs.bsl @@ -0,0 +1,53 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Extension2.fs", false, + QualifiedNameOfFile InType_Extension2, [], + [SynModuleOrNamespace + ([InType_Extension2], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [System; Int32], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,17)), + ObjectModel (Augmentation (1,18--1,22), [], (1,5--3,25)), + [Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((2,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([this; Abs111], [(2,15--2,16)], [None; None]), + None, None, Pats [], None, (2,11--2,22)), None, + App + (Atomic, false, Ident Abs, + Paren + (Ident this, (2,28--2,29), Some (2,33--2,34), + (2,28--2,34)), (2,25--2,34)), (2,11--2,22), + NoneAtInvisible, { LeadingKeyword = Member (2,4--2,10) + InlineKeyword = None + EqualsRange = Some (2,23--2,24) }), + (2,4--2,34)); + Open + (Type + (LongIdent + (SynLongIdent + ([System; Math], [(3,20--3,21)], [None; None])), + (3,14--3,25)), (3,4--3,25))], None, (1,5--3,25), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = None + WithKeyword = None })], (1,0--3,25))], PreXmlDocEmpty, [], + None, (1,0--3,25), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs new file mode 100644 index 00000000000..2ad94f7f640 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs @@ -0,0 +1,4 @@ +type ARecord = { A : int } + with + open System + member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs.bsl new file mode 100644 index 00000000000..9cdf5f9d5f2 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs.bsl @@ -0,0 +1,75 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Record.fs", false, + QualifiedNameOfFile InType_Record, [], + [SynModuleOrNamespace + ([InType_Record], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [ARecord], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,12)), + Simple + (Record + (None, + [SynField + ([], false, Some A, + LongIdent (SynLongIdent ([int], [], [None])), false, + PreXmlDoc ((1,17), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,17--1,24), { LeadingKeyword = None + MutableKeyword = None })], + (1,15--1,26)), (1,15--1,26)), + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (3,13--3,19)), + (3,8--3,19)); + GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; RandomNumber], [(4,16--4,17)], + [None; None]), Some get, None, + Pats + [Paren + (Const (Unit, (4,38--4,40)), (4,38--4,40))], + None, (4,35--4,40)), None, + App + (Atomic, false, + DotGet + (App + (Atomic, false, Ident Random, + Const (Unit, (4,49--4,51)), (4,43--4,51)), + (4,51--4,52), + SynLongIdent ([Next], [], [None]), + (4,43--4,56)), Const (Unit, (4,56--4,58)), + (4,43--4,58)), (4,35--4,40), NoneAtInvisible, + { LeadingKeyword = Member (4,8--4,14) + InlineKeyword = None + EqualsRange = Some (4,41--4,42) })), None, + (4,8--4,58), { InlineKeyword = None + WithKeyword = (4,30--4,34) + GetKeyword = Some (4,35--4,38) + AndKeyword = None + SetKeyword = None })], None, (1,5--4,58), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,13--1,14) + WithKeyword = Some (2,4--2,8) })], (1,0--4,58))], + PreXmlDocEmpty, [], None, (1,0--5,0), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs new file mode 100644 index 00000000000..f89920e1c9d --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs @@ -0,0 +1,4 @@ +type ARecord = { A : int } + with + member _.RandomNumber with get() = Random().Next() + open System diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs.bsl new file mode 100644 index 00000000000..33cd5bbeba3 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs.bsl @@ -0,0 +1,75 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Record2.fs", false, + QualifiedNameOfFile InType_Record2, [], + [SynModuleOrNamespace + ([InType_Record2], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [ARecord], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,12)), + Simple + (Record + (None, + [SynField + ([], false, Some A, + LongIdent (SynLongIdent ([int], [], [None])), false, + PreXmlDoc ((1,17), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,17--1,24), { LeadingKeyword = None + MutableKeyword = None })], + (1,15--1,26)), (1,15--1,26)), + [GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((3,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; RandomNumber], [(3,16--3,17)], + [None; None]), Some get, None, + Pats + [Paren + (Const (Unit, (3,38--3,40)), (3,38--3,40))], + None, (3,35--3,40)), None, + App + (Atomic, false, + DotGet + (App + (Atomic, false, Ident Random, + Const (Unit, (3,49--3,51)), (3,43--3,51)), + (3,51--3,52), + SynLongIdent ([Next], [], [None]), + (3,43--3,56)), Const (Unit, (3,56--3,58)), + (3,43--3,58)), (3,35--3,40), NoneAtInvisible, + { LeadingKeyword = Member (3,8--3,14) + InlineKeyword = None + EqualsRange = Some (3,41--3,42) })), None, + (3,8--3,58), { InlineKeyword = None + WithKeyword = (3,30--3,34) + GetKeyword = Some (3,35--3,38) + AndKeyword = None + SetKeyword = None }); + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (4,13--4,19)), + (4,8--4,19))], None, (1,5--4,19), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,13--1,14) + WithKeyword = Some (2,4--2,8) })], (1,0--4,19))], + PreXmlDocEmpty, [], None, (1,0--5,0), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs new file mode 100644 index 00000000000..4e7e43105da --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs @@ -0,0 +1,5 @@ +type ARecord = + open System + { A : int } + with + member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs.bsl new file mode 100644 index 00000000000..0e1c114debe --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs.bsl @@ -0,0 +1,71 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Record3.fs", false, + QualifiedNameOfFile InType_Record3, [], + [SynModuleOrNamespace + ([InType_Record3], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [ARecord], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,12)), + ObjectModel + (Unspecified, + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (2,9--2,15)), + (2,4--2,15)); + GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; RandomNumber], [(5,16--5,17)], + [None; None]), Some get, None, + Pats + [Paren + (Const (Unit, (5,38--5,40)), (5,38--5,40))], + None, (5,35--5,40)), None, + App + (Atomic, false, + DotGet + (App + (Atomic, false, Ident Random, + Const (Unit, (5,49--5,51)), (5,43--5,51)), + (5,51--5,52), + SynLongIdent ([Next], [], [None]), + (5,43--5,56)), Const (Unit, (5,56--5,58)), + (5,43--5,58)), (5,35--5,40), NoneAtInvisible, + { LeadingKeyword = Member (5,8--5,14) + InlineKeyword = None + EqualsRange = Some (5,41--5,42) })), None, + (3,4--5,58), { InlineKeyword = None + WithKeyword = (5,30--5,34) + GetKeyword = Some (5,35--5,38) + AndKeyword = None + SetKeyword = None })], (2,4--5,58)), [], + None, (1,5--5,58), { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,13--1,14) + WithKeyword = None })], (1,0--5,58))], + PreXmlDocEmpty, [], None, (1,0--6,0), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(3,4)-(3,5) parse error Unexpected symbol '{' in member definition +(6,0)-(6,0) parse error Incomplete structured construct at or before this point in implementation file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs new file mode 100644 index 00000000000..38891eea6d0 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs @@ -0,0 +1,5 @@ +type ARecord = + { A : int } + open System + with + member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs.bsl new file mode 100644 index 00000000000..ca9813c9f0c --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs.bsl @@ -0,0 +1,12 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Record4.fs", false, + QualifiedNameOfFile InType_Record4, [], + [SynModuleOrNamespace + ([InType_Record4], false, AnonModule, [], PreXmlDocEmpty, [], None, + (1,0--6,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(2,4)-(6,0) parse error At most one 'with' augmentation is permitted diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs new file mode 100644 index 00000000000..68234379e4c --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs @@ -0,0 +1,8 @@ +[] +type ABC = + open System + val a: Int32 + val b: Int32 + new (a) = + open type System.Int32 + { a = a; b = MinValue } diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs.bsl new file mode 100644 index 00000000000..3614609046c --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs.bsl @@ -0,0 +1,95 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Struct.fs", false, + QualifiedNameOfFile InType_Struct, [], + [SynModuleOrNamespace + ([InType_Struct], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([{ Attributes = + [{ TypeName = SynLongIdent ([Struct], [], [None]) + ArgExpr = Const (Unit, (1,2--1,8)) + Target = None + AppliesToGetterAndSetter = false + Range = (1,2--1,8) }] + Range = (1,0--1,10) }], None, [], [ABC], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (2,5--2,8)), + ObjectModel + (Unspecified, + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (3,9--3,15)), + (3,4--3,15)); + ValField + (SynField + ([], false, Some a, + LongIdent (SynLongIdent ([Int32], [], [None])), + false, + PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (4,4--4,16), + { LeadingKeyword = Some (Val (4,4--4,7)) + MutableKeyword = None }), (4,4--4,16)); + ValField + (SynField + ([], false, Some b, + LongIdent (SynLongIdent ([Int32], [], [None])), + false, + PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (5,4--5,16), + { LeadingKeyword = Some (Val (5,4--5,7)) + MutableKeyword = None }), (5,4--5,16)); + Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((6,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = false + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Constructor }, + SynValInfo + ([[SynArgInfo ([], false, Some a)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([new], [], [None]), None, + Some (SynValTyparDecls (None, false)), + Pats + [Paren + (Named + (SynIdent (a, None), false, None, + (6,9--6,10)), (6,8--6,11))], None, + (6,4--6,7)), None, + Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(7,24--7,25)], + [None; None])), (7,18--7,30)), + (7,8--7,30), (7,8--8,31), + Record + (None, None, + [SynExprRecordField + ((SynLongIdent ([a], [], [None]), true), + Some (8,12--8,13), Some (Ident a), + (8,10--8,15), + Some ((8,15--8,16), Some (8,16))); + SynExprRecordField + ((SynLongIdent ([b], [], [None]), true), + Some (8,19--8,20), Some (Ident MinValue), + (8,17--8,29), None)], (8,8--8,31))), + (6,4--6,11), NoneAtInvisible, + { LeadingKeyword = New (6,4--6,7) + InlineKeyword = None + EqualsRange = Some (6,12--6,13) }), (6,4--8,31))], + (3,4--8,31)), [], None, (1,0--8,31), + { LeadingKeyword = Type (2,0--2,4) + EqualsRange = Some (2,9--2,10) + WithKeyword = None })], (1,0--8,31))], PreXmlDocEmpty, [], + None, (1,0--9,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs new file mode 100644 index 00000000000..1804dfe0a1e --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs @@ -0,0 +1,8 @@ +[] +type ABC = + val a: Int32 + open System + val b: Int32 + new (a) = + open type System.Int32 + { a = a; b = MinValue } diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs.bsl new file mode 100644 index 00000000000..fe5fbd4464f --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs.bsl @@ -0,0 +1,95 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Struct2.fs", false, + QualifiedNameOfFile InType_Struct2, [], + [SynModuleOrNamespace + ([InType_Struct2], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([{ Attributes = + [{ TypeName = SynLongIdent ([Struct], [], [None]) + ArgExpr = Const (Unit, (1,2--1,8)) + Target = None + AppliesToGetterAndSetter = false + Range = (1,2--1,8) }] + Range = (1,0--1,10) }], None, [], [ABC], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (2,5--2,8)), + ObjectModel + (Unspecified, + [ValField + (SynField + ([], false, Some a, + LongIdent (SynLongIdent ([Int32], [], [None])), + false, + PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (3,4--3,16), + { LeadingKeyword = Some (Val (3,4--3,7)) + MutableKeyword = None }), (3,4--3,16)); + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (4,9--4,15)), + (4,4--4,15)); + ValField + (SynField + ([], false, Some b, + LongIdent (SynLongIdent ([Int32], [], [None])), + false, + PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), + None, (5,4--5,16), + { LeadingKeyword = Some (Val (5,4--5,7)) + MutableKeyword = None }), (5,4--5,16)); + Member + (SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((6,4), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (Some { IsInstance = false + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Constructor }, + SynValInfo + ([[SynArgInfo ([], false, Some a)]], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent ([new], [], [None]), None, + Some (SynValTyparDecls (None, false)), + Pats + [Paren + (Named + (SynIdent (a, None), false, None, + (6,9--6,10)), (6,8--6,11))], None, + (6,4--6,7)), None, + Open + (Type + (LongIdent + (SynLongIdent + ([System; Int32], [(7,24--7,25)], + [None; None])), (7,18--7,30)), + (7,8--7,30), (7,8--8,31), + Record + (None, None, + [SynExprRecordField + ((SynLongIdent ([a], [], [None]), true), + Some (8,12--8,13), Some (Ident a), + (8,10--8,15), + Some ((8,15--8,16), Some (8,16))); + SynExprRecordField + ((SynLongIdent ([b], [], [None]), true), + Some (8,19--8,20), Some (Ident MinValue), + (8,17--8,29), None)], (8,8--8,31))), + (6,4--6,11), NoneAtInvisible, + { LeadingKeyword = New (6,4--6,7) + InlineKeyword = None + EqualsRange = Some (6,12--6,13) }), (6,4--8,31))], + (3,4--8,31)), [], None, (1,0--8,31), + { LeadingKeyword = Type (2,0--2,4) + EqualsRange = Some (2,9--2,10) + WithKeyword = None })], (1,0--8,31))], PreXmlDocEmpty, [], + None, (1,0--9,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs new file mode 100644 index 00000000000..35efa4aef11 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs @@ -0,0 +1,4 @@ +type AUnion = | A of int + with + open System + member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs.bsl new file mode 100644 index 00000000000..c1f4159d3a4 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs.bsl @@ -0,0 +1,81 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Union.fs", false, + QualifiedNameOfFile InType_Union, [], + [SynModuleOrNamespace + ([InType_Union], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [AUnion], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,11)), + Simple + (Union + (None, + [SynUnionCase + ([], SynIdent (A, None), + Fields + [SynField + ([], false, None, + LongIdent (SynLongIdent ([int], [], [None])), + false, + PreXmlDoc ((1,21), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,21--1,24), { LeadingKeyword = None + MutableKeyword = None })], + PreXmlDoc ((1,14), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,16--1,24), { BarRange = Some (1,14--1,15) })], + (1,14--1,24)), (1,14--1,24)), + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (3,13--3,19)), + (3,8--3,19)); + GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; RandomNumber], [(4,16--4,17)], + [None; None]), Some get, None, + Pats + [Paren + (Const (Unit, (4,38--4,40)), (4,38--4,40))], + None, (4,35--4,40)), None, + App + (Atomic, false, + DotGet + (App + (Atomic, false, Ident Random, + Const (Unit, (4,49--4,51)), (4,43--4,51)), + (4,51--4,52), + SynLongIdent ([Next], [], [None]), + (4,43--4,56)), Const (Unit, (4,56--4,58)), + (4,43--4,58)), (4,35--4,40), NoneAtInvisible, + { LeadingKeyword = Member (4,8--4,14) + InlineKeyword = None + EqualsRange = Some (4,41--4,42) })), None, + (4,8--4,58), { InlineKeyword = None + WithKeyword = (4,30--4,34) + GetKeyword = Some (4,35--4,38) + AndKeyword = None + SetKeyword = None })], None, (1,5--4,58), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,12--1,13) + WithKeyword = Some (2,4--2,8) })], (1,0--4,58))], + PreXmlDocEmpty, [], None, (1,0--5,0), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs new file mode 100644 index 00000000000..3c680806a8c --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs @@ -0,0 +1,4 @@ +type AUnion = | A of int + with + member _.RandomNumber with get() = Random().Next() + open System diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs.bsl new file mode 100644 index 00000000000..bc3f736e39a --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs.bsl @@ -0,0 +1,81 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Union2.fs", false, + QualifiedNameOfFile InType_Union2, [], + [SynModuleOrNamespace + ([InType_Union2], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [AUnion], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,11)), + Simple + (Union + (None, + [SynUnionCase + ([], SynIdent (A, None), + Fields + [SynField + ([], false, None, + LongIdent (SynLongIdent ([int], [], [None])), + false, + PreXmlDoc ((1,21), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,21--1,24), { LeadingKeyword = None + MutableKeyword = None })], + PreXmlDoc ((1,14), FSharp.Compiler.Xml.XmlDocCollector), + None, (1,16--1,24), { BarRange = Some (1,14--1,15) })], + (1,14--1,24)), (1,14--1,24)), + [GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((3,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; RandomNumber], [(3,16--3,17)], + [None; None]), Some get, None, + Pats + [Paren + (Const (Unit, (3,38--3,40)), (3,38--3,40))], + None, (3,35--3,40)), None, + App + (Atomic, false, + DotGet + (App + (Atomic, false, Ident Random, + Const (Unit, (3,49--3,51)), (3,43--3,51)), + (3,51--3,52), + SynLongIdent ([Next], [], [None]), + (3,43--3,56)), Const (Unit, (3,56--3,58)), + (3,43--3,58)), (3,35--3,40), NoneAtInvisible, + { LeadingKeyword = Member (3,8--3,14) + InlineKeyword = None + EqualsRange = Some (3,41--3,42) })), None, + (3,8--3,58), { InlineKeyword = None + WithKeyword = (3,30--3,34) + GetKeyword = Some (3,35--3,38) + AndKeyword = None + SetKeyword = None }); + Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (4,13--4,19)), + (4,8--4,19))], None, (1,5--4,19), + { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,12--1,13) + WithKeyword = Some (2,4--2,8) })], (1,0--4,19))], + PreXmlDocEmpty, [], None, (1,0--5,0), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs new file mode 100644 index 00000000000..5c2a1384903 --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs @@ -0,0 +1,5 @@ +type AUnion = + open System + | A of int + with + member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs.bsl new file mode 100644 index 00000000000..cdf7dc5f21c --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs.bsl @@ -0,0 +1,71 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Union3.fs", false, + QualifiedNameOfFile InType_Union3, [], + [SynModuleOrNamespace + ([InType_Union3], false, AnonModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [AUnion], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (1,5--1,11)), + ObjectModel + (Unspecified, + [Open + (ModuleOrNamespace + (SynLongIdent ([System], [], [None]), (2,9--2,15)), + (2,4--2,15)); + GetSetMember + (Some + (SynBinding + (None, Normal, false, false, [], + PreXmlMerge + (PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), + SynValData + (Some + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertyGet }, + SynValInfo + ([[SynArgInfo ([], false, None)]; []], + SynArgInfo ([], false, None)), None), + LongIdent + (SynLongIdent + ([_; RandomNumber], [(5,16--5,17)], + [None; None]), Some get, None, + Pats + [Paren + (Const (Unit, (5,38--5,40)), (5,38--5,40))], + None, (5,35--5,40)), None, + App + (Atomic, false, + DotGet + (App + (Atomic, false, Ident Random, + Const (Unit, (5,49--5,51)), (5,43--5,51)), + (5,51--5,52), + SynLongIdent ([Next], [], [None]), + (5,43--5,56)), Const (Unit, (5,56--5,58)), + (5,43--5,58)), (5,35--5,40), NoneAtInvisible, + { LeadingKeyword = Member (5,8--5,14) + InlineKeyword = None + EqualsRange = Some (5,41--5,42) })), None, + (3,4--5,58), { InlineKeyword = None + WithKeyword = (5,30--5,34) + GetKeyword = Some (5,35--5,38) + AndKeyword = None + SetKeyword = None })], (2,4--5,58)), [], + None, (1,5--5,58), { LeadingKeyword = Type (1,0--1,4) + EqualsRange = Some (1,12--1,13) + WithKeyword = None })], (1,0--5,58))], + PreXmlDocEmpty, [], None, (1,0--6,0), { LeadingKeyword = None })], + (true, true), { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(3,4)-(3,5) parse error Unexpected symbol '|' in member definition +(6,0)-(6,0) parse error Incomplete structured construct at or before this point in implementation file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs new file mode 100644 index 00000000000..b9f6f1851ba --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs @@ -0,0 +1,5 @@ +type AUnion = + | A of int + open System + with + member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs.bsl new file mode 100644 index 00000000000..f2ad930f91b --- /dev/null +++ b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs.bsl @@ -0,0 +1,12 @@ +ImplFile + (ParsedImplFileInput + ("/root/OpenDeclaration/InType_Union4.fs", false, + QualifiedNameOfFile InType_Union4, [], + [SynModuleOrNamespace + ([InType_Union4], false, AnonModule, [], PreXmlDocEmpty, [], None, + (1,0--6,0), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + WarnDirectives = [] + CodeComments = [] }, set [])) + +(2,4)-(6,0) parse error At most one 'with' augmentation is permitted diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs b/tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs deleted file mode 100644 index 1aad8bc7ae1..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs +++ /dev/null @@ -1,9 +0,0 @@ -{ new System.IDisposable with - open System - member _.F _ = 3 -} - -type A() = - interface System.IDisposable with - open System - member _.F _ = 3 diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs.bsl deleted file mode 100644 index 9d7c15b3886..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/OpenInObjExprOrInterface.fs.bsl +++ /dev/null @@ -1,99 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/OpenInObjExprOrInterface.fs", false, - QualifiedNameOfFile OpenInObjExprOrInterface, [], - [SynModuleOrNamespace - ([OpenInObjExprOrInterface], false, AnonModule, - [Expr - (ObjExpr - (LongIdent - (SynLongIdent - ([System; IDisposable], [(1,12--1,13)], [None; None])), - None, Some (1,25--1,29), [], - [Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = true - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; - [SynArgInfo ([], false, None)]], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent ([_; F], [(3,12--3,13)], [None; None]), - None, None, Pats [Wild (3,15--3,16)], None, - (3,11--3,16)), None, Const (Int32 3, (3,19--3,20)), - (3,11--3,16), NoneAtInvisible, - { LeadingKeyword = Member (3,4--3,10) - InlineKeyword = None - EqualsRange = Some (3,17--3,18) }), (3,4--3,20))], [], - (1,2--1,24), (1,0--4,1)), (1,0--4,1)); - Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [A], - PreXmlDoc ((6,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (6,5--6,6)), - ObjectModel - (Unspecified, - [ImplicitCtor - (None, [], Const (Unit, (6,6--6,8)), None, - PreXmlDoc ((6,6), FSharp.Compiler.Xml.XmlDocCollector), - (6,5--6,6), { AsKeyword = None }); - Interface - (LongIdent - (SynLongIdent - ([System; IDisposable], [(7,20--7,21)], - [None; None])), Some (7,33--7,37), - Some - [Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((9,8), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = true - IsFinal = false - GetterOrSetterIsCompilerGenerated = - false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; - [SynArgInfo ([], false, None)]], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; F], [(9,16--9,17)], [None; None]), - None, None, Pats [Wild (9,19--9,20)], None, - (9,15--9,20)), None, - Const (Int32 3, (9,23--9,24)), (9,15--9,20), - NoneAtInvisible, - { LeadingKeyword = Member (9,8--9,14) - InlineKeyword = None - EqualsRange = Some (9,21--9,22) }), - (9,8--9,24))], (7,4--9,24))], (7,4--9,24)), [], - Some - (ImplicitCtor - (None, [], Const (Unit, (6,6--6,8)), None, - PreXmlDoc ((6,6), FSharp.Compiler.Xml.XmlDocCollector), - (6,5--6,6), { AsKeyword = None })), (6,5--9,24), - { LeadingKeyword = Type (6,0--6,4) - EqualsRange = Some (6,9--6,10) - WithKeyword = None })], (6,0--9,24))], PreXmlDocEmpty, [], - None, (1,0--10,0), { LeadingKeyword = None })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) - -(2,4)-(2,8) parse error Unexpected keyword 'open' in object expression. Expected 'member', 'override', 'static' or other token. -(2,16)-(3,4) parse error Expecting member body -(8,8)-(8,12) parse error Unexpected keyword 'open' in member definition. Expected 'member', 'override', 'static' or other token. -(8,20)-(9,8) parse error Expecting member body diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs b/tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs deleted file mode 100644 index 6275e58273c..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs +++ /dev/null @@ -1,11 +0,0 @@ -type R = - open System - { A : int } - open System - member _.F _ = 3 - -type T = - open System - | A of int - open System - | B of string \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs.bsl deleted file mode 100644 index f5267d8b5f7..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/OpenInTypeWithWrongPos.fs.bsl +++ /dev/null @@ -1,13 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/OpenInTypeWithWrongPos.fs", false, - QualifiedNameOfFile OpenInTypeWithWrongPos, [], - [SynModuleOrNamespace - ([OpenInTypeWithWrongPos], false, AnonModule, [], PreXmlDocEmpty, [], - None, (11,17--11,17), { LeadingKeyword = None })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) - -(3,4)-(3,5) parse error Unexpected symbol '{' in member definition -(9,4)-(9,5) parse error Unexpected symbol '|' in member definition diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs b/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs deleted file mode 100644 index dcca61fa898..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs +++ /dev/null @@ -1,51 +0,0 @@ -// #Regression #Conformance #DeclarationElements #Import -module openInTypeDecl - -type Foo() = - open global.System - open type DateTime - - inherit Object() - - [] val mutable x: Int64 - let x = 42 - let timeConstructed = Now.Ticks - do printfn "%d" Int32.MaxValue - static member Now () = DateTime.Now - member val TimeConstructed = timeConstructed with get, set - - member _.M() = - open type System.ArgumentException - Int32.MaxValue - - interface IDisposable with - member this.Dispose (): unit = - raise (NotImplementedException()) - -type A = A of int - with - open System - member _.RandomNumber with get() = Random().Next() - -type ARecord = { A : int } - with - open System - member _.RandomNumber with get() = Random().Next() - -exception AException of int - with - open System - member _.RandomNumber with get() = Random().Next() - -[] -type ABC = - open System - val a: Int32 - val b: Int32 - new (a) = - open type System.Int32 - { a = a; b = MinValue } - -type System.Int32 with - open type System.Math - member this.Abs111 = Abs(this) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs.bsl deleted file mode 100644 index e510de1d1c6..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/openInTypeDecl.fs.bsl +++ /dev/null @@ -1,604 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/openInTypeDecl.fs", false, - QualifiedNameOfFile openInTypeDecl, [], - [SynModuleOrNamespace - ([openInTypeDecl], false, NamedModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [Foo], - PreXmlDoc ((4,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (4,5--4,8)), - ObjectModel - (Unspecified, - [ImplicitCtor - (None, [], Const (Unit, (4,8--4,10)), None, - PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), - (4,5--4,8), { AsKeyword = None }); - Open - (ModuleOrNamespace - (SynLongIdent - ([`global`; System], [(5,15--5,16)], - [Some (OriginalNotation "global"); None]), - (5,9--5,22)), (5,4--5,22)); - Open - (Type - (LongIdent (SynLongIdent ([DateTime], [], [None])), - (6,14--6,22)), (6,4--6,22)); - ImplicitInherit - (LongIdent (SynLongIdent ([Object], [], [None])), - Const (Unit, (8,18--8,20)), None, (8,4--8,20), - { InheritKeyword = (8,4--8,11) }); - ValField - (SynField - ([{ Attributes = - [{ TypeName = - SynLongIdent ([DefaultValue], [], [None]) - ArgExpr = Const (Unit, (10,6--10,18)) - Target = None - AppliesToGetterAndSetter = false - Range = (10,6--10,18) }] - Range = (10,4--10,20) }], false, Some x, - LongIdent (SynLongIdent ([Int64], [], [None])), true, - PreXmlDoc ((10,4), FSharp.Compiler.Xml.XmlDocCollector), - None, (10,4--10,41), - { LeadingKeyword = Some (Val (10,21--10,24)) - MutableKeyword = Some (10,25--10,32) }), - (10,4--10,41)); - LetBindings - ([SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((11,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, - SynValInfo ([], SynArgInfo ([], false, None)), - None), - Named - (SynIdent (x, None), false, None, (11,8--11,9)), - None, Const (Int32 42, (11,12--11,14)), - (11,8--11,9), Yes (11,4--11,14), - { LeadingKeyword = Let (11,4--11,7) - InlineKeyword = None - EqualsRange = Some (11,10--11,11) })], false, - false, (11,4--11,14)); - LetBindings - ([SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((12,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, - SynValInfo ([], SynArgInfo ([], false, None)), - None), - Named - (SynIdent (timeConstructed, None), false, None, - (12,8--12,23)), None, - LongIdent - (false, - SynLongIdent - ([Now; Ticks], [(12,29--12,30)], [None; None]), - None, (12,26--12,35)), (12,8--12,23), - Yes (12,4--12,35), - { LeadingKeyword = Let (12,4--12,7) - InlineKeyword = None - EqualsRange = Some (12,24--12,25) })], false, - false, (12,4--12,35)); - LetBindings - ([SynBinding - (None, Do, false, false, [], PreXmlDocEmpty, - SynValData - (None, - SynValInfo ([], SynArgInfo ([], false, None)), - None), Const (Unit, (13,4--13,34)), None, - App - (NonAtomic, false, - App - (NonAtomic, false, Ident printfn, - Const - (String ("%d", Regular, (13,15--13,19)), - (13,15--13,19)), (13,7--13,19)), - LongIdent - (false, - SynLongIdent - ([Int32; MaxValue], [(13,25--13,26)], - [None; None]), None, (13,20--13,34)), - (13,7--13,34)), (13,4--13,34), NoneAtDo, - { LeadingKeyword = Do (13,4--13,6) - InlineKeyword = None - EqualsRange = None })], false, false, - (13,4--13,34)); - Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((14,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = false - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - SynValInfo ([[]], SynArgInfo ([], false, None)), - None), - LongIdent - (SynLongIdent ([Now], [], [None]), None, None, - Pats - [Paren - (Const (Unit, (14,22--14,24)), - (14,22--14,24))], None, (14,18--14,24)), - None, - LongIdent - (false, - SynLongIdent - ([DateTime; Now], [(14,35--14,36)], - [None; None]), None, (14,27--14,39)), - (14,18--14,24), NoneAtInvisible, - { LeadingKeyword = - StaticMember ((14,4--14,10), (14,11--14,17)) - InlineKeyword = None - EqualsRange = Some (14,25--14,26) }), - (14,4--14,39)); - AutoProperty - ([], false, TimeConstructed, None, PropertyGetSet, - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertySet }, - PreXmlDoc ((15,4), FSharp.Compiler.Xml.XmlDocCollector), - GetSet (None, None, None), Ident timeConstructed, - (15,4--15,62), - { LeadingKeyword = - MemberVal ((15,4--15,10), (15,11--15,14)) - WithKeyword = Some (15,49--15,53) - EqualsRange = Some (15,31--15,32) - GetSetKeywords = - Some (GetSet ((15,54--15,57), (15,59--15,62))) }); - Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((17,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; M], [(17,12--17,13)], [None; None]), None, - None, - Pats - [Paren - (Const (Unit, (17,14--17,16)), - (17,14--17,16))], None, (17,11--17,16)), - None, - Open - (Type - (LongIdent - (SynLongIdent - ([System; ArgumentException], - [(18,24--18,25)], [None; None])), - (18,18--18,42)), (18,8--18,42), (18,8--19,22), - LongIdent - (false, - SynLongIdent - ([Int32; MaxValue], [(19,13--19,14)], - [None; None]), None, (19,8--19,22))), - (17,11--17,16), NoneAtInvisible, - { LeadingKeyword = Member (17,4--17,10) - InlineKeyword = None - EqualsRange = Some (17,17--17,18) }), - (17,4--19,22)); - Interface - (LongIdent (SynLongIdent ([IDisposable], [], [None])), - Some (21,26--21,30), - Some - [Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((22,8), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = true - IsFinal = false - GetterOrSetterIsCompilerGenerated = - false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([this; Dispose], [(22,19--22,20)], - [None; None]), None, None, - Pats - [Paren - (Const (Unit, (22,28--22,30)), - (22,28--22,30))], None, - (22,15--22,30)), - Some - (SynBindingReturnInfo - (LongIdent - (SynLongIdent ([unit], [], [None])), - (22,32--22,36), [], - { ColonRange = Some (22,30--22,31) })), - Typed - (App - (NonAtomic, false, Ident raise, - Paren - (App - (Atomic, false, - Ident NotImplementedException, - Const (Unit, (23,42--23,44)), - (23,19--23,44)), (23,18--23,19), - Some (23,44--23,45), (23,18--23,45)), - (23,12--23,45)), - LongIdent - (SynLongIdent ([unit], [], [None])), - (23,12--23,45)), (22,15--22,30), - NoneAtInvisible, - { LeadingKeyword = Member (22,8--22,14) - InlineKeyword = None - EqualsRange = Some (22,37--22,38) }), - (22,8--23,45))], (21,4--23,45))], (5,4--23,45)), - [], - Some - (ImplicitCtor - (None, [], Const (Unit, (4,8--4,10)), None, - PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), - (4,5--4,8), { AsKeyword = None })), (4,5--23,45), - { LeadingKeyword = Type (4,0--4,4) - EqualsRange = Some (4,11--4,12) - WithKeyword = None })], (4,0--23,45)); - Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [A], - PreXmlDoc ((25,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (25,5--25,6)), - Simple - (Union - (None, - [SynUnionCase - ([], SynIdent (A, None), - Fields - [SynField - ([], false, None, - LongIdent (SynLongIdent ([int], [], [None])), - false, - PreXmlDoc ((25,14), FSharp.Compiler.Xml.XmlDocCollector), - None, (25,14--25,17), - { LeadingKeyword = None - MutableKeyword = None })], - PreXmlDoc ((25,9), FSharp.Compiler.Xml.XmlDocCollector), - None, (25,9--25,17), { BarRange = None })], - (25,9--25,17)), (25,9--25,17)), - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (27,13--27,19)), - (27,8--27,19)); - GetSetMember - (Some - (SynBinding - (None, Normal, false, false, [], - PreXmlMerge - (PreXmlDoc ((28,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertyGet }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; RandomNumber], [(28,16--28,17)], - [None; None]), Some get, None, - Pats - [Paren - (Const (Unit, (28,38--28,40)), - (28,38--28,40))], None, (28,35--28,40)), - None, - App - (Atomic, false, - DotGet - (App - (Atomic, false, Ident Random, - Const (Unit, (28,49--28,51)), - (28,43--28,51)), (28,51--28,52), - SynLongIdent ([Next], [], [None]), - (28,43--28,56)), Const (Unit, (28,56--28,58)), - (28,43--28,58)), (28,35--28,40), NoneAtInvisible, - { LeadingKeyword = Member (28,8--28,14) - InlineKeyword = None - EqualsRange = Some (28,41--28,42) })), None, - (28,8--28,58), { InlineKeyword = None - WithKeyword = (28,30--28,34) - GetKeyword = Some (28,35--28,38) - AndKeyword = None - SetKeyword = None })], None, - (25,5--28,58), { LeadingKeyword = Type (25,0--25,4) - EqualsRange = Some (25,7--25,8) - WithKeyword = Some (26,4--26,8) })], - (25,0--28,58)); - Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [ARecord], - PreXmlDoc ((30,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (30,5--30,12)), - Simple - (Record - (None, - [SynField - ([], false, Some A, - LongIdent (SynLongIdent ([int], [], [None])), false, - PreXmlDoc ((30,17), FSharp.Compiler.Xml.XmlDocCollector), - None, (30,17--30,24), { LeadingKeyword = None - MutableKeyword = None })], - (30,15--30,26)), (30,15--30,26)), - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (32,13--32,19)), - (32,8--32,19)); - GetSetMember - (Some - (SynBinding - (None, Normal, false, false, [], - PreXmlMerge - (PreXmlDoc ((33,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertyGet }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; RandomNumber], [(33,16--33,17)], - [None; None]), Some get, None, - Pats - [Paren - (Const (Unit, (33,38--33,40)), - (33,38--33,40))], None, (33,35--33,40)), - None, - App - (Atomic, false, - DotGet - (App - (Atomic, false, Ident Random, - Const (Unit, (33,49--33,51)), - (33,43--33,51)), (33,51--33,52), - SynLongIdent ([Next], [], [None]), - (33,43--33,56)), Const (Unit, (33,56--33,58)), - (33,43--33,58)), (33,35--33,40), NoneAtInvisible, - { LeadingKeyword = Member (33,8--33,14) - InlineKeyword = None - EqualsRange = Some (33,41--33,42) })), None, - (33,8--33,58), { InlineKeyword = None - WithKeyword = (33,30--33,34) - GetKeyword = Some (33,35--33,38) - AndKeyword = None - SetKeyword = None })], None, - (30,5--33,58), { LeadingKeyword = Type (30,0--30,4) - EqualsRange = Some (30,13--30,14) - WithKeyword = Some (31,4--31,8) })], - (30,0--33,58)); - Exception - (SynExceptionDefn - (SynExceptionDefnRepr - ([], - SynUnionCase - ([], SynIdent (AException, None), - Fields - [SynField - ([], false, None, - LongIdent (SynLongIdent ([int], [], [None])), false, - PreXmlDoc ((35,24), FSharp.Compiler.Xml.XmlDocCollector), - None, (35,24--35,27), { LeadingKeyword = None - MutableKeyword = None })], - PreXmlDocEmpty, None, (35,10--35,27), { BarRange = None }), - None, - PreXmlDoc ((35,0), FSharp.Compiler.Xml.XmlDocCollector), - None, (35,0--35,27)), Some (36,4--36,8), - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (37,13--37,19)), - (37,8--37,19)); - GetSetMember - (Some - (SynBinding - (None, Normal, false, false, [], - PreXmlMerge - (PreXmlDoc ((38,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertyGet }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; RandomNumber], [(38,16--38,17)], - [None; None]), Some get, None, - Pats - [Paren - (Const (Unit, (38,38--38,40)), (38,38--38,40))], - None, (38,35--38,40)), None, - App - (Atomic, false, - DotGet - (App - (Atomic, false, Ident Random, - Const (Unit, (38,49--38,51)), (38,43--38,51)), - (38,51--38,52), - SynLongIdent ([Next], [], [None]), - (38,43--38,56)), Const (Unit, (38,56--38,58)), - (38,43--38,58)), (38,35--38,40), NoneAtInvisible, - { LeadingKeyword = Member (38,8--38,14) - InlineKeyword = None - EqualsRange = Some (38,41--38,42) })), None, - (38,8--38,58), { InlineKeyword = None - WithKeyword = (38,30--38,34) - GetKeyword = Some (38,35--38,38) - AndKeyword = None - SetKeyword = None })], (35,0--38,58)), - (35,0--38,58)); - Types - ([SynTypeDefn - (SynComponentInfo - ([{ Attributes = - [{ TypeName = SynLongIdent ([Struct], [], [None]) - ArgExpr = Const (Unit, (40,2--40,8)) - Target = None - AppliesToGetterAndSetter = false - Range = (40,2--40,8) }] - Range = (40,0--40,10) }], None, [], [ABC], - PreXmlDoc ((40,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (41,5--41,8)), - ObjectModel - (Unspecified, - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (42,9--42,15)), - (42,4--42,15)); - ValField - (SynField - ([], false, Some a, - LongIdent (SynLongIdent ([Int32], [], [None])), - false, - PreXmlDoc ((43,4), FSharp.Compiler.Xml.XmlDocCollector), - None, (43,4--43,16), - { LeadingKeyword = Some (Val (43,4--43,7)) - MutableKeyword = None }), (43,4--43,16)); - ValField - (SynField - ([], false, Some b, - LongIdent (SynLongIdent ([Int32], [], [None])), - false, - PreXmlDoc ((44,4), FSharp.Compiler.Xml.XmlDocCollector), - None, (44,4--44,16), - { LeadingKeyword = Some (Val (44,4--44,7)) - MutableKeyword = None }), (44,4--44,16)); - Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((45,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = false - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Constructor }, - SynValInfo - ([[SynArgInfo ([], false, Some a)]], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent ([new], [], [None]), None, - Some (SynValTyparDecls (None, false)), - Pats - [Paren - (Named - (SynIdent (a, None), false, None, - (45,9--45,10)), (45,8--45,11))], None, - (45,4--45,7)), None, - Open - (Type - (LongIdent - (SynLongIdent - ([System; Int32], [(46,24--46,25)], - [None; None])), (46,18--46,30)), - (46,8--46,30), (46,8--47,31), - Record - (None, None, - [SynExprRecordField - ((SynLongIdent ([a], [], [None]), true), - Some (47,12--47,13), Some (Ident a), - (47,10--47,15), - Some ((47,15--47,16), Some (47,16))); - SynExprRecordField - ((SynLongIdent ([b], [], [None]), true), - Some (47,19--47,20), Some (Ident MinValue), - (47,17--47,29), None)], (47,8--47,31))), - (45,4--45,11), NoneAtInvisible, - { LeadingKeyword = New (45,4--45,7) - InlineKeyword = None - EqualsRange = Some (45,12--45,13) }), - (45,4--47,31))], (42,4--47,31)), [], None, - (40,0--47,31), { LeadingKeyword = Type (41,0--41,4) - EqualsRange = Some (41,9--41,10) - WithKeyword = None })], (40,0--47,31)); - Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [System; Int32], - PreXmlDoc ((49,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (49,5--49,17)), - ObjectModel (Augmentation (49,18--49,22), [], (49,5--51,34)), - [Open - (Type - (LongIdent - (SynLongIdent - ([System; Math], [(50,20--50,21)], [None; None])), - (50,14--50,25)), (50,4--50,25)); - Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((51,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([this; Abs111], [(51,15--51,16)], [None; None]), - None, None, Pats [], None, (51,11--51,22)), None, - App - (Atomic, false, Ident Abs, - Paren - (Ident this, (51,28--51,29), Some (51,33--51,34), - (51,28--51,34)), (51,25--51,34)), (51,11--51,22), - NoneAtInvisible, - { LeadingKeyword = Member (51,4--51,10) - InlineKeyword = None - EqualsRange = Some (51,23--51,24) }), (51,4--51,34))], - None, (49,5--51,34), { LeadingKeyword = Type (49,0--49,4) - EqualsRange = None - WithKeyword = None })], (49,0--51,34))], - PreXmlDoc ((2,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, - (2,0--51,34), { LeadingKeyword = Module (2,0--2,6) })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [LineComment (1,0--1,57)] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs b/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs deleted file mode 100644 index 38e95c7ded1..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs +++ /dev/null @@ -1,93 +0,0 @@ -// #Regression #Conformance #DeclarationElements #Import -module openModInFun - -let f x y = - let result = x + y - open System - Console.WriteLine(result.ToString()) - - open type Console - WriteLine(result.ToString()) - -let top x y = - let r1 = x + y - let r2 = x * y - let nested x y = - open System - Console.WriteLine(r1.ToString()) - nested r1 r2 - -type Foo() = - do - open System - open type Console - WriteLine 123 - member public this.PrintHello() = - open System - Console.WriteLine("Hello!") - - -( - open type - System.Console - WriteLine() -) - - -// In `match` -match Some 1 with -| Some 1 when open System; Int32.MinValue < 0 -> - open type System.Console - WriteLine "Is 1" -| _ -> () - -// In `for` -for _ in open System.Linq; Enumerable.Range(0, 10) do - open type System.Console - WriteLine "Hello, World!" - -// In `while` -while - (open type System.Int32 - MaxValue < 0) do - open type System.Console - WriteLine "MaxValue is negative" - -// In `if` -if (open type System.Int32; MaxValue <> MinValue) then - open type System.Console - WriteLine "MaxValue is not equal to MinValue" -elif (open type System.Int32; MaxValue < 0) then - open type System.Console - WriteLine "MaxValue is negative" -else - open type System.Console - WriteLine "MaxValue is positive" - -// In `try` -try - open type System.Int32 - open Checked - ignore(MaxValue + 1) -with | exn -> open type System.Console; WriteLine exn.Message - -// In lambdas -let fun1 = fun x -> open System; x + 1 -let fun2 = function x -> open type System.Int32; x + MinValue - -// In computation expressions -let res = async { - open System - Console.WriteLine("Hello, World!") - let! x = Async.Sleep 1000 - return x -} - -// In `query` -let q = - query { - open type System.Linq.Enumerable - for i in Range(1, 10) do - open type int - yield MinValue + i - } |> Seq.toArray diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs.bsl deleted file mode 100644 index c92c72b1cd2..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/openModInFun.fs.bsl +++ /dev/null @@ -1,848 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/openModInFun.fs", false, - QualifiedNameOfFile openModInFun, [], - [SynModuleOrNamespace - ([openModInFun], false, NamedModule, - [Let - (false, - [SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((4,0), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, - SynValInfo - ([[SynArgInfo ([], false, Some x)]; - [SynArgInfo ([], false, Some y)]], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent ([f], [], [None]), None, None, - Pats - [Named (SynIdent (x, None), false, None, (4,6--4,7)); - Named (SynIdent (y, None), false, None, (4,8--4,9))], - None, (4,4--4,9)), None, - LetOrUse - (false, false, - [SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, SynValInfo ([], SynArgInfo ([], false, None)), - None), - Named - (SynIdent (result, None), false, None, (5,8--5,14)), - None, - App - (NonAtomic, false, - App - (NonAtomic, true, - LongIdent - (false, - SynLongIdent - ([op_Addition], [], - [Some (OriginalNotation "+")]), None, - (5,19--5,20)), Ident x, (5,17--5,20)), Ident y, - (5,17--5,22)), (5,8--5,14), Yes (5,4--5,22), - { LeadingKeyword = Let (5,4--5,7) - InlineKeyword = None - EqualsRange = Some (5,15--5,16) })], - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (6,9--6,15)), - (6,4--6,15), (6,4--10,32), - Sequential - (SuppressNeither, true, - App - (Atomic, false, - LongIdent - (false, - SynLongIdent - ([Console; WriteLine], [(7,11--7,12)], - [None; None]), None, (7,4--7,21)), - Paren - (App - (Atomic, false, - LongIdent - (false, - SynLongIdent - ([result; ToString], [(7,28--7,29)], - [None; None]), None, (7,22--7,37)), - Const (Unit, (7,37--7,39)), (7,22--7,39)), - (7,21--7,22), Some (7,39--7,40), (7,21--7,40)), - (7,4--7,40)), - Open - (Type - (LongIdent - (SynLongIdent ([Console], [], [None])), - (9,14--9,21)), (9,4--9,21), (9,4--10,32), - App - (Atomic, false, Ident WriteLine, - Paren - (App - (Atomic, false, - LongIdent - (false, - SynLongIdent - ([result; ToString], - [(10,20--10,21)], [None; None]), - None, (10,14--10,29)), - Const (Unit, (10,29--10,31)), - (10,14--10,31)), (10,13--10,14), - Some (10,31--10,32), (10,13--10,32)), - (10,4--10,32))), (7,4--10,32), - { SeparatorRange = None })), (5,4--10,32), - { LetOrUseKeyword = (5,4--5,7) - InKeyword = None - EqualsRange = Some (5,15--5,16) }), (4,4--4,9), NoneAtLet, - { LeadingKeyword = Let (4,0--4,3) - InlineKeyword = None - EqualsRange = Some (4,10--4,11) })], (4,0--10,32)); - Let - (false, - [SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((12,0), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, - SynValInfo - ([[SynArgInfo ([], false, Some x)]; - [SynArgInfo ([], false, Some y)]], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent ([top], [], [None]), None, None, - Pats - [Named (SynIdent (x, None), false, None, (12,8--12,9)); - Named (SynIdent (y, None), false, None, (12,10--12,11))], - None, (12,4--12,11)), None, - LetOrUse - (false, false, - [SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((13,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, SynValInfo ([], SynArgInfo ([], false, None)), - None), - Named (SynIdent (r1, None), false, None, (13,8--13,10)), - None, - App - (NonAtomic, false, - App - (NonAtomic, true, - LongIdent - (false, - SynLongIdent - ([op_Addition], [], - [Some (OriginalNotation "+")]), None, - (13,15--13,16)), Ident x, (13,13--13,16)), - Ident y, (13,13--13,18)), (13,8--13,10), - Yes (13,4--13,18), - { LeadingKeyword = Let (13,4--13,7) - InlineKeyword = None - EqualsRange = Some (13,11--13,12) })], - LetOrUse - (false, false, - [SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((14,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, - SynValInfo ([], SynArgInfo ([], false, None)), - None), - Named - (SynIdent (r2, None), false, None, (14,8--14,10)), - None, - App - (NonAtomic, false, - App - (NonAtomic, true, - LongIdent - (false, - SynLongIdent - ([op_Multiply], [], - [Some (OriginalNotation "*")]), None, - (14,15--14,16)), Ident x, (14,13--14,16)), - Ident y, (14,13--14,18)), (14,8--14,10), - Yes (14,4--14,18), - { LeadingKeyword = Let (14,4--14,7) - InlineKeyword = None - EqualsRange = Some (14,11--14,12) })], - LetOrUse - (false, false, - [SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((15,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, - SynValInfo - ([[SynArgInfo ([], false, Some x)]; - [SynArgInfo ([], false, Some y)]], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent ([nested], [], [None]), None, - None, - Pats - [Named - (SynIdent (x, None), false, None, - (15,15--15,16)); - Named - (SynIdent (y, None), false, None, - (15,17--15,18))], None, (15,8--15,18)), - None, - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), - (16,13--16,19)), (16,8--16,19), - (16,8--17,40), - App - (Atomic, false, - LongIdent - (false, - SynLongIdent - ([Console; WriteLine], - [(17,15--17,16)], [None; None]), None, - (17,8--17,25)), - Paren - (App - (Atomic, false, - LongIdent - (false, - SynLongIdent - ([r1; ToString], - [(17,28--17,29)], [None; None]), - None, (17,26--17,37)), - Const (Unit, (17,37--17,39)), - (17,26--17,39)), (17,25--17,26), - Some (17,39--17,40), (17,25--17,40)), - (17,8--17,40))), (15,8--15,18), NoneAtLet, - { LeadingKeyword = Let (15,4--15,7) - InlineKeyword = None - EqualsRange = Some (15,19--15,20) })], - App - (NonAtomic, false, - App - (NonAtomic, false, Ident nested, Ident r1, - (18,4--18,13)), Ident r2, (18,4--18,16)), - (15,4--18,16), { LetOrUseKeyword = (15,4--15,7) - InKeyword = None - EqualsRange = Some (15,19--15,20) }), - (14,4--18,16), { LetOrUseKeyword = (14,4--14,7) - InKeyword = None - EqualsRange = Some (14,11--14,12) }), - (13,4--18,16), { LetOrUseKeyword = (13,4--13,7) - InKeyword = None - EqualsRange = Some (13,11--13,12) }), - (12,4--12,11), NoneAtLet, - { LeadingKeyword = Let (12,0--12,3) - InlineKeyword = None - EqualsRange = Some (12,12--12,13) })], (12,0--18,16)); - Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [Foo], - PreXmlDoc ((20,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (20,5--20,8)), - ObjectModel - (Unspecified, - [ImplicitCtor - (None, [], Const (Unit, (20,8--20,10)), None, - PreXmlDoc ((20,8), FSharp.Compiler.Xml.XmlDocCollector), - (20,5--20,8), { AsKeyword = None }); - LetBindings - ([SynBinding - (None, Do, false, false, [], PreXmlDocEmpty, - SynValData - (None, - SynValInfo ([], SynArgInfo ([], false, None)), - None), Const (Unit, (21,4--24,21)), None, - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), - (22,13--22,19)), (22,8--22,19), (22,8--24,21), - Open - (Type - (LongIdent - (SynLongIdent ([Console], [], [None])), - (23,18--23,25)), (23,8--23,25), - (23,8--24,21), - App - (NonAtomic, false, Ident WriteLine, - Const (Int32 123, (24,18--24,21)), - (24,8--24,21)))), (21,4--24,21), NoneAtDo, - { LeadingKeyword = Do (21,4--21,6) - InlineKeyword = None - EqualsRange = None })], false, false, - (21,4--24,21)); - Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((25,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([this; PrintHello], [(25,22--25,23)], - [None; None]), None, None, - Pats - [Paren - (Const (Unit, (25,33--25,35)), - (25,33--25,35))], - Some (Public (25,11--25,17)), (25,11--25,35)), - None, - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), - (26,13--26,19)), (26,8--26,19), (26,8--27,35), - App - (Atomic, false, - LongIdent - (false, - SynLongIdent - ([Console; WriteLine], [(27,15--27,16)], - [None; None]), None, (27,8--27,25)), - Paren - (Const - (String - ("Hello!", Regular, (27,26--27,34)), - (27,26--27,34)), (27,25--27,26), - Some (27,34--27,35), (27,25--27,35)), - (27,8--27,35))), (25,11--25,35), - NoneAtInvisible, - { LeadingKeyword = Member (25,4--25,10) - InlineKeyword = None - EqualsRange = Some (25,36--25,37) }), - (25,4--27,35))], (21,4--27,35)), [], - Some - (ImplicitCtor - (None, [], Const (Unit, (20,8--20,10)), None, - PreXmlDoc ((20,8), FSharp.Compiler.Xml.XmlDocCollector), - (20,5--20,8), { AsKeyword = None })), (20,5--27,35), - { LeadingKeyword = Type (20,0--20,4) - EqualsRange = Some (20,11--20,12) - WithKeyword = None })], (20,0--27,35)); - Expr - (Paren - (Open - (Type - (LongIdent - (SynLongIdent - ([System; Console], [(32,14--32,15)], [None; None])), - (32,8--32,22)), (31,4--32,22), (31,4--33,15), - App - (Atomic, false, Ident WriteLine, - Const (Unit, (33,13--33,15)), (33,4--33,15))), - (30,0--30,1), Some (34,0--34,1), (30,0--34,1)), (30,0--34,1)); - Expr - (Match - (Yes (38,0--38,17), - App - (NonAtomic, false, Ident Some, - Const (Int32 1, (38,11--38,12)), (38,6--38,12)), - [SynMatchClause - (LongIdent - (SynLongIdent ([Some], [], [None]), None, None, - Pats [Const (Int32 1, (39,7--39,8))], None, (39,2--39,8)), - Some - (Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), - (39,19--39,25)), (39,14--39,25), (39,14--39,45), - App - (NonAtomic, false, - App - (NonAtomic, true, - LongIdent - (false, - SynLongIdent - ([op_LessThan], [], - [Some (OriginalNotation "<")]), None, - (39,42--39,43)), - LongIdent - (false, - SynLongIdent - ([Int32; MinValue], [(39,32--39,33)], - [None; None]), None, (39,27--39,41)), - (39,27--39,43)), - Const (Int32 0, (39,44--39,45)), (39,27--39,45)))), - Open - (Type - (LongIdent - (SynLongIdent - ([System; Console], [(40,20--40,21)], - [None; None])), (40,14--40,28)), (40,4--40,28), - (40,4--41,20), - App - (NonAtomic, false, Ident WriteLine, - Const - (String ("Is 1", Regular, (41,14--41,20)), - (41,14--41,20)), (41,4--41,20))), (39,2--41,20), - Yes, { ArrowRange = Some (39,46--39,48) - BarRange = Some (39,0--39,1) }); - SynMatchClause - (Wild (42,2--42,3), None, Const (Unit, (42,7--42,9)), - (42,2--42,9), Yes, { ArrowRange = Some (42,4--42,6) - BarRange = Some (42,0--42,1) })], - (38,0--42,9), { MatchKeyword = (38,0--38,5) - WithKeyword = (38,13--38,17) }), (38,0--42,9)); - Expr - (ForEach - (Yes (45,0--45,3), Yes (45,6--45,8), SeqExprOnly false, true, - Wild (45,4--45,5), - Open - (ModuleOrNamespace - (SynLongIdent - ([System; Linq], [(45,20--45,21)], [None; None]), - (45,14--45,25)), (45,9--45,25), (45,9--45,50), - App - (Atomic, false, - LongIdent - (false, - SynLongIdent - ([Enumerable; Range], [(45,37--45,38)], [None; None]), - None, (45,27--45,43)), - Paren - (Tuple - (false, - [Const (Int32 0, (45,44--45,45)); - Const (Int32 10, (45,47--45,49))], - [(45,45--45,46)], (45,44--45,49)), (45,43--45,44), - Some (45,49--45,50), (45,43--45,50)), (45,27--45,50))), - Open - (Type - (LongIdent - (SynLongIdent - ([System; Console], [(46,20--46,21)], [None; None])), - (46,14--46,28)), (46,4--46,28), (46,4--47,29), - App - (NonAtomic, false, Ident WriteLine, - Const - (String ("Hello, World!", Regular, (47,14--47,29)), - (47,14--47,29)), (47,4--47,29))), (45,0--47,29)), - (45,0--47,29)); - Expr - (While - (Yes (50,0--52,18), - Paren - (Open - (Type - (LongIdent - (SynLongIdent - ([System; Int32], [(51,21--51,22)], [None; None])), - (51,15--51,27)), (51,5--51,27), (51,5--52,17), - App - (NonAtomic, false, - App - (NonAtomic, true, - LongIdent - (false, - SynLongIdent - ([op_LessThan], [], - [Some (OriginalNotation "<")]), None, - (52,14--52,15)), Ident MaxValue, (52,5--52,15)), - Const (Int32 0, (52,16--52,17)), (52,5--52,17))), - (51,4--51,5), Some (52,17--52,18), (51,4--52,18)), - Open - (Type - (LongIdent - (SynLongIdent - ([System; Console], [(53,20--53,21)], [None; None])), - (53,14--53,28)), (53,4--53,28), (53,4--54,36), - App - (NonAtomic, false, Ident WriteLine, - Const - (String - ("MaxValue is negative", Regular, (54,14--54,36)), - (54,14--54,36)), (54,4--54,36))), (50,0--54,36)), - (50,0--54,36)); - Expr - (IfThenElse - (Paren - (Open - (Type - (LongIdent - (SynLongIdent - ([System; Int32], [(57,20--57,21)], [None; None])), - (57,14--57,26)), (57,4--57,26), (57,4--57,48), - App - (NonAtomic, false, - App - (NonAtomic, true, - LongIdent - (false, - SynLongIdent - ([op_Inequality], [], - [Some (OriginalNotation "<>")]), None, - (57,37--57,39)), Ident MaxValue, (57,28--57,39)), - Ident MinValue, (57,28--57,48))), (57,3--57,4), - Some (57,48--57,49), (57,3--57,49)), - Open - (Type - (LongIdent - (SynLongIdent - ([System; Console], [(58,20--58,21)], [None; None])), - (58,14--58,28)), (58,4--58,28), (58,4--59,49), - App - (NonAtomic, false, Ident WriteLine, - Const - (String - ("MaxValue is not equal to MinValue", Regular, - (59,14--59,49)), (59,14--59,49)), (59,4--59,49))), - Some - (IfThenElse - (Paren - (Open - (Type - (LongIdent - (SynLongIdent - ([System; Int32], [(60,22--60,23)], - [None; None])), (60,16--60,28)), - (60,6--60,28), (60,6--60,42), - App - (NonAtomic, false, - App - (NonAtomic, true, - LongIdent - (false, - SynLongIdent - ([op_LessThan], [], - [Some (OriginalNotation "<")]), None, - (60,39--60,40)), Ident MaxValue, - (60,30--60,40)), - Const (Int32 0, (60,41--60,42)), (60,30--60,42))), - (60,5--60,6), Some (60,42--60,43), (60,5--60,43)), - Open - (Type - (LongIdent - (SynLongIdent - ([System; Console], [(61,20--61,21)], - [None; None])), (61,14--61,28)), - (61,4--61,28), (61,4--62,36), - App - (NonAtomic, false, Ident WriteLine, - Const - (String - ("MaxValue is negative", Regular, - (62,14--62,36)), (62,14--62,36)), - (62,4--62,36))), - Some - (Open - (Type - (LongIdent - (SynLongIdent - ([System; Console], [(64,20--64,21)], - [None; None])), (64,14--64,28)), - (64,4--64,28), (64,4--65,36), - App - (NonAtomic, false, Ident WriteLine, - Const - (String - ("MaxValue is positive", Regular, - (65,14--65,36)), (65,14--65,36)), - (65,4--65,36)))), Yes (60,0--60,48), false, - (60,0--65,36), { IfKeyword = (60,0--60,4) - IsElif = true - ThenKeyword = (60,44--60,48) - ElseKeyword = Some (63,0--63,4) - IfToThenRange = (60,0--60,48) })), - Yes (57,0--57,54), false, (57,0--65,36), - { IfKeyword = (57,0--57,2) - IsElif = false - ThenKeyword = (57,50--57,54) - ElseKeyword = None - IfToThenRange = (57,0--57,54) }), (57,0--65,36)); - Expr - (TryWith - (Open - (Type - (LongIdent - (SynLongIdent - ([System; Int32], [(69,20--69,21)], [None; None])), - (69,14--69,26)), (69,4--69,26), (69,4--71,24), - Open - (ModuleOrNamespace - (SynLongIdent ([Checked], [], [None]), (70,9--70,16)), - (70,4--70,16), (70,4--71,24), - App - (Atomic, false, Ident ignore, - Paren - (App - (NonAtomic, false, - App - (NonAtomic, true, - LongIdent - (false, - SynLongIdent - ([op_Addition], [], - [Some (OriginalNotation "+")]), None, - (71,20--71,21)), Ident MaxValue, - (71,11--71,21)), - Const (Int32 1, (71,22--71,23)), (71,11--71,23)), - (71,10--71,11), Some (71,23--71,24), (71,10--71,24)), - (71,4--71,24)))), - [SynMatchClause - (Named (SynIdent (exn, None), false, None, (72,7--72,10)), - None, - Open - (Type - (LongIdent - (SynLongIdent - ([System; Console], [(72,30--72,31)], - [None; None])), (72,24--72,38)), (72,14--72,38), - (72,14--72,61), - App - (NonAtomic, false, Ident WriteLine, - LongIdent - (false, - SynLongIdent - ([exn; Message], [(72,53--72,54)], [None; None]), - None, (72,50--72,61)), (72,40--72,61))), - (72,7--72,61), Yes, { ArrowRange = Some (72,11--72,13) - BarRange = Some (72,5--72,6) })], - (68,0--72,61), Yes (68,0--68,3), Yes (72,0--72,4), - { TryKeyword = (68,0--68,3) - TryToWithRange = (68,0--72,4) - WithKeyword = (72,0--72,4) - WithToEndRange = (72,0--72,61) }), (68,0--72,61)); - Let - (false, - [SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((75,0), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, - SynValInfo - ([[SynArgInfo ([], false, Some x)]], - SynArgInfo ([], false, None)), None), - Named (SynIdent (fun1, None), false, None, (75,4--75,8)), None, - Lambda - (false, false, - SimplePats - ([Id (x, None, false, false, false, (75,15--75,16))], [], - (75,15--75,16)), - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (75,25--75,31)), - (75,20--75,31), (75,20--75,38), - App - (NonAtomic, false, - App - (NonAtomic, true, - LongIdent - (false, - SynLongIdent - ([op_Addition], [], - [Some (OriginalNotation "+")]), None, - (75,35--75,36)), Ident x, (75,33--75,36)), - Const (Int32 1, (75,37--75,38)), (75,33--75,38))), - Some - ([Named (SynIdent (x, None), false, None, (75,15--75,16))], - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), - (75,25--75,31)), (75,20--75,31), (75,20--75,38), - App - (NonAtomic, false, - App - (NonAtomic, true, - LongIdent - (false, - SynLongIdent - ([op_Addition], [], - [Some (OriginalNotation "+")]), None, - (75,35--75,36)), Ident x, (75,33--75,36)), - Const (Int32 1, (75,37--75,38)), (75,33--75,38)))), - (75,11--75,38), { ArrowRange = Some (75,17--75,19) }), - (75,4--75,8), NoneAtLet, { LeadingKeyword = Let (75,0--75,3) - InlineKeyword = None - EqualsRange = Some (75,9--75,10) })], - (75,0--75,38)); - Let - (false, - [SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((76,0), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, SynValInfo ([], SynArgInfo ([], false, None)), None), - Named (SynIdent (fun2, None), false, None, (76,4--76,8)), None, - MatchLambda - (false, (76,11--76,19), - [SynMatchClause - (Named (SynIdent (x, None), false, None, (76,20--76,21)), - None, - Open - (Type - (LongIdent - (SynLongIdent - ([System; Int32], [(76,41--76,42)], - [None; None])), (76,35--76,47)), - (76,25--76,47), (76,25--76,61), - App - (NonAtomic, false, - App - (NonAtomic, true, - LongIdent - (false, - SynLongIdent - ([op_Addition], [], - [Some (OriginalNotation "+")]), None, - (76,51--76,52)), Ident x, (76,49--76,52)), - Ident MinValue, (76,49--76,61))), (76,20--76,61), - Yes, { ArrowRange = Some (76,22--76,24) - BarRange = None })], NoneAtInvisible, - (76,11--76,61)), (76,4--76,8), NoneAtLet, - { LeadingKeyword = Let (76,0--76,3) - InlineKeyword = None - EqualsRange = Some (76,9--76,10) })], (76,0--76,61)); - Let - (false, - [SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((79,0), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, SynValInfo ([], SynArgInfo ([], false, None)), None), - Named (SynIdent (res, None), false, None, (79,4--79,7)), None, - App - (NonAtomic, false, Ident async, - ComputationExpr - (false, - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (80,9--80,15)), - (80,4--80,15), (80,4--83,12), - Sequential - (SuppressNeither, true, - App - (Atomic, false, - LongIdent - (false, - SynLongIdent - ([Console; WriteLine], [(81,11--81,12)], - [None; None]), None, (81,4--81,21)), - Paren - (Const - (String - ("Hello, World!", Regular, - (81,22--81,37)), (81,22--81,37)), - (81,21--81,22), Some (81,37--81,38), - (81,21--81,38)), (81,4--81,38)), - LetOrUseBang - (Yes (82,4--82,29), false, true, - Named - (SynIdent (x, None), false, None, - (82,9--82,10)), - App - (NonAtomic, false, - LongIdent - (false, - SynLongIdent - ([Async; Sleep], [(82,18--82,19)], - [None; None]), None, (82,13--82,24)), - Const (Int32 1000, (82,25--82,29)), - (82,13--82,29)), [], - YieldOrReturn - ((false, true), Ident x, (83,4--83,12), - { YieldOrReturnKeyword = (83,4--83,10) }), - (82,4--83,12), - { LetOrUseKeyword = (82,4--82,8) - InKeyword = None - EqualsRange = Some (82,11--82,12) }), - (81,4--83,12), { SeparatorRange = None })), - (79,16--84,1)), (79,10--84,1)), (79,4--79,7), NoneAtLet, - { LeadingKeyword = Let (79,0--79,3) - InlineKeyword = None - EqualsRange = Some (79,8--79,9) })], (79,0--84,1)); - Let - (false, - [SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((87,0), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (None, SynValInfo ([], SynArgInfo ([], false, None)), None), - Named (SynIdent (q, None), false, None, (87,4--87,5)), None, - App - (NonAtomic, false, - App - (NonAtomic, true, - LongIdent - (false, - SynLongIdent - ([op_PipeRight], [], [Some (OriginalNotation "|>")]), - None, (93,6--93,8)), - App - (NonAtomic, false, Ident query, - ComputationExpr - (false, - Open - (Type - (LongIdent - (SynLongIdent - ([System; Linq; Enumerable], - [(89,24--89,25); (89,29--89,30)], - [None; None; None])), (89,18--89,40)), - (89,8--89,40), (89,8--92,30), - ForEach - (Yes (90,8--90,11), Yes (90,14--90,16), - SeqExprOnly false, true, - Named - (SynIdent (i, None), false, None, - (90,12--90,13)), - App - (Atomic, false, Ident Range, - Paren - (Tuple - (false, - [Const (Int32 1, (90,23--90,24)); - Const (Int32 10, (90,26--90,28))], - [(90,24--90,25)], (90,23--90,28)), - (90,22--90,23), Some (90,28--90,29), - (90,22--90,29)), (90,17--90,29)), - Open - (Type - (LongIdent - (SynLongIdent ([int], [], [None])), - (91,22--91,25)), (91,12--91,25), - (91,12--92,30), - YieldOrReturn - ((true, false), - App - (NonAtomic, false, - App - (NonAtomic, true, - LongIdent - (false, - SynLongIdent - ([op_Addition], [], - [Some - (OriginalNotation "+")]), - None, (92,27--92,28)), - Ident MinValue, (92,18--92,28)), - Ident i, (92,18--92,30)), - (92,12--92,30), - { YieldOrReturnKeyword = - (92,12--92,17) })), (90,8--92,30))), - (88,10--93,5)), (88,4--93,5)), (88,4--93,8)), - LongIdent - (false, - SynLongIdent - ([Seq; toArray], [(93,12--93,13)], [None; None]), None, - (93,9--93,20)), (88,4--93,20)), (87,4--87,5), NoneAtLet, - { LeadingKeyword = Let (87,0--87,3) - InlineKeyword = None - EqualsRange = Some (87,6--87,7) })], (87,0--93,20))], - PreXmlDoc ((2,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, - (2,0--93,20), { LeadingKeyword = Module (2,0--2,6) })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = - [LineComment (1,0--1,57); LineComment (37,0--37,13); - LineComment (44,0--44,11); LineComment (49,0--49,13); - LineComment (56,0--56,10); LineComment (67,0--67,11); - LineComment (74,0--74,13); LineComment (78,0--78,29); - LineComment (86,0--86,13)] }, set [])) From 04c2064f6e5c8fcc97897d41bd84e2013249a47d Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:04:28 +0800 Subject: [PATCH 17/22] split lang feature; fix tests --- src/Compiler/Checking/CheckDeclarations.fs | 6 ++++-- .../Checking/Expressions/CheckExpressions.fs | 2 +- src/Compiler/FSComp.txt | 3 ++- src/Compiler/Facilities/LanguageFeatures.fs | 9 ++++++--- src/Compiler/Facilities/LanguageFeatures.fsi | 3 ++- src/Compiler/xlf/FSComp.txt.cs.xlf | 15 ++++++++++----- src/Compiler/xlf/FSComp.txt.de.xlf | 15 ++++++++++----- src/Compiler/xlf/FSComp.txt.es.xlf | 15 ++++++++++----- src/Compiler/xlf/FSComp.txt.fr.xlf | 15 ++++++++++----- src/Compiler/xlf/FSComp.txt.it.xlf | 15 ++++++++++----- src/Compiler/xlf/FSComp.txt.ja.xlf | 15 ++++++++++----- src/Compiler/xlf/FSComp.txt.ko.xlf | 15 ++++++++++----- src/Compiler/xlf/FSComp.txt.pl.xlf | 15 ++++++++++----- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 15 ++++++++++----- src/Compiler/xlf/FSComp.txt.ru.xlf | 15 ++++++++++----- src/Compiler/xlf/FSComp.txt.tr.xlf | 15 ++++++++++----- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 15 ++++++++++----- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 15 ++++++++++----- vsintegration/tests/UnitTests/UnusedOpensTests.fs | 4 ++-- 19 files changed, 147 insertions(+), 75 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 9071ac3d2b3..3dd171ba7ec 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -676,6 +676,8 @@ let TcTyconMemberSpecs cenv env containerInfo declKind tpenv augSpfn = let TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) = CheckBasics.TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) +// Build a TcEnv with type-scoped opens applied. +// This function maybe call multiple times during the type checking. let private buildTcEnvWithTypeScopedOpensApplied (cenv: cenv) scopem (synMembers: 'MemberInfo) env = // Because 'MemberInfo is not SynMemberDefn list when it is in signature files, // we need to check the type first @@ -685,7 +687,7 @@ let private buildTcEnvWithTypeScopedOpensApplied (cenv: cenv) scopem (synMembers // we can just go through until we hit a non-open declaration let rec loop env = function | SynMemberDefn.Open (target, mOpen) :: rest -> - checkLanguageFeatureAndRecover cenv.g.langVersion LanguageFeature.ExpressionAndTypeScopedOpens mOpen + checkLanguageFeatureAndRecover cenv.g.langVersion LanguageFeature.OpensInTypeScope mOpen let env, _openDecl = TcOpenDecl cenv mOpen scopem env target loop env rest @@ -1092,7 +1094,7 @@ module MutRecBindingChecking = cbinds, innerState | Some (SynMemberDefn.Open (target, m)), _ -> - if cenv.g.langVersion.SupportsFeature(LanguageFeature.ExpressionAndTypeScopedOpens) then + if cenv.g.langVersion.SupportsFeature(LanguageFeature.OpensInTypeScope) then [Phase2AOpen (target, m)], innerState else [], innerState diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index eede534bafc..6aafbfdf46f 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -6092,7 +6092,7 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE error(Error(FSComp.SR.tcInvalidIndexerExpression(), m)) | SynExpr.Open (target, mOpen, _m, body) -> - checkLanguageFeatureAndRecover g.langVersion LanguageFeature.ExpressionAndTypeScopedOpens mOpen + checkLanguageFeatureAndRecover g.langVersion LanguageFeature.OpensInExpressionScope mOpen let env, _openDecls = TcOpenDecl cenv mOpen body.Range env target TcExprThatCanBeCtorBody cenv overallTy env tpenv body diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index e63ce66fba3..2173303fddf 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1810,4 +1810,5 @@ featureAllowLetOrUseBangTypeAnnotationWithoutParens,"Allow let! and use! type an 3878,tcAttributeIsNotValidForUnionCaseWithFields,"This attribute is not valid for use on union cases with fields." featureReturnFromFinal,"Support for ReturnFromFinal/YieldFromFinal in computation expressions to enable tailcall optimization when available on the builder." 3879,tcTypeDefinitionsMustHaveOpensBeforeOtherMembers,"'open' declarations must come before all other definitions in type definitions or augmentation" -featureExpressionAndTypeScopedOpens,"'open' declarations in expression or type scopes" \ No newline at end of file +featureOpensInExpressionScope,"'open' declarations in expression scopes" +featureOpensInTypeScope,"'open' declarations in type scopes" \ No newline at end of file diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 9afea15396b..f690b268540 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -104,7 +104,8 @@ type LanguageFeature = | ScopedNowarn | AllowTypedLetUseAndBang | ReturnFromFinal - | ExpressionAndTypeScopedOpens + | OpensInExpressionScope + | OpensInTypeScope /// LanguageVersion management type LanguageVersion(versionText) = @@ -244,7 +245,8 @@ type LanguageVersion(versionText) = // F# preview (still preview in 10.0) LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work - LanguageFeature.ExpressionAndTypeScopedOpens, previewVersion + LanguageFeature.OpensInExpressionScope, previewVersion + LanguageFeature.OpensInTypeScope, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -414,7 +416,8 @@ type LanguageVersion(versionText) = | LanguageFeature.ScopedNowarn -> FSComp.SR.featureScopedNowarn () | LanguageFeature.AllowTypedLetUseAndBang -> FSComp.SR.featureAllowLetOrUseBangTypeAnnotationWithoutParens () | LanguageFeature.ReturnFromFinal -> FSComp.SR.featureReturnFromFinal () - | LanguageFeature.ExpressionAndTypeScopedOpens -> FSComp.SR.featureExpressionAndTypeScopedOpens () + | LanguageFeature.OpensInExpressionScope -> FSComp.SR.featureOpensInExpressionScope () + | LanguageFeature.OpensInTypeScope -> FSComp.SR.featureOpensInTypeScope () /// 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 c2ed8b7c9d7..657392a64ed 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -95,7 +95,8 @@ type LanguageFeature = | ScopedNowarn | AllowTypedLetUseAndBang | ReturnFromFinal - | ExpressionAndTypeScopedOpens + | OpensInExpressionScope + | OpensInTypeScope /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 3911ebabad5..1ee43ea3236 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -412,11 +412,6 @@ více typů podporuje měrné jednotky - - 'open' declarations in expression or type scopes - 'open' declarations in expression or type scopes - - extended fixed bindings for byref and GetPinnableReference rozšířené pevné vazby pro byref a GetPinnableReference @@ -537,6 +532,16 @@ Otevřít deklaraci typu + + 'open' declarations in expression scopes + 'open' declarations in expression scopes + + + + 'open' declarations in type scopes + 'open' declarations in type scopes + + overloads for custom operations přetížení pro vlastní operace diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 16397298802..b8c3c39141b 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -412,11 +412,6 @@ Maßeinheitenunterstützung durch weitere Typen - - 'open' declarations in expression or type scopes - 'open' declarations in expression or type scopes - - extended fixed bindings for byref and GetPinnableReference Erweiterte feste Bindungen für byref und GetPinnableReference @@ -537,6 +532,16 @@ Deklaration für offene Typen + + 'open' declarations in expression scopes + 'open' declarations in expression scopes + + + + 'open' declarations in type scopes + 'open' declarations in type scopes + + overloads for custom operations Überladungen für benutzerdefinierte Vorgänge diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 389d343496a..dee9c82f3bb 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -412,11 +412,6 @@ más tipos admiten las unidades de medida - - 'open' declarations in expression or type scopes - 'open' declarations in expression or type scopes - - extended fixed bindings for byref and GetPinnableReference enlaces fijos extendidos para byref y GetPinnableReference @@ -537,6 +532,16 @@ declaración de tipo abierto + + 'open' declarations in expression scopes + 'open' declarations in expression scopes + + + + 'open' declarations in type scopes + 'open' declarations in type scopes + + overloads for custom operations sobrecargas para operaciones personalizadas diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 98073316d3e..022be4a7a93 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -412,11 +412,6 @@ d'autres types prennent en charge les unités de mesure - - 'open' declarations in expression or type scopes - 'open' declarations in expression or type scopes - - extended fixed bindings for byref and GetPinnableReference liaisons fixes étendues pour byref et GetPinnableReference @@ -537,6 +532,16 @@ déclaration de type ouverte + + 'open' declarations in expression scopes + 'open' declarations in expression scopes + + + + 'open' declarations in type scopes + 'open' declarations in type scopes + + overloads for custom operations surcharges pour les opérations personnalisées diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index bfa7ab8e3f1..9ec4fc4b355 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -412,11 +412,6 @@ più tipi supportano le unità di misura - - 'open' declarations in expression or type scopes - 'open' declarations in expression or type scopes - - extended fixed bindings for byref and GetPinnableReference binding fissi estesi per byref e GetPinnableReference @@ -537,6 +532,16 @@ dichiarazione di tipo aperto + + 'open' declarations in expression scopes + 'open' declarations in expression scopes + + + + 'open' declarations in type scopes + 'open' declarations in type scopes + + overloads for custom operations overload per le operazioni personalizzate diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 691a18de16f..7eeea45b3d3 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -412,11 +412,6 @@ 単位をサポートするその他の型 - - 'open' declarations in expression or type scopes - 'open' declarations in expression or type scopes - - extended fixed bindings for byref and GetPinnableReference byref と GetPinnableReference の拡張固定バインド @@ -537,6 +532,16 @@ オープン型宣言 + + 'open' declarations in expression scopes + 'open' declarations in expression scopes + + + + 'open' declarations in type scopes + 'open' declarations in type scopes + + overloads for custom operations カスタム操作のオーバーロード diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index a26cd50872f..16c8b7d7bd8 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -412,11 +412,6 @@ 더 많은 형식이 측정 단위를 지원함 - - 'open' declarations in expression or type scopes - 'open' declarations in expression or type scopes - - extended fixed bindings for byref and GetPinnableReference byref 및 GetPinnableReference에 대한 확장된 고정 바인딩 @@ -537,6 +532,16 @@ 개방형 형식 선언 + + 'open' declarations in expression scopes + 'open' declarations in expression scopes + + + + 'open' declarations in type scopes + 'open' declarations in type scopes + + overloads for custom operations 사용자 지정 작업의 오버로드 diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 104d6c47e6c..4aaabd661dd 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -412,11 +412,6 @@ więcej typów obsługuje jednostki miary - - 'open' declarations in expression or type scopes - 'open' declarations in expression or type scopes - - extended fixed bindings for byref and GetPinnableReference rozszerzone powiązania stałe dla elementów byref i GetPinnableReference @@ -537,6 +532,16 @@ deklaracja typu otwartego + + 'open' declarations in expression scopes + 'open' declarations in expression scopes + + + + 'open' declarations in type scopes + 'open' declarations in type scopes + + overloads for custom operations przeciążenia dla operacji niestandardowych diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 0ab15ad913c..fd38267e845 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -412,11 +412,6 @@ mais tipos dão suporte para unidades de medida - - 'open' declarations in expression or type scopes - 'open' declarations in expression or type scopes - - extended fixed bindings for byref and GetPinnableReference associações fixas estendidas para byref e GetPinnableReference @@ -537,6 +532,16 @@ declaração de tipo aberto + + 'open' declarations in expression scopes + 'open' declarations in expression scopes + + + + 'open' declarations in type scopes + 'open' declarations in type scopes + + overloads for custom operations sobrecargas para operações personalizadas diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index bb2f9ae16c1..ca2e6c96575 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -412,11 +412,6 @@ другие типы поддерживают единицы измерения - - 'open' declarations in expression or type scopes - 'open' declarations in expression or type scopes - - extended fixed bindings for byref and GetPinnableReference расширенные фиксированные привязки для byref и GetPinnableReference @@ -537,6 +532,16 @@ объявление открытого типа + + 'open' declarations in expression scopes + 'open' declarations in expression scopes + + + + 'open' declarations in type scopes + 'open' declarations in type scopes + + overloads for custom operations перегрузки для настраиваемых операций diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index ed49c2c06d1..946e778147b 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -412,11 +412,6 @@ tür daha ölçü birimlerini destekler - - 'open' declarations in expression or type scopes - 'open' declarations in expression or type scopes - - extended fixed bindings for byref and GetPinnableReference byref ve GetPinnableReference için genişletilmiş sabit bağlamalar @@ -537,6 +532,16 @@ açık tür bildirimi + + 'open' declarations in expression scopes + 'open' declarations in expression scopes + + + + 'open' declarations in type scopes + 'open' declarations in type scopes + + overloads for custom operations özel işlemler için aşırı yüklemeler diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 38426723eb5..c3ef0333316 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -412,11 +412,6 @@ 更多类型支持度量单位 - - 'open' declarations in expression or type scopes - 'open' declarations in expression or type scopes - - extended fixed bindings for byref and GetPinnableReference byref 和 GetPinnableReference 的扩展固定绑定 @@ -537,6 +532,16 @@ 开放类型声明 + + 'open' declarations in expression scopes + 'open' declarations in expression scopes + + + + 'open' declarations in type scopes + 'open' declarations in type scopes + + overloads for custom operations 自定义操作的重载 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index e4461337887..1734dc661dc 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -412,11 +412,6 @@ 更多支援測量單位的類型 - - 'open' declarations in expression or type scopes - 'open' declarations in expression or type scopes - - extended fixed bindings for byref and GetPinnableReference ByRef 和 GetPinnableReference 的擴充固定繫結 @@ -537,6 +532,16 @@ 開放式類型宣告 + + 'open' declarations in expression scopes + 'open' declarations in expression scopes + + + + 'open' declarations in type scopes + 'open' declarations in type scopes + + overloads for custom operations 為自訂作業多載 diff --git a/vsintegration/tests/UnitTests/UnusedOpensTests.fs b/vsintegration/tests/UnitTests/UnusedOpensTests.fs index 5fb4da21860..7acd63b491a 100644 --- a/vsintegration/tests/UnitTests/UnusedOpensTests.fs +++ b/vsintegration/tests/UnitTests/UnusedOpensTests.fs @@ -868,7 +868,7 @@ type T() = open type System.Console do printfn "%s" "Hello World" """ - => [3, (14, 28)] + => [3, (14, 28); 3, (14, 28)] [] @@ -880,7 +880,7 @@ type T() = open System.IO do File.Create "" """ - => [ 5, (9, 18) ] + => [ 5, (9, 18); 5, (9, 18) ] [] From 1a4a25ab5263cea047cc1d07b3af98444ba141ec Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Fri, 8 Aug 2025 17:07:50 +0800 Subject: [PATCH 18/22] remove open in type --- .editorconfig | 2 + src/Compiler/Checking/CheckDeclarations.fs | 111 +++--------------- src/Compiler/FSComp.txt | 4 +- src/Compiler/Facilities/LanguageFeatures.fs | 3 - src/Compiler/Facilities/LanguageFeatures.fsi | 1 - src/Compiler/xlf/FSComp.txt.cs.xlf | 10 -- src/Compiler/xlf/FSComp.txt.de.xlf | 10 -- src/Compiler/xlf/FSComp.txt.es.xlf | 10 -- src/Compiler/xlf/FSComp.txt.fr.xlf | 10 -- src/Compiler/xlf/FSComp.txt.it.xlf | 10 -- src/Compiler/xlf/FSComp.txt.ja.xlf | 10 -- src/Compiler/xlf/FSComp.txt.ko.xlf | 10 -- src/Compiler/xlf/FSComp.txt.pl.xlf | 10 -- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 10 -- src/Compiler/xlf/FSComp.txt.ru.xlf | 10 -- src/Compiler/xlf/FSComp.txt.tr.xlf | 10 -- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 10 -- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 10 -- .../ImportDeclarations/ImportDeclarations.fs | 4 +- .../Tests.LanguageService.ParameterInfo.fs | 2 +- .../tests/UnitTests/UnusedOpensTests.fs | 6 +- 21 files changed, 26 insertions(+), 237 deletions(-) diff --git a/.editorconfig b/.editorconfig index 54ab5fb9706..e2d011710b5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,10 +13,12 @@ fsharp_max_dot_get_expression_width=80 fsharp_multiline_block_brackets_on_same_column=true fsharp_multiline_bracket_style=aligned fsharp_keep_max_number_of_blank_lines=1 +end_of_line=crlf [*.fsi] fsharp_newline_between_type_definition_and_members=true fsharp_keep_max_number_of_blank_lines=1 +end_of_line=crlf # These files contains many imperative if-then expressions which are not clearer on one line # Reducing fsharp_max_if_then_else_short_width back to its default formats these over multiple lines. diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 3dd171ba7ec..e2df92e2680 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -675,28 +675,6 @@ let TcTyconMemberSpecs cenv env containerInfo declKind tpenv augSpfn = let TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) = CheckBasics.TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) - -// Build a TcEnv with type-scoped opens applied. -// This function maybe call multiple times during the type checking. -let private buildTcEnvWithTypeScopedOpensApplied (cenv: cenv) scopem (synMembers: 'MemberInfo) env = - // Because 'MemberInfo is not SynMemberDefn list when it is in signature files, - // we need to check the type first - match box synMembers with - | :? (SynMemberDefn list) as synMembers -> - // Since type-scoped opens are always at the top of the type definition, - // we can just go through until we hit a non-open declaration - let rec loop env = function - | SynMemberDefn.Open (target, mOpen) :: rest -> - checkLanguageFeatureAndRecover cenv.g.langVersion LanguageFeature.OpensInTypeScope mOpen - let env, _openDecl = TcOpenDecl cenv mOpen scopem env target - loop env rest - - // The implicit constructor maybe on the first one, skip them. - | SynMemberDefn.ImplicitCtor _ :: rest -> loop env rest - | _ -> env - - loop env synMembers - | _ -> env let MakeSafeInitField (cenv: cenv) env m isStatic = let id = @@ -879,8 +857,6 @@ module MutRecBindingChecking = /// Indicates the last 'field' has been initialized, only 'do' comes after | Phase2AIncrClassCtorJustAfterLastLet - | Phase2AOpen of target: SynOpenDeclTarget * range: range - /// The collected syntactic input definitions for a single type or type-extension definition type TyconBindingsPhase2A = | TyconBindingsPhase2A of Tycon option * DeclKind * Val list * TyconRef * Typar list * TType * TyconBindingPhase2A list @@ -1092,13 +1068,6 @@ module MutRecBindingChecking = let innerState = (incrCtorInfoOpt, envForTycon, tpenv, recBindIdx, List.rev binds @ uncheckedBindsRev) cbinds, innerState - - | Some (SynMemberDefn.Open (target, m)), _ -> - if cenv.g.langVersion.SupportsFeature(LanguageFeature.OpensInTypeScope) then - [Phase2AOpen (target, m)], innerState - else - [], innerState - | definition -> error(InternalError(sprintf "Unexpected definition %A" definition, m))) @@ -1146,7 +1115,7 @@ module MutRecBindingChecking = let rest = let isAfter b = match b with - | Phase2AIncrClassCtor _ | Phase2AInherit _ | Phase2AIncrClassCtorJustAfterSuperInit | Phase2AOpen _ -> false + | Phase2AIncrClassCtor _ | Phase2AInherit _ | Phase2AIncrClassCtorJustAfterSuperInit -> false | Phase2AIncrClassBindings (_, binds, _, _, _) -> binds |> List.exists (function SynBinding (kind=SynBindingKind.Do) -> true | _ -> false) | Phase2AIncrClassCtorJustAfterLastLet | Phase2AMember _ -> true @@ -1262,7 +1231,7 @@ module MutRecBindingChecking = let defnBs, (tpenv, _, _, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) = let initialInnerState = (tpenv, envForTycon, envForTycon, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - (initialInnerState, defnAs) ||> List.collectFold (fun innerState defnA -> + (initialInnerState, defnAs) ||> List.mapFold (fun innerState defnA -> let tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable = innerState @@ -1295,7 +1264,7 @@ module MutRecBindingChecking = | Some incrCtorInfo -> TcLetrecComputeCtorSafeThisValBind cenv incrCtorInfo.InstanceCtorSafeThisValOpt let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - [Phase2BIncrClassCtor (staticCtorInfo, incrCtorInfoOpt, safeThisValBindOpt)], innerState + Phase2BIncrClassCtor (staticCtorInfo, incrCtorInfoOpt, safeThisValBindOpt), innerState // Phase2B: typecheck the argument to an 'inherits' call and build the new object expr for the inherit-call | Phase2AInherit (synBaseTy, arg, baseValOpt, m) -> @@ -1310,7 +1279,7 @@ module MutRecBindingChecking = let envInstance = match baseValOpt with Some baseVal -> AddLocalVal g cenv.tcSink scopem baseVal envInstance | None -> envInstance let envNonRec = match baseValOpt with Some baseVal -> AddLocalVal g cenv.tcSink scopem baseVal envNonRec | None -> envNonRec let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - [Phase2BInherit inheritsExpr], innerState + Phase2BInherit inheritsExpr, innerState // Phase2B: let and let rec value and function definitions | Phase2AIncrClassBindings (tcref, binds, isStatic, isRec, mBinds) -> @@ -1355,15 +1324,15 @@ module MutRecBindingChecking = let envInstance = (if isStatic then (binds, envInstance) ||> List.foldBack (fun b e -> AddLocalVal g cenv.tcSink scopem b.Var e) else env) let envStatic = (if isStatic then env else envStatic) let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - [Phase2BIncrClassBindings bindRs], innerState + Phase2BIncrClassBindings bindRs, innerState | Phase2AIncrClassCtorJustAfterSuperInit -> let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - [Phase2BIncrClassCtorJustAfterSuperInit], innerState + Phase2BIncrClassCtorJustAfterSuperInit, innerState | Phase2AIncrClassCtorJustAfterLastLet -> let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - [Phase2BIncrClassCtorJustAfterLastLet], innerState + Phase2BIncrClassCtorJustAfterLastLet, innerState // Note: this path doesn't add anything the environment, because the member is already available off via its type @@ -1393,16 +1362,7 @@ module MutRecBindingChecking = TcLetrecBinding (cenv, envForBinding, scopem, extraGeneralizableTypars, reqdThisValTyOpt) (envNonRec, generalizedRecBinds, preGeneralizationRecBinds, tpenv, uncheckedRecBindsTable) rbind let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - [Phase2BMember rbind.RecBindingInfo.Index], innerState - - | Phase2AOpen (target, m) -> - // excepts the line before 'open' - let scopem = withStart m.End scopem - let envInstance, _openDecls = TcOpenDecl cenv m scopem envInstance target - let envStatic, _openDecls = TcOpenDecl cenv m scopem envStatic target - let innerState = (tpenv, envInstance, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) - [], innerState - ) + Phase2BMember rbind.RecBindingInfo.Index, innerState) let tyconOpt = if not(cenv.g.langVersion.SupportsFeature(LanguageFeature.CSharpExtensionAttributeNotRequired)) then @@ -2011,10 +1971,10 @@ let TcMutRecDefns_Phase2 (cenv: cenv) envInitial mBinds scopem mutRecNSInfo (env match mem with | SynMemberDefn.AutoProperty (isStatic=isStatic) | SynMemberDefn.LetBindings (isStatic=isStatic) when isStatic -> () - | SynMemberDefn.Open _ | SynMemberDefn.Member _ | SynMemberDefn.GetSetMember _ | SynMemberDefn.Interface _ -> () + | SynMemberDefn.Open _ | SynMemberDefn.AutoProperty _ | SynMemberDefn.LetBindings _ | SynMemberDefn.ImplicitCtor _ // accept implicit ctor pattern, should be first! @@ -2051,12 +2011,10 @@ let TcMutRecDefns_Phase2 (cenv: cenv) envInitial mBinds scopem mutRecNSInfo (env | _ -> envForDecls let obinds = tyconBindingsOfTypeDefn tyconData - let ibinds = - // The env with type-scoped `open`s applied - let envForDecls = buildTcEnvWithTypeScopedOpensApplied cenv scopem synMembers envForDecls - let intfTypes = interfacesFromTypeDefn envForDecls tyconData - let slotImplSets = DispatchSlotChecking.GetSlotImplSets cenv.infoReader envForDecls.DisplayEnv envForDecls.AccessRights false (List.map (fun (intfTy, _, m) -> (intfTy, m)) intfTypes) - (intfTypes, slotImplSets) ||> List.map2 (interfaceMembersFromTypeDefn tyconData) |> List.concat + let ibinds = + let intfTypes = interfacesFromTypeDefn envForDecls tyconData + let slotImplSets = DispatchSlotChecking.GetSlotImplSets cenv.infoReader envForDecls.DisplayEnv envForDecls.AccessRights false (List.map (fun (intfTy, _, m) -> (intfTy, m)) intfTypes) + (intfTypes, slotImplSets) ||> List.map2 (interfaceMembersFromTypeDefn tyconData) |> List.concat MutRecDefnsPhase2InfoForTycon(tyconOpt, tcref, declaredTyconTypars, declKind, obinds @ ibinds, fixupFinalAttrs)) MutRecBindingChecking.TcMutRecDefns_Phase2_Bindings cenv envInitial tpenv mBinds scopem mutRecNSInfo envMutRec binds @@ -2339,14 +2297,6 @@ let CheckForDuplicateModule env nm m = if curr.ModulesAndNamespacesByDemangledName.ContainsKey nm then errorR (Duplicate(FSComp.SR.tcTypeOrModule(), nm, m)) -// Check the ordering of opens -// 'open' declarations must come before all other definitions in type definitions -let rec private CheckOpensOrderInTypeDefinition metNonOpen = function -// The implicit constructor maybe on the first one, skip them. -| (SynMemberDefn.Open _ | SynMemberDefn.ImplicitCtor _) :: ds when not metNonOpen -> CheckOpensOrderInTypeDefinition false ds -| SynMemberDefn.Open (range = m) :: _ -> errorR(Error(FSComp.SR.tcTypeDefinitionsMustHaveOpensBeforeOtherMembers(), m)) -| _ :: ds -> CheckOpensOrderInTypeDefinition true ds -| [] -> () //------------------------------------------------------------------------- // Bind exception definitions @@ -2460,8 +2410,6 @@ module TcExceptionDeclarations = let binds1, exnc = TcExnDefnCore cenv envInitial parent core let envMutRec = AddLocalExnDefnAndReport cenv.tcSink scopem (AddLocalTycons g cenv.amap scopem [exnc] envInitial) exnc - CheckOpensOrderInTypeDefinition false aug - let defns = [MutRecShape.Tycon(MutRecDefnsPhase2DataForTycon(Some exnc, parent, ModuleOrMemberBinding, mkLocalEntityRef exnc, None, NoSafeInitInfo, [], aug, m, NoNewSlots, (fun () -> ())))] let binds2, envFinal = TcMutRecDefns_Phase2 cenv envInitial m scopem None envMutRec defns true let binds2flat = binds2 |> MutRecShapes.collectTycons |> List.collect snd @@ -3239,16 +3187,13 @@ module EstablishTypeDefinitionCores = let tyconWithImplementsL = (envMutRec, mutRecDefns) ||> MutRecShapes.mapTyconsWithEnv (fun envinner (origInfo, tyconAndAttrsOpt) -> match origInfo, tyconAndAttrsOpt with - | (typeDefCore, memberDefns, _), Some (tycon, (attrs, _)) -> + | (typeDefCore, _, _), Some (tycon, (attrs, _)) -> let (MutRecDefnsPhase1DataForTycon(_, synTyconRepr, explicitImplements, _, _, _)) = typeDefCore let m = tycon.Range let tcref = mkLocalTyconRef tycon let envinner = AddDeclaredTypars CheckForDuplicateTypars (tycon.Typars m) envinner let envinner = MakeInnerEnvForTyconRef envinner tcref false - - // The env with type-scoped `open`s applied - // Used to type check TYPENAME in `interface TYPENAME with ...` or `inherit TYPENAME` - let envinner = buildTcEnvWithTypeScopedOpensApplied cenv synTyconRepr.Range memberDefns envinner + let implementedTys, _ = List.mapFold (mapFoldFst (TcTypeAndRecover cenv NoNewTypars checkConstraints ItemOccurrence.UseInType WarnOnIWSAM.No envinner)) tpenv explicitImplements if firstPass then @@ -4070,16 +4015,7 @@ module EstablishTypeDefinitionCores = (envMutRecPrelim, withEnvs) ||> MutRecShapes.mapTyconsWithEnv (fun envForDecls (origInfo, tyconOpt) -> match origInfo, tyconOpt with - | (MutRecDefnsPhase1DataForTycon(_, synTyconRepr, _, _, _, _) as typeDefCore, memberDefns, _), Some tycon -> - // The env with type-scoped `open`s applied. - // Used for type check fields on structs. - // Only apply when the type is not a union/record/exception, to avoid the field types - // can reference a type open in the `with` section. - let envForDecls = - if synTyconRepr.IsGeneral then - buildTcEnvWithTypeScopedOpensApplied cenv synTyconRepr.Range memberDefns envForDecls - else envForDecls - Some (tycon, GetStructuralElementsOfTyconDefn cenv envForDecls tpenv typeDefCore tycon) + | (typeDefCore, _, _), Some tycon -> Some (tycon, GetStructuralElementsOfTyconDefn cenv envForDecls tpenv typeDefCore tycon) | _ -> None) |> MutRecShapes.collectTycons |> List.choose id @@ -4125,16 +4061,7 @@ module EstablishTypeDefinitionCores = (envMutRecPrelim, withAttrs) ||> MutRecShapes.mapTyconsWithEnv (fun envForDecls (origInfo, tyconAndAttrsOpt) -> let info = match origInfo, tyconAndAttrsOpt with - | (MutRecDefnsPhase1DataForTycon(_, synTyconRepr, _, _, _, _) as typeDefCore, memberDefns, _), Some (tycon, (attrs, _)) -> - // The env with type-scoped `open`s applied. - // Used for type check fields. - // Only apply when the type is not a union/record/exception, to avoid the field types - // can reference a type open in the `with` section. - let envForDecls = - if synTyconRepr.IsGeneral then - buildTcEnvWithTypeScopedOpensApplied cenv synTyconRepr.Range memberDefns envForDecls - else envForDecls - TcTyconDefnCore_Phase1G_EstablishRepresentation cenv envForDecls tpenv inSig typeDefCore tycon attrs + | (typeDefCore, _, _), Some (tycon, (attrs, _)) -> TcTyconDefnCore_Phase1G_EstablishRepresentation cenv envForDecls tpenv inSig typeDefCore tycon attrs | _ -> None, NoSafeInitInfo let tyconOpt, fixupFinalAttrs = match tyconAndAttrsOpt with @@ -4472,16 +4399,12 @@ module TcDeclarations = /// body = members /// where members contain methods/overrides, also implicit ctor, inheritCall and local definitions. let rec private SplitTyconDefn g (SynTypeDefn(typeInfo=synTyconInfo;typeRepr=trepr; members=extraMembers)) = - CheckOpensOrderInTypeDefinition false extraMembers - let extraMembers = desugarGetSetMembers extraMembers let extraMembers, extra_vals_Inherits_Abstractslots = SplitAutoProps g extraMembers let implements1 = extraMembers |> List.choose (function SynMemberDefn.Interface (interfaceType=ty) -> Some(ty, ty.Range) | _ -> None) match trepr with | SynTypeDefnRepr.ObjectModel(kind, members, m) -> - CheckOpensOrderInTypeDefinition false members - let members = desugarGetSetMembers members CheckMembersForm members synTyconInfo.Range diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 2173303fddf..d84896a7c62 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1809,6 +1809,4 @@ featureAllowLetOrUseBangTypeAnnotationWithoutParens,"Allow let! and use! type an 3877,lexLineDirectiveMappingIsNotUnique,"The file '%s' was also pointed to in a line directive in '%s'. Proper warn directive application may not be possible." 3878,tcAttributeIsNotValidForUnionCaseWithFields,"This attribute is not valid for use on union cases with fields." featureReturnFromFinal,"Support for ReturnFromFinal/YieldFromFinal in computation expressions to enable tailcall optimization when available on the builder." -3879,tcTypeDefinitionsMustHaveOpensBeforeOtherMembers,"'open' declarations must come before all other definitions in type definitions or augmentation" -featureOpensInExpressionScope,"'open' declarations in expression scopes" -featureOpensInTypeScope,"'open' declarations in type scopes" \ No newline at end of file +featureOpensInExpressionScope,"'open' declarations in expression scopes" \ No newline at end of file diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index f690b268540..8b3c22761ff 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -105,7 +105,6 @@ type LanguageFeature = | AllowTypedLetUseAndBang | ReturnFromFinal | OpensInExpressionScope - | OpensInTypeScope /// LanguageVersion management type LanguageVersion(versionText) = @@ -246,7 +245,6 @@ type LanguageVersion(versionText) = // F# preview (still preview in 10.0) LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work LanguageFeature.OpensInExpressionScope, previewVersion - LanguageFeature.OpensInTypeScope, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -417,7 +415,6 @@ type LanguageVersion(versionText) = | LanguageFeature.AllowTypedLetUseAndBang -> FSComp.SR.featureAllowLetOrUseBangTypeAnnotationWithoutParens () | LanguageFeature.ReturnFromFinal -> FSComp.SR.featureReturnFromFinal () | LanguageFeature.OpensInExpressionScope -> FSComp.SR.featureOpensInExpressionScope () - | LanguageFeature.OpensInTypeScope -> FSComp.SR.featureOpensInTypeScope () /// 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 657392a64ed..901a5293cf9 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -96,7 +96,6 @@ type LanguageFeature = | AllowTypedLetUseAndBang | ReturnFromFinal | OpensInExpressionScope - | OpensInTypeScope /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 1ee43ea3236..60906d1be39 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -537,11 +537,6 @@ 'open' declarations in expression scopes - - 'open' declarations in type scopes - 'open' declarations in type scopes - - overloads for custom operations přetížení pro vlastní operace @@ -1777,11 +1772,6 @@ Vlastnost nesmí určovat volitelné argumenty, in, out, ParamArray, CallerInfo nebo Quote. - - 'open' declarations must come before all other definitions in type definitions or augmentation - 'open' declarations must come before all other definitions in type definitions or augmentation - - The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index b8c3c39141b..92d802087fe 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -537,11 +537,6 @@ 'open' declarations in expression scopes - - 'open' declarations in type scopes - 'open' declarations in type scopes - - overloads for custom operations Überladungen für benutzerdefinierte Vorgänge @@ -1777,11 +1772,6 @@ Ein Merkmal darf keine Argumente für „optional“, „in“, „out“, „ParamArray“", „CallerInfo“ oder „Quote“ angeben. - - 'open' declarations must come before all other definitions in type definitions or augmentation - 'open' declarations must come before all other definitions in type definitions or augmentation - - The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index dee9c82f3bb..447f157bc3b 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -537,11 +537,6 @@ 'open' declarations in expression scopes - - 'open' declarations in type scopes - 'open' declarations in type scopes - - overloads for custom operations sobrecargas para operaciones personalizadas @@ -1777,11 +1772,6 @@ Un rasgo no puede especificar argumentos opcionales, in, out, ParamArray, CallerInfo o Quote - - 'open' declarations must come before all other definitions in type definitions or augmentation - 'open' declarations must come before all other definitions in type definitions or augmentation - - The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 022be4a7a93..f2fb3bffe8f 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -537,11 +537,6 @@ 'open' declarations in expression scopes - - 'open' declarations in type scopes - 'open' declarations in type scopes - - overloads for custom operations surcharges pour les opérations personnalisées @@ -1777,11 +1772,6 @@ Une caractéristique ne peut pas spécifier d’arguments facultatifs, in, out, ParamArray, CallerInfo ou Quote - - 'open' declarations must come before all other definitions in type definitions or augmentation - 'open' declarations must come before all other definitions in type definitions or augmentation - - The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 9ec4fc4b355..e79c8c37af0 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -537,11 +537,6 @@ 'open' declarations in expression scopes - - 'open' declarations in type scopes - 'open' declarations in type scopes - - overloads for custom operations overload per le operazioni personalizzate @@ -1777,11 +1772,6 @@ Un tratto non può specificare argomenti optional, in, out, ParamArray, CallerInfo o Quote - - 'open' declarations must come before all other definitions in type definitions or augmentation - 'open' declarations must come before all other definitions in type definitions or augmentation - - The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 7eeea45b3d3..d303660f96a 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -537,11 +537,6 @@ 'open' declarations in expression scopes - - 'open' declarations in type scopes - 'open' declarations in type scopes - - overloads for custom operations カスタム操作のオーバーロード @@ -1777,11 +1772,6 @@ 特性では、オプションの、in 引数、out 引数、ParamArray 引数、CallerInfo 引数、または Quote 引数を指定することはできません - - 'open' declarations must come before all other definitions in type definitions or augmentation - 'open' declarations must come before all other definitions in type definitions or augmentation - - The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 16c8b7d7bd8..47c6078c6d2 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -537,11 +537,6 @@ 'open' declarations in expression scopes - - 'open' declarations in type scopes - 'open' declarations in type scopes - - overloads for custom operations 사용자 지정 작업의 오버로드 @@ -1777,11 +1772,6 @@ 특성은 optional, in, out, ParamArray, CallerInfo, Quote 인수를 지정할 수 없습니다. - - 'open' declarations must come before all other definitions in type definitions or augmentation - 'open' declarations must come before all other definitions in type definitions or augmentation - - The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 4aaabd661dd..c851a69346b 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -537,11 +537,6 @@ 'open' declarations in expression scopes - - 'open' declarations in type scopes - 'open' declarations in type scopes - - overloads for custom operations przeciążenia dla operacji niestandardowych @@ -1777,11 +1772,6 @@ Cecha nie może określać opcjonalnych argumentów in, out, ParamArray, CallerInfo lub Quote - - 'open' declarations must come before all other definitions in type definitions or augmentation - 'open' declarations must come before all other definitions in type definitions or augmentation - - The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index fd38267e845..922554912bf 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -537,11 +537,6 @@ 'open' declarations in expression scopes - - 'open' declarations in type scopes - 'open' declarations in type scopes - - overloads for custom operations sobrecargas para operações personalizadas @@ -1777,11 +1772,6 @@ Uma característica não pode especificar os argumentos optional, in, out, ParamArray, CallerInfo ou Quote - - 'open' declarations must come before all other definitions in type definitions or augmentation - 'open' declarations must come before all other definitions in type definitions or augmentation - - The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index ca2e6c96575..2cdd3193d73 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -537,11 +537,6 @@ 'open' declarations in expression scopes - - 'open' declarations in type scopes - 'open' declarations in type scopes - - overloads for custom operations перегрузки для настраиваемых операций @@ -1777,11 +1772,6 @@ Признак не может указывать необязательные аргументы in, out, ParamArray, CallerInfo или Quote - - 'open' declarations must come before all other definitions in type definitions or augmentation - 'open' declarations must come before all other definitions in type definitions or augmentation - - The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 946e778147b..89b112218c1 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -537,11 +537,6 @@ 'open' declarations in expression scopes - - 'open' declarations in type scopes - 'open' declarations in type scopes - - overloads for custom operations özel işlemler için aşırı yüklemeler @@ -1777,11 +1772,6 @@ Bir nitelik optional, in, out, ParamArray, CallerInfo veya Quote bağımsız değişkenlerini belirtemiyor - - 'open' declarations must come before all other definitions in type definitions or augmentation - 'open' declarations must come before all other definitions in type definitions or augmentation - - The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index c3ef0333316..aa8792186a3 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -537,11 +537,6 @@ 'open' declarations in expression scopes - - 'open' declarations in type scopes - 'open' declarations in type scopes - - overloads for custom operations 自定义操作的重载 @@ -1777,11 +1772,6 @@ 特征不能指定 option、in、out、ParamArray、CallerInfo 或 Quote 参数 - - 'open' declarations must come before all other definitions in type definitions or augmentation - 'open' declarations must come before all other definitions in type definitions or augmentation - - The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 1734dc661dc..45883257168 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -537,11 +537,6 @@ 'open' declarations in expression scopes - - 'open' declarations in type scopes - 'open' declarations in type scopes - - overloads for custom operations 為自訂作業多載 @@ -1777,11 +1772,6 @@ 特徵不能指定選擇性、in、out、ParamArray、CallerInfo 或 Quote 引數 - - 'open' declarations must come before all other definitions in type definitions or augmentation - 'open' declarations must come before all other definitions in type definitions or augmentation - - The type '{0}' does not support a nullness qualification. The type '{0}' does not support a nullness qualification. diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs index 8c719ec90ac..29d8907519d 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs @@ -66,7 +66,7 @@ module ImportDeclarations = ] // SOURCE=E_openInTypeDecl.fs SCFLAGS="--test:ErrorRanges" # E_openInTypeDecl.fs - [] + [] let ``E_openInTypeDecl_fs`` compilation = compilation |> withOptions ["--nowarn:52"] // The value has been copied to ensure the original is not mutated by this operation or because the copy is implicit when returning a struct from a member and another member is then accessed @@ -96,7 +96,7 @@ module ImportDeclarations = ] // SOURCE=openInTypeDecl.fs # openInTypeDecl.fs - [] + [] let ``openInTypeDecl_fs`` compilation = compilation |> withOptions ["--nowarn:52"] // The value has been copied to ensure the original is not mutated by this operation or because the copy is implicit when returning a struct from a member and another member is then accessed diff --git a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ParameterInfo.fs b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ParameterInfo.fs index 6729e428bac..f866c19168d 100644 --- a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ParameterInfo.fs +++ b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ParameterInfo.fs @@ -1206,7 +1206,7 @@ We really need to rewrite some code paths here to use the real parse tree rather ^x.M1^(^(1,$ """, markAtEOF=true) - [] + [] member public this.``LocationOfParams.UnmatchedParens.Bug91609.OtherCases.Open``() = this.TestParameterInfoLocationOfParams(""" let arr = Array.create 4 1 diff --git a/vsintegration/tests/UnitTests/UnusedOpensTests.fs b/vsintegration/tests/UnitTests/UnusedOpensTests.fs index 7acd63b491a..eacb36f620b 100644 --- a/vsintegration/tests/UnitTests/UnusedOpensTests.fs +++ b/vsintegration/tests/UnitTests/UnusedOpensTests.fs @@ -861,7 +861,7 @@ let f() = """ => [3, (14, 28)] -[] +[] let ``unused open C# type in type scoped``() = """ type T() = @@ -871,7 +871,7 @@ type T() = => [3, (14, 28); 3, (14, 28)] -[] +[] let ``type-scoped open declaration duplication in module is unused``() = """ module TopModule @@ -895,7 +895,7 @@ let _ = => [ 5, (9, 18) ] -[] +[] let ``type- and expression-scoped open declaration duplication in module is unused``() = """ module TopModule From 70dc26951c94a9470d6f7f31029aff9e3b85a1d9 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Fri, 8 Aug 2025 17:13:26 +0800 Subject: [PATCH 19/22] release note --- .editorconfig | 2 -- docs/release-notes/.FSharp.Compiler.Service/10.0.100.md | 2 +- docs/release-notes/.Language/preview.md | 2 +- src/Compiler/Checking/CheckBasics.fs | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.editorconfig b/.editorconfig index e2d011710b5..54ab5fb9706 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,12 +13,10 @@ fsharp_max_dot_get_expression_width=80 fsharp_multiline_block_brackets_on_same_column=true fsharp_multiline_bracket_style=aligned fsharp_keep_max_number_of_blank_lines=1 -end_of_line=crlf [*.fsi] fsharp_newline_between_type_definition_and_members=true fsharp_keep_max_number_of_blank_lines=1 -end_of_line=crlf # These files contains many imperative if-then expressions which are not clearer on one line # Reducing fsharp_max_if_then_else_short_width back to its default formats these over multiple lines. diff --git a/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md index b149c92a7d4..2174ce50cbb 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/10.0.100.md @@ -3,7 +3,7 @@ * Add support for `when 'T : Enum` library-only static optimization constraint. ([PR #18546](https://github.com/dotnet/fsharp/pull/18546)) * Add support for tail calls in computation expressions ([PR #18804](https://github.com/dotnet/fsharp/pull/18804)) * Add `--typecheck-only` flag support for F# Interactive (FSI) scripts to type-check without execution. ([Issue #18686](https://github.com/dotnet/fsharp/issues/18686)) -* Allow opens in expression/type scoped. ([Suggestion](https://github.com/fsharp/fslang-suggestions/issues/96), [PR #18814](https://github.com/dotnet/fsharp/pull/18814)) +* Allow open declarations in expression scope. ([Suggestion](https://github.com/fsharp/fslang-suggestions/issues/96), [PR #18814](https://github.com/dotnet/fsharp/pull/18814)) ### Fixed diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md index 55d9310a6a5..558f362810e 100644 --- a/docs/release-notes/.Language/preview.md +++ b/docs/release-notes/.Language/preview.md @@ -11,7 +11,7 @@ * Allow `let!`, `use!`, `and!` type annotations without requiring parentheses (([PR #18508](https://github.com/dotnet/fsharp/pull/18508) and [PR #18682](https://github.com/dotnet/fsharp/pull/18682))) * Exception names are now validated for illegal characters using the same mechanism as types/modules/namespaces ([Issue #18763](https://github.com/dotnet/fsharp/issues/18763)) * Support tail calls in computation expressions ([PR #18804](https://github.com/dotnet/fsharp/pull/18804)) -* Allow opens in expression/type scoped. ([Suggestion](https://github.com/fsharp/fslang-suggestions/issues/96), [PR #18814](https://github.com/dotnet/fsharp/pull/18814)) +* Allow open declarations in expression scope. ([Suggestion](https://github.com/fsharp/fslang-suggestions/issues/96), [PR #18814](https://github.com/dotnet/fsharp/pull/18814)) ### Fixed diff --git a/src/Compiler/Checking/CheckBasics.fs b/src/Compiler/Checking/CheckBasics.fs index 302a366e72e..8ef29dd7400 100644 --- a/src/Compiler/Checking/CheckBasics.fs +++ b/src/Compiler/Checking/CheckBasics.fs @@ -381,7 +381,6 @@ type TcFileState = override _.ToString() = "" open FSharp.Compiler.AttributeChecking -open FSharp.Compiler.Features open FSharp.Compiler.Syntax.PrettyNaming open FSharp.Compiler.Text.Range open FSharp.Compiler.TypedTreeBasics From bf4f8cca42830e11f9005734c9f36d19574d02fb Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 12 Aug 2025 19:39:08 +0800 Subject: [PATCH 20/22] clean open in type scope --- src/Compiler/pars.fsy | 3 - .../ImportDeclarations/E_openInTypeDecl.fs | 69 +------------- .../E_openInTypeInterface.fs | 5 - .../ImportDeclarations/ImportDeclarations.fs | 47 +-------- .../ImportDeclarations/openInTypeDecl.fs | 58 ----------- .../OpenDeclaration/InInterfaceImplement.fs | 4 - .../InInterfaceImplement.fs.bsl | 67 ------------- .../OpenDeclaration/InInterfaceImplement2.fs | 4 - .../InInterfaceImplement2.fs.bsl | 67 ------------- .../SyntaxTree/OpenDeclaration/InType_Enum.fs | 3 - .../OpenDeclaration/InType_Enum.fs.bsl | 32 ------- .../OpenDeclaration/InType_Exception.fs | 4 - .../OpenDeclaration/InType_Exception.fs.bsl | 72 -------------- .../OpenDeclaration/InType_Extension.fs | 3 - .../OpenDeclaration/InType_Extension.fs.bsl | 53 ----------- .../OpenDeclaration/InType_Extension2.fs | 3 - .../OpenDeclaration/InType_Extension2.fs.bsl | 53 ----------- .../OpenDeclaration/InType_Record.fs | 4 - .../OpenDeclaration/InType_Record.fs.bsl | 75 --------------- .../OpenDeclaration/InType_Record2.fs | 4 - .../OpenDeclaration/InType_Record2.fs.bsl | 75 --------------- .../OpenDeclaration/InType_Record3.fs | 5 - .../OpenDeclaration/InType_Record3.fs.bsl | 71 -------------- .../OpenDeclaration/InType_Record4.fs | 5 - .../OpenDeclaration/InType_Record4.fs.bsl | 12 --- .../OpenDeclaration/InType_Struct.fs | 8 -- .../OpenDeclaration/InType_Struct.fs.bsl | 95 ------------------- .../OpenDeclaration/InType_Struct2.fs | 8 -- .../OpenDeclaration/InType_Struct2.fs.bsl | 95 ------------------- .../OpenDeclaration/InType_Union.fs | 4 - .../OpenDeclaration/InType_Union.fs.bsl | 81 ---------------- .../OpenDeclaration/InType_Union2.fs | 4 - .../OpenDeclaration/InType_Union2.fs.bsl | 81 ---------------- .../OpenDeclaration/InType_Union3.fs | 5 - .../OpenDeclaration/InType_Union3.fs.bsl | 71 -------------- .../OpenDeclaration/InType_Union4.fs | 5 - .../OpenDeclaration/InType_Union4.fs.bsl | 12 --- 37 files changed, 6 insertions(+), 1261 deletions(-) delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeInterface.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs delete mode 100644 tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs.bsl diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 20a7dac4058..58b2ced6e2f 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -2157,9 +2157,6 @@ classDefnMember: let leadingKeyword = SynTypeDefnLeadingKeyword.StaticType(rhs parseState 3, rhs parseState 4) [ SynMemberDefn.NestedType($5 leadingKeyword, None, rhs2 parseState 1 5) ] } - | openDecl - { [ SynMemberDefn.Open $1 ] } - /* A 'val' definition in an object type definition */ valDefnDecl: | VAL opt_mutable opt_access ident COLON typ diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs index 875d221f369..85a71f628f5 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeDecl.fs @@ -1,71 +1,8 @@ // #Regression #Conformance #DeclarationElements #Import -module openInTypeDecl +//Unexpected keyword 'open' in member definition$ type Foo() = - open type System.DateTime - - inherit Object() - - [] val mutable x: Int64 let x = 42 - let timeConstructed = Now.Ticks - do printfn "%d" Int32.MaxValue - static member Now () = DateTime.Now - member val TimeConstructed = timeConstructed with get, set - - member _.M() = - open type System.ArgumentException - Int32.MaxValue - - interface IDisposable with - member this.Dispose (): unit = - raise (NotImplementedException()) - open global.System - -type A = A of int - with - member _.RandomNumber with get() = Random().Next() - open System - -type ARecord = { A : int } - with - member _.RandomNumber with get() = Random().Next() - open System - -exception AException of int - with - member _.RandomNumber with get() = Random().Next() - open System - -type B = A of Int32 - with - open System - -exception BException of Int32 - with - open System - -type BRecord = { A : Int32 } - with - open System - -[] -type ABC = - val a: Int32 - val b: Int32 - new (a) = - open type System.Int32 - { a = a; b = MinValue } - open System - -type System.Int32 with - member this.Abs111 = Abs(this) - open type System.Math - -type A123 = - | A + open System - member _.F _ = 3 -and B123 = - | B - member _.F _ = Console.WriteLine() \ No newline at end of file + let timeConstructed = DateTime.Now.Ticks diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeInterface.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeInterface.fs deleted file mode 100644 index d55cd3c3eab..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/E_openInTypeInterface.fs +++ /dev/null @@ -1,5 +0,0 @@ -type AAA = - interface System.IDisposable with - open System - member this.Dispose (): unit = - raise (NotImplementedException()) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs index 29d8907519d..c9978fc7d3e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/ImportDeclarations.fs @@ -53,56 +53,15 @@ module ImportDeclarations = (Error 39, Line 34, Col 9, Line 34, Col 10, "The value or constructor 'C' is not defined.") ] - // SOURCE=E_openInTypeInterface.fs SCFLAGS="--test:ErrorRanges" # E_openInTypeInterface.fs - [] - let ``E_openInTypeInterface_fs`` compilation = - compilation - |> withLangVersionPreview - |> typecheck - |> shouldFail - |> withDiagnostics [ - (Error 0010, Line 3, Col 5, Line 3, Col 9, "Unexpected keyword 'open' in member definition. Expected 'member', 'override', 'static' or other token.") - (Error 3567, Line 3, Col 17, Line 4, Col 5, "Expecting member body") - ] - // SOURCE=E_openInTypeDecl.fs SCFLAGS="--test:ErrorRanges" # E_openInTypeDecl.fs - [] + [] let ``E_openInTypeDecl_fs`` compilation = compilation - |> withOptions ["--nowarn:52"] // The value has been copied to ensure the original is not mutated by this operation or because the copy is implicit when returning a struct from a member and another member is then accessed - |> withLangVersionPreview - |> typecheck + |> verifyCompile |> shouldFail |> withDiagnostics [ - (Error 3879, Line 23, Col 5, Line 23, Col 23, "'open' declarations must come before all other definitions in type definitions or augmentation") - (Error 0039, Line 20, Col 15, Line 20, Col 26, "The type 'IDisposable' is not defined.") - (Error 0039, Line 7, Col 13, Line 7, Col 19, "The type 'Object' is not defined. Maybe you want one of the following:\n obj") - (Error 0887, Line 20, Col 15, Line 20, Col 26, "The type 'obj' is not an interface type") - (Error 0039, Line 9, Col 37, Line 9, Col 42, "The type 'Int64' is not defined. Maybe you want one of the following:\n int64\n uint64\n int8\n int\n int16") - (Error 0855, Line 21, Col 21, Line 21, Col 28, "No abstract or interface member was found that corresponds to this override") - (Error 0039, Line 12, Col 21, Line 12, Col 26, "The value, namespace, type or module 'Int32' is not defined. Maybe you want one of the following:\n int32\n uint32\n int8\n int\n int16") - (Error 3879, Line 28, Col 9, Line 28, Col 20, "'open' declarations must come before all other definitions in type definitions or augmentation") - (Error 3879, Line 33, Col 9, Line 33, Col 20, "'open' declarations must come before all other definitions in type definitions or augmentation") - (Error 3879, Line 38, Col 9, Line 38, Col 20, "'open' declarations must come before all other definitions in type definitions or augmentation") - (Error 0039, Line 37, Col 44, Line 37, Col 50, "The value or constructor 'Random' is not defined.") - (Error 0039, Line 40, Col 15, Line 40, Col 20, "The type 'Int32' is not defined. Maybe you want one of the following:\n int32\n uint32\n int8\n int\n int16") - (Warning 1178, Line 40, Col 6, Line 40, Col 7, "The struct, record or union type 'B' is not structurally comparable because the type 'obj' does not satisfy the 'comparison' constraint. Consider adding the 'NoComparison' attribute to the type 'B' to clarify that the type is not comparable") - (Error 0039, Line 44, Col 25, Line 44, Col 30, "The type 'Int32' is not defined. Maybe you want one of the following:\n int32\n uint32\n int8\n int\n int16") - (Error 0039, Line 48, Col 22, Line 48, Col 27, "The type 'Int32' is not defined. Maybe you want one of the following:\n int32\n uint32\n int8\n int\n int16") - (Warning 1178, Line 48, Col 6, Line 48, Col 13, "The struct, record or union type 'BRecord' is not structurally comparable because the type 'obj' does not satisfy the 'comparison' constraint. Consider adding the 'NoComparison' attribute to the type 'BRecord' to clarify that the type is not comparable") - (Error 3879, Line 59, Col 5, Line 59, Col 16, "'open' declarations must come before all other definitions in type definitions or augmentation") - (Error 3879, Line 63, Col 5, Line 63, Col 26, "'open' declarations must come before all other definitions in type definitions or augmentation") - (Error 0039, Line 71, Col 20, Line 71, Col 27, "The value, namespace, type or module 'Console' is not defined. Maybe you want one of the following:\n Control\n cosh") + (Error 10, Line 7, Col 5, Line 7, Col 9, "Unexpected keyword 'open' in member definition") ] - - // SOURCE=openInTypeDecl.fs # openInTypeDecl.fs - [] - let ``openInTypeDecl_fs`` compilation = - compilation - |> withOptions ["--nowarn:52"] // The value has been copied to ensure the original is not mutated by this operation or because the copy is implicit when returning a struct from a member and another member is then accessed - |> withLangVersionPreview - |> typecheck - |> shouldSucceed // SOURCE=openModInFun.fs # openModInFun.fs [] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs deleted file mode 100644 index 2bb588eaaa1..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/ImportDeclarations/openInTypeDecl.fs +++ /dev/null @@ -1,58 +0,0 @@ -// #Regression #Conformance #DeclarationElements #Import -module openInTypeDecl - -type Foo() = - open global.System - open type DateTime - - inherit Object() - - [] val mutable x: Int64 - let x = 42 - let timeConstructed = Now.Ticks - do printfn "%d" Int32.MaxValue - static member Now () = DateTime.Now - member val TimeConstructed = timeConstructed with get, set - - member _.M() = - open type System.ArgumentException - Int32.MaxValue - - interface IDisposable with - member this.Dispose (): unit = - raise (NotImplementedException()) - -type A = A of int - with - open System - member _.RandomNumber with get() = Random().Next() - -type ARecord = { A : int } - with - open System - member _.RandomNumber with get() = Random().Next() - -exception AException of int - with - open System - member _.RandomNumber with get() = Random().Next() - -[] -type ABC = - open System - val a: Int32 - val b: Int32 - new (a) = - open type System.Int32 - { a = a; b = MinValue } - -type System.Int32 with - open type System.Math - member this.Abs111 = Abs(this) - -type IA = - open System - open type Int32 - open System.Collections.Generic - inherit IDisposable - inherit IEquatable diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs deleted file mode 100644 index 5754c954550..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs +++ /dev/null @@ -1,4 +0,0 @@ -type A() = - interface System.IDisposable with - open System - member _.F _ = 3 \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs.bsl deleted file mode 100644 index 9ca8369c442..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement.fs.bsl +++ /dev/null @@ -1,67 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InInterfaceImplement.fs", false, - QualifiedNameOfFile InInterfaceImplement, [], - [SynModuleOrNamespace - ([InInterfaceImplement], false, AnonModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [A], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (1,5--1,6)), - ObjectModel - (Unspecified, - [ImplicitCtor - (None, [], Const (Unit, (1,6--1,8)), None, - PreXmlDoc ((1,6), FSharp.Compiler.Xml.XmlDocCollector), - (1,5--1,6), { AsKeyword = None }); - Interface - (LongIdent - (SynLongIdent - ([System; IDisposable], [(2,20--2,21)], - [None; None])), Some (2,33--2,37), - Some - [Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = true - IsFinal = false - GetterOrSetterIsCompilerGenerated = - false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; - [SynArgInfo ([], false, None)]], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; F], [(4,16--4,17)], [None; None]), - None, None, Pats [Wild (4,19--4,20)], None, - (4,15--4,20)), None, - Const (Int32 3, (4,23--4,24)), (4,15--4,20), - NoneAtInvisible, - { LeadingKeyword = Member (4,8--4,14) - InlineKeyword = None - EqualsRange = Some (4,21--4,22) }), - (4,8--4,24))], (2,4--4,24))], (2,4--4,24)), [], - Some - (ImplicitCtor - (None, [], Const (Unit, (1,6--1,8)), None, - PreXmlDoc ((1,6), FSharp.Compiler.Xml.XmlDocCollector), - (1,5--1,6), { AsKeyword = None })), (1,5--4,24), - { LeadingKeyword = Type (1,0--1,4) - EqualsRange = Some (1,9--1,10) - WithKeyword = None })], (1,0--4,24))], PreXmlDocEmpty, [], - None, (1,0--4,24), { LeadingKeyword = None })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) - -(3,8)-(3,12) parse error Unexpected keyword 'open' in member definition. Expected 'member', 'override', 'static' or other token. -(3,20)-(4,8) parse error Expecting member body diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs deleted file mode 100644 index e2255c01fbe..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs +++ /dev/null @@ -1,4 +0,0 @@ -type A() = - interface System.IDisposable with - member _.F _ = 3 - open System \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs.bsl deleted file mode 100644 index d9580603e86..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InInterfaceImplement2.fs.bsl +++ /dev/null @@ -1,67 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InInterfaceImplement2.fs", false, - QualifiedNameOfFile InInterfaceImplement2, [], - [SynModuleOrNamespace - ([InInterfaceImplement2], false, AnonModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [A], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (1,5--1,6)), - ObjectModel - (Unspecified, - [ImplicitCtor - (None, [], Const (Unit, (1,6--1,8)), None, - PreXmlDoc ((1,6), FSharp.Compiler.Xml.XmlDocCollector), - (1,5--1,6), { AsKeyword = None }); - Interface - (LongIdent - (SynLongIdent - ([System; IDisposable], [(2,20--2,21)], - [None; None])), Some (2,33--2,37), - Some - [Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((3,8), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = true - IsFinal = false - GetterOrSetterIsCompilerGenerated = - false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; - [SynArgInfo ([], false, None)]], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; F], [(3,16--3,17)], [None; None]), - None, None, Pats [Wild (3,19--3,20)], None, - (3,15--3,20)), None, - Const (Int32 3, (3,23--3,24)), (3,15--3,20), - NoneAtInvisible, - { LeadingKeyword = Member (3,8--3,14) - InlineKeyword = None - EqualsRange = Some (3,21--3,22) }), - (3,8--3,24))], (2,4--3,24))], (2,4--3,24)), [], - Some - (ImplicitCtor - (None, [], Const (Unit, (1,6--1,8)), None, - PreXmlDoc ((1,6), FSharp.Compiler.Xml.XmlDocCollector), - (1,5--1,6), { AsKeyword = None })), (1,5--3,24), - { LeadingKeyword = Type (1,0--1,4) - EqualsRange = Some (1,9--1,10) - WithKeyword = None })], (1,0--3,24))], PreXmlDocEmpty, [], - None, (1,0--4,19), { LeadingKeyword = None })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) - -(4,8)-(4,12) parse error Unexpected keyword 'open' in object expression. Expected 'member', 'override', 'static' or other token. -(4,0)-(4,19) parse error Expecting member body diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs deleted file mode 100644 index 45bf16a072a..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs +++ /dev/null @@ -1,3 +0,0 @@ -type AUnion = - | A = 0 - open System diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs.bsl deleted file mode 100644 index c510d2ae685..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Enum.fs.bsl +++ /dev/null @@ -1,32 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Enum.fs", false, - QualifiedNameOfFile InType_Enum, [], - [SynModuleOrNamespace - ([InType_Enum], false, AnonModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [AUnion], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (1,5--1,11)), - Simple - (Enum - ([SynEnumCase - ([], SynIdent (A, None), - Const (Int32 0, (2,10--2,11)), - PreXmlDoc ((2,4), FSharp.Compiler.Xml.XmlDocCollector), - (2,6--2,11), { BarRange = Some (2,4--2,5) - EqualsRange = (2,8--2,9) })], - (2,4--2,11)), (2,4--2,11)), - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (3,9--3,15)), - (3,4--3,15))], None, (1,5--3,15), - { LeadingKeyword = Type (1,0--1,4) - EqualsRange = Some (1,12--1,13) - WithKeyword = None })], (1,0--3,15))], PreXmlDocEmpty, [], - None, (1,0--4,0), { LeadingKeyword = None })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs deleted file mode 100644 index d063e0ce02a..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs +++ /dev/null @@ -1,4 +0,0 @@ -exception AException of int - with - open System - member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs.bsl deleted file mode 100644 index a38f182f6f1..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Exception.fs.bsl +++ /dev/null @@ -1,72 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Exception.fs", false, - QualifiedNameOfFile InType_Exception, [], - [SynModuleOrNamespace - ([InType_Exception], false, AnonModule, - [Exception - (SynExceptionDefn - (SynExceptionDefnRepr - ([], - SynUnionCase - ([], SynIdent (AException, None), - Fields - [SynField - ([], false, None, - LongIdent (SynLongIdent ([int], [], [None])), false, - PreXmlDoc ((1,24), FSharp.Compiler.Xml.XmlDocCollector), - None, (1,24--1,27), { LeadingKeyword = None - MutableKeyword = None })], - PreXmlDocEmpty, None, (1,10--1,27), { BarRange = None }), - None, PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - None, (1,0--1,27)), Some (2,4--2,8), - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (3,13--3,19)), - (3,8--3,19)); - GetSetMember - (Some - (SynBinding - (None, Normal, false, false, [], - PreXmlMerge - (PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertyGet }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; RandomNumber], [(4,16--4,17)], [None; None]), - Some get, None, - Pats - [Paren - (Const (Unit, (4,38--4,40)), (4,38--4,40))], - None, (4,35--4,40)), None, - App - (Atomic, false, - DotGet - (App - (Atomic, false, Ident Random, - Const (Unit, (4,49--4,51)), (4,43--4,51)), - (4,51--4,52), SynLongIdent ([Next], [], [None]), - (4,43--4,56)), Const (Unit, (4,56--4,58)), - (4,43--4,58)), (4,35--4,40), NoneAtInvisible, - { LeadingKeyword = Member (4,8--4,14) - InlineKeyword = None - EqualsRange = Some (4,41--4,42) })), None, - (4,8--4,58), { InlineKeyword = None - WithKeyword = (4,30--4,34) - GetKeyword = Some (4,35--4,38) - AndKeyword = None - SetKeyword = None })], (1,0--4,58)), - (1,0--4,58))], PreXmlDocEmpty, [], None, (1,0--5,0), - { LeadingKeyword = None })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs deleted file mode 100644 index ed43c7ee697..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs +++ /dev/null @@ -1,3 +0,0 @@ -type System.Int32 with - open type System.Math - member this.Abs111 = Abs(this) \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs.bsl deleted file mode 100644 index 7005e434ccf..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension.fs.bsl +++ /dev/null @@ -1,53 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Extension.fs", false, - QualifiedNameOfFile InType_Extension, [], - [SynModuleOrNamespace - ([InType_Extension], false, AnonModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [System; Int32], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (1,5--1,17)), - ObjectModel (Augmentation (1,18--1,22), [], (1,5--3,34)), - [Open - (Type - (LongIdent - (SynLongIdent - ([System; Math], [(2,20--2,21)], [None; None])), - (2,14--2,25)), (2,4--2,25)); - Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([this; Abs111], [(3,15--3,16)], [None; None]), - None, None, Pats [], None, (3,11--3,22)), None, - App - (Atomic, false, Ident Abs, - Paren - (Ident this, (3,28--3,29), Some (3,33--3,34), - (3,28--3,34)), (3,25--3,34)), (3,11--3,22), - NoneAtInvisible, { LeadingKeyword = Member (3,4--3,10) - InlineKeyword = None - EqualsRange = Some (3,23--3,24) }), - (3,4--3,34))], None, (1,5--3,34), - { LeadingKeyword = Type (1,0--1,4) - EqualsRange = None - WithKeyword = None })], (1,0--3,34))], PreXmlDocEmpty, [], - None, (1,0--3,34), { LeadingKeyword = None })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs deleted file mode 100644 index 7910f8a7a92..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs +++ /dev/null @@ -1,3 +0,0 @@ -type System.Int32 with - member this.Abs111 = Abs(this) - open type System.Math \ No newline at end of file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs.bsl deleted file mode 100644 index 7e5c8ca55a6..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Extension2.fs.bsl +++ /dev/null @@ -1,53 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Extension2.fs", false, - QualifiedNameOfFile InType_Extension2, [], - [SynModuleOrNamespace - ([InType_Extension2], false, AnonModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [System; Int32], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (1,5--1,17)), - ObjectModel (Augmentation (1,18--1,22), [], (1,5--3,25)), - [Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((2,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([this; Abs111], [(2,15--2,16)], [None; None]), - None, None, Pats [], None, (2,11--2,22)), None, - App - (Atomic, false, Ident Abs, - Paren - (Ident this, (2,28--2,29), Some (2,33--2,34), - (2,28--2,34)), (2,25--2,34)), (2,11--2,22), - NoneAtInvisible, { LeadingKeyword = Member (2,4--2,10) - InlineKeyword = None - EqualsRange = Some (2,23--2,24) }), - (2,4--2,34)); - Open - (Type - (LongIdent - (SynLongIdent - ([System; Math], [(3,20--3,21)], [None; None])), - (3,14--3,25)), (3,4--3,25))], None, (1,5--3,25), - { LeadingKeyword = Type (1,0--1,4) - EqualsRange = None - WithKeyword = None })], (1,0--3,25))], PreXmlDocEmpty, [], - None, (1,0--3,25), { LeadingKeyword = None })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs deleted file mode 100644 index 2ad94f7f640..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs +++ /dev/null @@ -1,4 +0,0 @@ -type ARecord = { A : int } - with - open System - member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs.bsl deleted file mode 100644 index 9cdf5f9d5f2..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record.fs.bsl +++ /dev/null @@ -1,75 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Record.fs", false, - QualifiedNameOfFile InType_Record, [], - [SynModuleOrNamespace - ([InType_Record], false, AnonModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [ARecord], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (1,5--1,12)), - Simple - (Record - (None, - [SynField - ([], false, Some A, - LongIdent (SynLongIdent ([int], [], [None])), false, - PreXmlDoc ((1,17), FSharp.Compiler.Xml.XmlDocCollector), - None, (1,17--1,24), { LeadingKeyword = None - MutableKeyword = None })], - (1,15--1,26)), (1,15--1,26)), - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (3,13--3,19)), - (3,8--3,19)); - GetSetMember - (Some - (SynBinding - (None, Normal, false, false, [], - PreXmlMerge - (PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertyGet }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; RandomNumber], [(4,16--4,17)], - [None; None]), Some get, None, - Pats - [Paren - (Const (Unit, (4,38--4,40)), (4,38--4,40))], - None, (4,35--4,40)), None, - App - (Atomic, false, - DotGet - (App - (Atomic, false, Ident Random, - Const (Unit, (4,49--4,51)), (4,43--4,51)), - (4,51--4,52), - SynLongIdent ([Next], [], [None]), - (4,43--4,56)), Const (Unit, (4,56--4,58)), - (4,43--4,58)), (4,35--4,40), NoneAtInvisible, - { LeadingKeyword = Member (4,8--4,14) - InlineKeyword = None - EqualsRange = Some (4,41--4,42) })), None, - (4,8--4,58), { InlineKeyword = None - WithKeyword = (4,30--4,34) - GetKeyword = Some (4,35--4,38) - AndKeyword = None - SetKeyword = None })], None, (1,5--4,58), - { LeadingKeyword = Type (1,0--1,4) - EqualsRange = Some (1,13--1,14) - WithKeyword = Some (2,4--2,8) })], (1,0--4,58))], - PreXmlDocEmpty, [], None, (1,0--5,0), { LeadingKeyword = None })], - (true, true), { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs deleted file mode 100644 index f89920e1c9d..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs +++ /dev/null @@ -1,4 +0,0 @@ -type ARecord = { A : int } - with - member _.RandomNumber with get() = Random().Next() - open System diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs.bsl deleted file mode 100644 index 33cd5bbeba3..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record2.fs.bsl +++ /dev/null @@ -1,75 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Record2.fs", false, - QualifiedNameOfFile InType_Record2, [], - [SynModuleOrNamespace - ([InType_Record2], false, AnonModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [ARecord], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (1,5--1,12)), - Simple - (Record - (None, - [SynField - ([], false, Some A, - LongIdent (SynLongIdent ([int], [], [None])), false, - PreXmlDoc ((1,17), FSharp.Compiler.Xml.XmlDocCollector), - None, (1,17--1,24), { LeadingKeyword = None - MutableKeyword = None })], - (1,15--1,26)), (1,15--1,26)), - [GetSetMember - (Some - (SynBinding - (None, Normal, false, false, [], - PreXmlMerge - (PreXmlDoc ((3,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertyGet }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; RandomNumber], [(3,16--3,17)], - [None; None]), Some get, None, - Pats - [Paren - (Const (Unit, (3,38--3,40)), (3,38--3,40))], - None, (3,35--3,40)), None, - App - (Atomic, false, - DotGet - (App - (Atomic, false, Ident Random, - Const (Unit, (3,49--3,51)), (3,43--3,51)), - (3,51--3,52), - SynLongIdent ([Next], [], [None]), - (3,43--3,56)), Const (Unit, (3,56--3,58)), - (3,43--3,58)), (3,35--3,40), NoneAtInvisible, - { LeadingKeyword = Member (3,8--3,14) - InlineKeyword = None - EqualsRange = Some (3,41--3,42) })), None, - (3,8--3,58), { InlineKeyword = None - WithKeyword = (3,30--3,34) - GetKeyword = Some (3,35--3,38) - AndKeyword = None - SetKeyword = None }); - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (4,13--4,19)), - (4,8--4,19))], None, (1,5--4,19), - { LeadingKeyword = Type (1,0--1,4) - EqualsRange = Some (1,13--1,14) - WithKeyword = Some (2,4--2,8) })], (1,0--4,19))], - PreXmlDocEmpty, [], None, (1,0--5,0), { LeadingKeyword = None })], - (true, true), { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs deleted file mode 100644 index 4e7e43105da..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs +++ /dev/null @@ -1,5 +0,0 @@ -type ARecord = - open System - { A : int } - with - member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs.bsl deleted file mode 100644 index 0e1c114debe..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record3.fs.bsl +++ /dev/null @@ -1,71 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Record3.fs", false, - QualifiedNameOfFile InType_Record3, [], - [SynModuleOrNamespace - ([InType_Record3], false, AnonModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [ARecord], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (1,5--1,12)), - ObjectModel - (Unspecified, - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (2,9--2,15)), - (2,4--2,15)); - GetSetMember - (Some - (SynBinding - (None, Normal, false, false, [], - PreXmlMerge - (PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), - SynValData - (Some - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertyGet }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; RandomNumber], [(5,16--5,17)], - [None; None]), Some get, None, - Pats - [Paren - (Const (Unit, (5,38--5,40)), (5,38--5,40))], - None, (5,35--5,40)), None, - App - (Atomic, false, - DotGet - (App - (Atomic, false, Ident Random, - Const (Unit, (5,49--5,51)), (5,43--5,51)), - (5,51--5,52), - SynLongIdent ([Next], [], [None]), - (5,43--5,56)), Const (Unit, (5,56--5,58)), - (5,43--5,58)), (5,35--5,40), NoneAtInvisible, - { LeadingKeyword = Member (5,8--5,14) - InlineKeyword = None - EqualsRange = Some (5,41--5,42) })), None, - (3,4--5,58), { InlineKeyword = None - WithKeyword = (5,30--5,34) - GetKeyword = Some (5,35--5,38) - AndKeyword = None - SetKeyword = None })], (2,4--5,58)), [], - None, (1,5--5,58), { LeadingKeyword = Type (1,0--1,4) - EqualsRange = Some (1,13--1,14) - WithKeyword = None })], (1,0--5,58))], - PreXmlDocEmpty, [], None, (1,0--6,0), { LeadingKeyword = None })], - (true, true), { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) - -(3,4)-(3,5) parse error Unexpected symbol '{' in member definition -(6,0)-(6,0) parse error Incomplete structured construct at or before this point in implementation file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs deleted file mode 100644 index 38891eea6d0..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs +++ /dev/null @@ -1,5 +0,0 @@ -type ARecord = - { A : int } - open System - with - member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs.bsl deleted file mode 100644 index ca9813c9f0c..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Record4.fs.bsl +++ /dev/null @@ -1,12 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Record4.fs", false, - QualifiedNameOfFile InType_Record4, [], - [SynModuleOrNamespace - ([InType_Record4], false, AnonModule, [], PreXmlDocEmpty, [], None, - (1,0--6,0), { LeadingKeyword = None })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) - -(2,4)-(6,0) parse error At most one 'with' augmentation is permitted diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs deleted file mode 100644 index 68234379e4c..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs +++ /dev/null @@ -1,8 +0,0 @@ -[] -type ABC = - open System - val a: Int32 - val b: Int32 - new (a) = - open type System.Int32 - { a = a; b = MinValue } diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs.bsl deleted file mode 100644 index 3614609046c..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct.fs.bsl +++ /dev/null @@ -1,95 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Struct.fs", false, - QualifiedNameOfFile InType_Struct, [], - [SynModuleOrNamespace - ([InType_Struct], false, AnonModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([{ Attributes = - [{ TypeName = SynLongIdent ([Struct], [], [None]) - ArgExpr = Const (Unit, (1,2--1,8)) - Target = None - AppliesToGetterAndSetter = false - Range = (1,2--1,8) }] - Range = (1,0--1,10) }], None, [], [ABC], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (2,5--2,8)), - ObjectModel - (Unspecified, - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (3,9--3,15)), - (3,4--3,15)); - ValField - (SynField - ([], false, Some a, - LongIdent (SynLongIdent ([Int32], [], [None])), - false, - PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, (4,4--4,16), - { LeadingKeyword = Some (Val (4,4--4,7)) - MutableKeyword = None }), (4,4--4,16)); - ValField - (SynField - ([], false, Some b, - LongIdent (SynLongIdent ([Int32], [], [None])), - false, - PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), - None, (5,4--5,16), - { LeadingKeyword = Some (Val (5,4--5,7)) - MutableKeyword = None }), (5,4--5,16)); - Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((6,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = false - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Constructor }, - SynValInfo - ([[SynArgInfo ([], false, Some a)]], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent ([new], [], [None]), None, - Some (SynValTyparDecls (None, false)), - Pats - [Paren - (Named - (SynIdent (a, None), false, None, - (6,9--6,10)), (6,8--6,11))], None, - (6,4--6,7)), None, - Open - (Type - (LongIdent - (SynLongIdent - ([System; Int32], [(7,24--7,25)], - [None; None])), (7,18--7,30)), - (7,8--7,30), (7,8--8,31), - Record - (None, None, - [SynExprRecordField - ((SynLongIdent ([a], [], [None]), true), - Some (8,12--8,13), Some (Ident a), - (8,10--8,15), - Some ((8,15--8,16), Some (8,16))); - SynExprRecordField - ((SynLongIdent ([b], [], [None]), true), - Some (8,19--8,20), Some (Ident MinValue), - (8,17--8,29), None)], (8,8--8,31))), - (6,4--6,11), NoneAtInvisible, - { LeadingKeyword = New (6,4--6,7) - InlineKeyword = None - EqualsRange = Some (6,12--6,13) }), (6,4--8,31))], - (3,4--8,31)), [], None, (1,0--8,31), - { LeadingKeyword = Type (2,0--2,4) - EqualsRange = Some (2,9--2,10) - WithKeyword = None })], (1,0--8,31))], PreXmlDocEmpty, [], - None, (1,0--9,0), { LeadingKeyword = None })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs deleted file mode 100644 index 1804dfe0a1e..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs +++ /dev/null @@ -1,8 +0,0 @@ -[] -type ABC = - val a: Int32 - open System - val b: Int32 - new (a) = - open type System.Int32 - { a = a; b = MinValue } diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs.bsl deleted file mode 100644 index fe5fbd4464f..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Struct2.fs.bsl +++ /dev/null @@ -1,95 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Struct2.fs", false, - QualifiedNameOfFile InType_Struct2, [], - [SynModuleOrNamespace - ([InType_Struct2], false, AnonModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([{ Attributes = - [{ TypeName = SynLongIdent ([Struct], [], [None]) - ArgExpr = Const (Unit, (1,2--1,8)) - Target = None - AppliesToGetterAndSetter = false - Range = (1,2--1,8) }] - Range = (1,0--1,10) }], None, [], [ABC], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (2,5--2,8)), - ObjectModel - (Unspecified, - [ValField - (SynField - ([], false, Some a, - LongIdent (SynLongIdent ([Int32], [], [None])), - false, - PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - None, (3,4--3,16), - { LeadingKeyword = Some (Val (3,4--3,7)) - MutableKeyword = None }), (3,4--3,16)); - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (4,9--4,15)), - (4,4--4,15)); - ValField - (SynField - ([], false, Some b, - LongIdent (SynLongIdent ([Int32], [], [None])), - false, - PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), - None, (5,4--5,16), - { LeadingKeyword = Some (Val (5,4--5,7)) - MutableKeyword = None }), (5,4--5,16)); - Member - (SynBinding - (None, Normal, false, false, [], - PreXmlDoc ((6,4), FSharp.Compiler.Xml.XmlDocCollector), - SynValData - (Some { IsInstance = false - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Constructor }, - SynValInfo - ([[SynArgInfo ([], false, Some a)]], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent ([new], [], [None]), None, - Some (SynValTyparDecls (None, false)), - Pats - [Paren - (Named - (SynIdent (a, None), false, None, - (6,9--6,10)), (6,8--6,11))], None, - (6,4--6,7)), None, - Open - (Type - (LongIdent - (SynLongIdent - ([System; Int32], [(7,24--7,25)], - [None; None])), (7,18--7,30)), - (7,8--7,30), (7,8--8,31), - Record - (None, None, - [SynExprRecordField - ((SynLongIdent ([a], [], [None]), true), - Some (8,12--8,13), Some (Ident a), - (8,10--8,15), - Some ((8,15--8,16), Some (8,16))); - SynExprRecordField - ((SynLongIdent ([b], [], [None]), true), - Some (8,19--8,20), Some (Ident MinValue), - (8,17--8,29), None)], (8,8--8,31))), - (6,4--6,11), NoneAtInvisible, - { LeadingKeyword = New (6,4--6,7) - InlineKeyword = None - EqualsRange = Some (6,12--6,13) }), (6,4--8,31))], - (3,4--8,31)), [], None, (1,0--8,31), - { LeadingKeyword = Type (2,0--2,4) - EqualsRange = Some (2,9--2,10) - WithKeyword = None })], (1,0--8,31))], PreXmlDocEmpty, [], - None, (1,0--9,0), { LeadingKeyword = None })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs deleted file mode 100644 index 35efa4aef11..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs +++ /dev/null @@ -1,4 +0,0 @@ -type AUnion = | A of int - with - open System - member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs.bsl deleted file mode 100644 index c1f4159d3a4..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union.fs.bsl +++ /dev/null @@ -1,81 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Union.fs", false, - QualifiedNameOfFile InType_Union, [], - [SynModuleOrNamespace - ([InType_Union], false, AnonModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [AUnion], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (1,5--1,11)), - Simple - (Union - (None, - [SynUnionCase - ([], SynIdent (A, None), - Fields - [SynField - ([], false, None, - LongIdent (SynLongIdent ([int], [], [None])), - false, - PreXmlDoc ((1,21), FSharp.Compiler.Xml.XmlDocCollector), - None, (1,21--1,24), { LeadingKeyword = None - MutableKeyword = None })], - PreXmlDoc ((1,14), FSharp.Compiler.Xml.XmlDocCollector), - None, (1,16--1,24), { BarRange = Some (1,14--1,15) })], - (1,14--1,24)), (1,14--1,24)), - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (3,13--3,19)), - (3,8--3,19)); - GetSetMember - (Some - (SynBinding - (None, Normal, false, false, [], - PreXmlMerge - (PreXmlDoc ((4,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertyGet }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; RandomNumber], [(4,16--4,17)], - [None; None]), Some get, None, - Pats - [Paren - (Const (Unit, (4,38--4,40)), (4,38--4,40))], - None, (4,35--4,40)), None, - App - (Atomic, false, - DotGet - (App - (Atomic, false, Ident Random, - Const (Unit, (4,49--4,51)), (4,43--4,51)), - (4,51--4,52), - SynLongIdent ([Next], [], [None]), - (4,43--4,56)), Const (Unit, (4,56--4,58)), - (4,43--4,58)), (4,35--4,40), NoneAtInvisible, - { LeadingKeyword = Member (4,8--4,14) - InlineKeyword = None - EqualsRange = Some (4,41--4,42) })), None, - (4,8--4,58), { InlineKeyword = None - WithKeyword = (4,30--4,34) - GetKeyword = Some (4,35--4,38) - AndKeyword = None - SetKeyword = None })], None, (1,5--4,58), - { LeadingKeyword = Type (1,0--1,4) - EqualsRange = Some (1,12--1,13) - WithKeyword = Some (2,4--2,8) })], (1,0--4,58))], - PreXmlDocEmpty, [], None, (1,0--5,0), { LeadingKeyword = None })], - (true, true), { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs deleted file mode 100644 index 3c680806a8c..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs +++ /dev/null @@ -1,4 +0,0 @@ -type AUnion = | A of int - with - member _.RandomNumber with get() = Random().Next() - open System diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs.bsl deleted file mode 100644 index bc3f736e39a..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union2.fs.bsl +++ /dev/null @@ -1,81 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Union2.fs", false, - QualifiedNameOfFile InType_Union2, [], - [SynModuleOrNamespace - ([InType_Union2], false, AnonModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [AUnion], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (1,5--1,11)), - Simple - (Union - (None, - [SynUnionCase - ([], SynIdent (A, None), - Fields - [SynField - ([], false, None, - LongIdent (SynLongIdent ([int], [], [None])), - false, - PreXmlDoc ((1,21), FSharp.Compiler.Xml.XmlDocCollector), - None, (1,21--1,24), { LeadingKeyword = None - MutableKeyword = None })], - PreXmlDoc ((1,14), FSharp.Compiler.Xml.XmlDocCollector), - None, (1,16--1,24), { BarRange = Some (1,14--1,15) })], - (1,14--1,24)), (1,14--1,24)), - [GetSetMember - (Some - (SynBinding - (None, Normal, false, false, [], - PreXmlMerge - (PreXmlDoc ((3,8), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), - SynValData - (Some { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertyGet }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; RandomNumber], [(3,16--3,17)], - [None; None]), Some get, None, - Pats - [Paren - (Const (Unit, (3,38--3,40)), (3,38--3,40))], - None, (3,35--3,40)), None, - App - (Atomic, false, - DotGet - (App - (Atomic, false, Ident Random, - Const (Unit, (3,49--3,51)), (3,43--3,51)), - (3,51--3,52), - SynLongIdent ([Next], [], [None]), - (3,43--3,56)), Const (Unit, (3,56--3,58)), - (3,43--3,58)), (3,35--3,40), NoneAtInvisible, - { LeadingKeyword = Member (3,8--3,14) - InlineKeyword = None - EqualsRange = Some (3,41--3,42) })), None, - (3,8--3,58), { InlineKeyword = None - WithKeyword = (3,30--3,34) - GetKeyword = Some (3,35--3,38) - AndKeyword = None - SetKeyword = None }); - Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (4,13--4,19)), - (4,8--4,19))], None, (1,5--4,19), - { LeadingKeyword = Type (1,0--1,4) - EqualsRange = Some (1,12--1,13) - WithKeyword = Some (2,4--2,8) })], (1,0--4,19))], - PreXmlDocEmpty, [], None, (1,0--5,0), { LeadingKeyword = None })], - (true, true), { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs deleted file mode 100644 index 5c2a1384903..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs +++ /dev/null @@ -1,5 +0,0 @@ -type AUnion = - open System - | A of int - with - member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs.bsl deleted file mode 100644 index cdf7dc5f21c..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union3.fs.bsl +++ /dev/null @@ -1,71 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Union3.fs", false, - QualifiedNameOfFile InType_Union3, [], - [SynModuleOrNamespace - ([InType_Union3], false, AnonModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [AUnion], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (1,5--1,11)), - ObjectModel - (Unspecified, - [Open - (ModuleOrNamespace - (SynLongIdent ([System], [], [None]), (2,9--2,15)), - (2,4--2,15)); - GetSetMember - (Some - (SynBinding - (None, Normal, false, false, [], - PreXmlMerge - (PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), PreXmlDocEmpty), - SynValData - (Some - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertyGet }, - SynValInfo - ([[SynArgInfo ([], false, None)]; []], - SynArgInfo ([], false, None)), None), - LongIdent - (SynLongIdent - ([_; RandomNumber], [(5,16--5,17)], - [None; None]), Some get, None, - Pats - [Paren - (Const (Unit, (5,38--5,40)), (5,38--5,40))], - None, (5,35--5,40)), None, - App - (Atomic, false, - DotGet - (App - (Atomic, false, Ident Random, - Const (Unit, (5,49--5,51)), (5,43--5,51)), - (5,51--5,52), - SynLongIdent ([Next], [], [None]), - (5,43--5,56)), Const (Unit, (5,56--5,58)), - (5,43--5,58)), (5,35--5,40), NoneAtInvisible, - { LeadingKeyword = Member (5,8--5,14) - InlineKeyword = None - EqualsRange = Some (5,41--5,42) })), None, - (3,4--5,58), { InlineKeyword = None - WithKeyword = (5,30--5,34) - GetKeyword = Some (5,35--5,38) - AndKeyword = None - SetKeyword = None })], (2,4--5,58)), [], - None, (1,5--5,58), { LeadingKeyword = Type (1,0--1,4) - EqualsRange = Some (1,12--1,13) - WithKeyword = None })], (1,0--5,58))], - PreXmlDocEmpty, [], None, (1,0--6,0), { LeadingKeyword = None })], - (true, true), { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) - -(3,4)-(3,5) parse error Unexpected symbol '|' in member definition -(6,0)-(6,0) parse error Incomplete structured construct at or before this point in implementation file diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs deleted file mode 100644 index b9f6f1851ba..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs +++ /dev/null @@ -1,5 +0,0 @@ -type AUnion = - | A of int - open System - with - member _.RandomNumber with get() = Random().Next() diff --git a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs.bsl b/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs.bsl deleted file mode 100644 index f2ad930f91b..00000000000 --- a/tests/service/data/SyntaxTree/OpenDeclaration/InType_Union4.fs.bsl +++ /dev/null @@ -1,12 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/OpenDeclaration/InType_Union4.fs", false, - QualifiedNameOfFile InType_Union4, [], - [SynModuleOrNamespace - ([InType_Union4], false, AnonModule, [], PreXmlDocEmpty, [], None, - (1,0--6,0), { LeadingKeyword = None })], (true, true), - { ConditionalDirectives = [] - WarnDirectives = [] - CodeComments = [] }, set [])) - -(2,4)-(6,0) parse error At most one 'with' augmentation is permitted From 643ca34da6c6b27b50bd8db551e7ab9198f0cfd1 Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Tue, 12 Aug 2025 19:41:21 +0800 Subject: [PATCH 21/22] clean open in type --- .../tests/UnitTests/UnusedOpensTests.fs | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/vsintegration/tests/UnitTests/UnusedOpensTests.fs b/vsintegration/tests/UnitTests/UnusedOpensTests.fs index eacb36f620b..7e93c6f417c 100644 --- a/vsintegration/tests/UnitTests/UnusedOpensTests.fs +++ b/vsintegration/tests/UnitTests/UnusedOpensTests.fs @@ -861,28 +861,6 @@ let f() = """ => [3, (14, 28)] -[] -let ``unused open C# type in type scoped``() = - """ -type T() = - open type System.Console - do printfn "%s" "Hello World" - """ - => [3, (14, 28); 3, (14, 28)] - - -[] -let ``type-scoped open declaration duplication in module is unused``() = - """ -module TopModule -open System.IO -type T() = - open System.IO - do File.Create "" -""" - => [ 5, (9, 18); 5, (9, 18) ] - - [] let ``expression-scoped open declaration duplication in module is unused``() = """ @@ -893,17 +871,3 @@ let _ = File.Create "" """ => [ 5, (9, 18) ] - - -[] -let ``type- and expression-scoped open declaration duplication in module is unused``() = - """ -module TopModule -open System.IO -type T() = - open System.IO - do - open System.IO - File.Create "" -""" - => [ 5, (9, 18); 5, (9, 18); 7, (13, 22) ] From e9b3b1d3a680fc0467adb7c9e6848058b02a529a Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Sat, 10 Jan 2026 00:33:19 +0800 Subject: [PATCH 22/22] fix build --- src/Compiler/Checking/CheckBasics.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Checking/CheckBasics.fs b/src/Compiler/Checking/CheckBasics.fs index 04729e2c000..b242f264271 100644 --- a/src/Compiler/Checking/CheckBasics.fs +++ b/src/Compiler/Checking/CheckBasics.fs @@ -455,7 +455,7 @@ let TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) = if IsPartiallyQualifiedNamespace modref then errorR(Error(FSComp.SR.tcOpenUsedWithPartiallyQualifiedPath(fullDisplayTextOfModRef modref), m))) - let modrefs = List.map p23 modrefs + let modrefs = List.map (fun (_, modref, _) -> modref) modrefs modrefs |> List.iter (fun modref -> CheckEntityAttributes g modref m |> CommitOperationResult) let openDecl = OpenDeclaration.Create (SynOpenDeclTarget.ModuleOrNamespace (SynLongIdent(longId, [], []), m), modrefs, [], scopem, false)