Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .executor-pid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22280
1 change: 1 addition & 0 deletions src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1818,4 +1818,5 @@ featurePreprocessorElif,"#elif preprocessor directive"
3885,parsLetBangCannotBeLastInCE,"'%s' cannot be the final expression in a computation expression. Finish with 'return', 'return!', or a simple expression."
3886,tcListLiteralWithSingleTupleElement,"This list expression contains a single tuple element. Did you mean to use ';' instead of ',' to separate list elements?"
3887,ilCustomAttrInvalidArrayElemType,"The type '%s' is not a valid custom attribute argument type. Custom attribute arrays must have elements of primitive types, enums, string, System.Type, or System.Object."
3888,tastNamespaceAndTypeWithSameNameInAssembly,"The namespace '%s' clashes with the type '%s'."
featureExceptionFieldSerializationSupport,"emit GetObjectData and field-restoring deserialization constructor for exception types"
54 changes: 46 additions & 8 deletions src/Compiler/Service/ServiceParsedInputOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2602,17 +2602,55 @@ module ParsedInput =

mkPos line ctx.Pos.Column

let private tryFindLastHashRLineInScript (parsedInput: ParsedInput) =
if
not (
parsedInput.FileName.EndsWith(".fsx", System.StringComparison.OrdinalIgnoreCase)
|| parsedInput.FileName.EndsWith(".fsscript", System.StringComparison.OrdinalIgnoreCase)
)
then
None
else
match parsedInput with
| ParsedInput.SigFile _ -> None
| ParsedInput.ImplFile(ParsedImplFileInput(hashDirectives = fileHashes; contents = contents)) ->
let mutable lastLine = 0

let consider (ParsedHashDirective(ident, _, r)) =
if ident = "r" && r.EndLine > lastLine then
lastLine <- r.EndLine

fileHashes |> List.iter consider

let rec walkDecl (decl: SynModuleDecl) =
match decl with
| SynModuleDecl.HashDirective(hashDirective = hd) -> consider hd
| SynModuleDecl.NestedModule(decls = decls) -> List.iter walkDecl decls
| SynModuleDecl.NamespaceFragment(SynModuleOrNamespace(decls = decls)) -> List.iter walkDecl decls
| _ -> ()

for SynModuleOrNamespace(decls = decls) in contents do
List.iter walkDecl decls

if lastLine > 0 then Some lastLine else None

let FindNearestPointToInsertOpenDeclaration
(currentLine: int)
(parsedInput: ParsedInput)
(entity: ShortIdents)
(insertionPoint: OpenStatementInsertionPoint)
=
match tryFindNearestPointAndModules currentLine parsedInput insertionPoint with
| Some(scope, _, point), modules -> findBestPositionToInsertOpenDeclaration modules scope point entity
| _ ->
// we failed to find insertion point because ast is empty for some reason, return top left point in this case
{
ScopeKind = ScopeKind.TopModule
Pos = mkPos 1 0
}
let ctx =
match tryFindNearestPointAndModules currentLine parsedInput insertionPoint with
| Some(scope, _, point), modules -> findBestPositionToInsertOpenDeclaration modules scope point entity
| _ ->
// we failed to find insertion point because ast is empty for some reason, return top left point in this case
{
ScopeKind = ScopeKind.TopModule
Pos = mkPos 1 0
}

// For .fsx scripts, ensure the open is placed after any #r directives.
match tryFindLastHashRLineInScript parsedInput with
| Some lastRLine when ctx.Pos.Line <= lastRLine -> { ctx with Pos = mkPos (lastRLine + 1) 0 }
| _ -> ctx
5 changes: 4 additions & 1 deletion src/Compiler/TypedTree/TypedTreeOps.Remapping.fs
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,11 @@ module internal SignatureOps =

match entity1.IsNamespace, entity2.IsNamespace, entity1.IsModule, entity2.IsModule with
| true, true, _, _ -> ()
| true, _, _, true
| _, true, true, _ -> errorR (Error(FSComp.SR.tastNamespaceAndModuleWithSameNameInAssembly (textOfPath path2), entity2.Range))
| true, _, _, _
| _, true, _, _ -> errorR (Error(FSComp.SR.tastNamespaceAndModuleWithSameNameInAssembly (textOfPath path2), entity2.Range))
| _, true, _, _ ->
errorR (Error(FSComp.SR.tastNamespaceAndTypeWithSameNameInAssembly (textOfPath path2, entity2.LogicalName), entity2.Range))
| false, false, false, false ->
errorR (Error(FSComp.SR.tastDuplicateTypeDefinitionInAssembly (entity2.LogicalName, textOfPath path), entity2.Range))
| false, false, true, true -> errorR (Error(FSComp.SR.tastTwoModulesWithSameNameInAssembly (textOfPath path2), entity2.Range))
Expand Down
35 changes: 20 additions & 15 deletions src/Compiler/xlf/FSComp.txt.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 20 additions & 15 deletions src/Compiler/xlf/FSComp.txt.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 20 additions & 15 deletions src/Compiler/xlf/FSComp.txt.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 20 additions & 15 deletions src/Compiler/xlf/FSComp.txt.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading