Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"fantomas": {
"version": "5.0.0-beta-005",
"version": "5.0.3",
"commands": [
"fantomas"
]
Expand Down
81 changes: 73 additions & 8 deletions .fantomasignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,79 @@ artifacts/

# Explicitly unformatted implementation files

src/Compiler/Checking/**/*.fs
src/Compiler/DependencyManager/**/*.fs
src/Compiler/Facilities/**/*.fs
src/Compiler/Interactive/**/*.fs
src/Compiler/Legacy/**/*.fs
src/Compiler/Optimize/**/*.fs
src/Compiler/Symbols/**/*.fs
src/Compiler/TypedTree/**/*.fs
src/Compiler/Checking/AccessibilityLogic.fs
src/Compiler/Checking/AttributeChecking.fs
src/Compiler/Checking/AugmentWithHashCompare.fs
src/Compiler/Checking/CheckBasics.fs
src/Compiler/Checking/CheckComputationExpressions.fs
src/Compiler/Checking/CheckDeclarations.fs
src/Compiler/Checking/CheckExpressions.fs
src/Compiler/Checking/CheckFormatStrings.fs
src/Compiler/Checking/CheckIncrementalClasses.fs
src/Compiler/Checking/CheckPatterns.fs
src/Compiler/Checking/ConstraintSolver.fs
src/Compiler/Checking/FindUnsolved.fs
src/Compiler/Checking/import.fs
src/Compiler/Checking/InfoReader.fs
src/Compiler/Checking/infos.fs
src/Compiler/Checking/MethodCalls.fs
src/Compiler/Checking/MethodOverrides.fs
src/Compiler/Checking/NameResolution.fs
src/Compiler/Checking/NicePrint.fs
src/Compiler/Checking/PatternMatchCompilation.fs
src/Compiler/Checking/PostInferenceChecks.fs
src/Compiler/Checking/QuotationTranslator.fs
src/Compiler/Checking/SignatureConformance.fs
src/Compiler/Checking/TypeHierarchy.fs
src/Compiler/Checking/TypeRelations.fs

src/Compiler/DependencyManager/AssemblyResolveHandler.fs
src/Compiler/DependencyManager/DependencyProvider.fs
src/Compiler/DependencyManager/NativeDllResolveHandler.fs

src/Compiler/Facilities/BuildGraph.fs
src/Compiler/Facilities/CompilerLocation.fs
src/Compiler/Facilities/DiagnosticOptions.fs
src/Compiler/Facilities/DiagnosticResolutionHints.fs
src/Compiler/Facilities/DiagnosticsLogger.fs
src/Compiler/Facilities/LanguageFeatures.fs
src/Compiler/Facilities/Logger.fs
src/Compiler/Facilities/prim-lexing.fs
src/Compiler/Facilities/prim-parsing.fs
src/Compiler/Facilities/ReferenceResolver.fs
src/Compiler/Facilities/SimulatedMSBuildReferenceResolver.fs
src/Compiler/Facilities/TextLayoutRender.fs

src/Compiler/Interactive/ControlledExecution.fs
src/Compiler/Interactive/fsi.fs

src/Compiler/Legacy/LegacyHostedCompilerForTesting.fs
src/Compiler/Legacy/LegacyMSBuildReferenceResolver.fs

src/Compiler/Optimize/DetupleArgs.fs
src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs
src/Compiler/Optimize/LowerCalls.fs
src/Compiler/Optimize/LowerComputedCollections.fs
src/Compiler/Optimize/LowerLocalMutables.fs
src/Compiler/Optimize/LowerSequences.fs
src/Compiler/Optimize/LowerStateMachines.fs
src/Compiler/Optimize/Optimizer.fs

src/Compiler/Symbols/Exprs.fs
src/Compiler/Symbols/FSharpDiagnostic.fs
src/Compiler/Symbols/SymbolHelpers.fs
src/Compiler/Symbols/SymbolPatterns.fs
src/Compiler/Symbols/Symbols.fs

src/Compiler/TypedTree/CompilerGlobalState.fs
src/Compiler/TypedTree/QuotationPickler.fs
src/Compiler/TypedTree/tainted.fs
src/Compiler/TypedTree/TcGlobals.fs
src/Compiler/TypedTree/TypedTree.fs
src/Compiler/TypedTree/TypedTreeBasics.fs
src/Compiler/TypedTree/TypedTreeOps.fs
src/Compiler/TypedTree/TypedTreePickle.fs
src/Compiler/TypedTree/TypeProviders.fs

# Explicitly unformatted file that needs more care to get it to format well

Expand Down
30 changes: 7 additions & 23 deletions src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2840,9 +2840,7 @@ let ComputeDebugPointForBinding g bind =
| DebugPointAtBinding.NoneAtDo, _ -> false, None
| DebugPointAtBinding.NoneAtLet, _ -> false, None
// Don't emit debug points for lambdas.
| _,
(Expr.Lambda _
| Expr.TyLambda _) -> false, None
| _, (Expr.Lambda _ | Expr.TyLambda _) -> false, None
| DebugPointAtBinding.Yes m, _ -> false, Some m

//-------------------------------------------------------------------------
Expand Down Expand Up @@ -5134,21 +5132,10 @@ and GenAsmCode cenv cgbuf eenv (il, tyargs, args, returnTys, m) sequel =
// For these we can just generate the argument and change the test (from a brfalse to a brtrue and vice versa)
| ([ AI_ceq ],
[ arg1
Expr.Const ((Const.Bool false
| Const.SByte 0y
| Const.Int16 0s
| Const.Int32 0
| Const.Int64 0L
| Const.Byte 0uy
| Const.UInt16 0us
| Const.UInt32 0u
| Const.UInt64 0UL),
Expr.Const ((Const.Bool false | Const.SByte 0y | Const.Int16 0s | Const.Int32 0 | Const.Int64 0L | Const.Byte 0uy | Const.UInt16 0us | Const.UInt32 0u | Const.UInt64 0UL),
_,
_) ],
CmpThenBrOrContinue (1,
[ I_brcmp ((BI_brfalse
| BI_brtrue) as bi,
label1) ]),
CmpThenBrOrContinue (1, [ I_brcmp ((BI_brfalse | BI_brtrue) as bi, label1) ]),
_) ->

let bi =
Expand Down Expand Up @@ -7903,9 +7890,7 @@ and GenDecisionTreeTest
// If so, emit the failure logic, then came back and do the success target, then
// do any postponed failure target.
match successTree, failureTree with
| TDSuccess _,
(TDBind _
| TDSwitch _) ->
| TDSuccess _, (TDBind _ | TDSwitch _) ->

// OK, there is more logic in the decision tree on the failure branch
let success = CG.GenerateDelayMark cgbuf "testSuccess"
Expand Down Expand Up @@ -10641,10 +10626,9 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) =
| None -> None
| Some memberInfo ->
match name, memberInfo.MemberFlags.MemberKind with
| ("Item"
| "op_IndexedLookup"),
(SynMemberKind.PropertyGet
| SynMemberKind.PropertySet) when not (isNil (ArgInfosOfPropertyVal g vref.Deref)) ->
| ("Item" | "op_IndexedLookup"), (SynMemberKind.PropertyGet | SynMemberKind.PropertySet) when
not (isNil (ArgInfosOfPropertyVal g vref.Deref))
->
Some(
mkILCustomAttribute (
g.FindSysILTypeRef "System.Reflection.DefaultMemberAttribute",
Expand Down
5 changes: 1 addition & 4 deletions src/Compiler/Driver/ParseAndCheckInputs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -844,10 +844,7 @@ let ProcessMetaCommandsFromInput
| ParsedHashDirective ("nowarn", ParsedHashDirectiveArguments numbers, m) ->
List.fold (fun state d -> nowarnF state (m, d)) state numbers

| ParsedHashDirective (("reference"
| "r"),
ParsedHashDirectiveArguments args,
m) ->
| ParsedHashDirective (("reference" | "r"), ParsedHashDirectiveArguments args, m) ->
matchedm <- m
ProcessDependencyManagerDirective Directive.Resolution args m state

Expand Down
22 changes: 5 additions & 17 deletions src/Compiler/Service/FSharpCheckerResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ type FSharpSymbolUse(denv: DisplayEnv, symbol: FSharpSymbol, inst: TyparInstanti
// 'seq' in 'seq { ... }' gets colored as keywords
| Item.Value vref, ItemOccurence.Use when valRefEq denv.g denv.g.seq_vref vref -> true
// custom builders, custom operations get colored as keywords
| (Item.CustomBuilder _
| Item.CustomOperation _),
ItemOccurence.Use -> true
| (Item.CustomBuilder _ | Item.CustomOperation _), ItemOccurence.Use -> true
| _ -> false

member _.IsFromOpenStatement = itemOcc = ItemOccurence.Open
Expand Down Expand Up @@ -2306,14 +2304,8 @@ module internal ParseAndCheckFile =

matchBraces stackAfterMatch

| LPAREN
| LBRACE _
| LBRACK
| LBRACE_BAR
| LBRACK_BAR
| LQUOTE _
| LBRACK_LESS as tok,
_ -> matchBraces ((tok, lexbuf.LexemeRange) :: stack)
| LPAREN | LBRACE _ | LBRACK | LBRACE_BAR | LBRACK_BAR | LQUOTE _ | LBRACK_LESS as tok, _ ->
matchBraces ((tok, lexbuf.LexemeRange) :: stack)

// INTERP_STRING_BEGIN_PART corresponds to $"... {" at the start of an interpolated string
//
Expand All @@ -2322,19 +2314,15 @@ module internal ParseAndCheckFile =
// interpolation expression)
//
// Either way we start a new potential match at the last character
| INTERP_STRING_BEGIN_PART _
| INTERP_STRING_PART _ as tok,
_ ->
| INTERP_STRING_BEGIN_PART _ | INTERP_STRING_PART _ as tok, _ ->
let m = lexbuf.LexemeRange

let m2 =
mkFileIndexRange m.FileIndex (mkPos m.End.Line (max (m.End.Column - 1) 0)) m.End

matchBraces ((tok, m2) :: stack)

| (EOF _
| LEX_FAILURE _),
_ -> ()
| (EOF _ | LEX_FAILURE _), _ -> ()
| _ -> matchBraces stack

matchBraces [])
Expand Down
6 changes: 2 additions & 4 deletions src/Compiler/Service/SemanticClassification.fs
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,8 @@ module TcResolutionsExtensions =
resolutions
|> Array.iter (fun cnr ->
match cnr.Item, cnr.ItemOccurence, cnr.Range with
| (Item.CustomBuilder _
| Item.CustomOperation _),
ItemOccurence.Use,
m -> add m SemanticClassificationType.ComputationExpression
| (Item.CustomBuilder _ | Item.CustomOperation _), ItemOccurence.Use, m ->
add m SemanticClassificationType.ComputationExpression

| Item.Value vref, _, m when isValRefMutable g vref -> add m SemanticClassificationType.MutableVar

Expand Down
10 changes: 3 additions & 7 deletions src/Compiler/Service/ServiceLexing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,9 @@ module internal TokenClassifications =
// (this isn't entirely correct, but it'll work for now - see bug 3727)
(FSharpTokenColorKind.Number, FSharpTokenCharKind.Operator, FSharpTokenTriggerClass.None)

| INFIX_STAR_DIV_MOD_OP ("mod"
| "land"
| "lor"
| "lxor")
| INFIX_STAR_STAR_OP ("lsl"
| "lsr"
| "asr") -> (FSharpTokenColorKind.Keyword, FSharpTokenCharKind.Keyword, FSharpTokenTriggerClass.None)
| INFIX_STAR_DIV_MOD_OP ("mod" | "land" | "lor" | "lxor")
| INFIX_STAR_STAR_OP ("lsl" | "lsr" | "asr") ->
(FSharpTokenColorKind.Keyword, FSharpTokenCharKind.Keyword, FSharpTokenTriggerClass.None)

| LPAREN_STAR_RPAREN
| DOLLAR
Expand Down
5 changes: 1 addition & 4 deletions src/Compiler/Service/ServiceParsedInputOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2037,10 +2037,7 @@ module ParsedInput =
result <- Some(oldScope, oldPos, true)
| Some (oldScope, oldPos, _), _ ->
match kind, oldScope.Kind with
| (Namespace
| NestedModule
| TopModule),
OpenDeclaration
| (Namespace | NestedModule | TopModule), OpenDeclaration
| _ when oldPos.Line <= line ->
result <-
Some(
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/TypedTree/QuotationPickler.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/// Code to pickle out quotations in the quotation binary format.
module internal FSharp.Compiler.QuotationPickler

#nowarn "1178"

type TypeData
Expand Down
1 change: 1 addition & 0 deletions src/FSharp.Core/local.fsi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Microsoft.FSharp.Core

open Microsoft.FSharp.Core

[<AutoOpen>]
Expand Down
13 changes: 3 additions & 10 deletions src/FSharp.Core/quotations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -942,14 +942,8 @@ module Patterns =
| VarSetOp, _
| AddressSetOp, _ -> typeof<Unit>
| AddressOfOp, [ expr ] -> (typeOf expr).MakeByRefType()
| (AddressOfOp
| QuoteOp _
| SequentialOp
| TryWithOp
| TryFinallyOp
| IfThenElseOp
| AppOp),
_ -> failwith "unreachable"
| (AddressOfOp | QuoteOp _ | SequentialOp | TryWithOp | TryFinallyOp | IfThenElseOp | AppOp), _ ->
failwith "unreachable"

//--------------------------------------------------------------------------
// Constructors for building Raw quotations
Expand Down Expand Up @@ -2933,8 +2927,7 @@ module DerivedPatterns =
let (|SpecificCall|_|) templateParameter =
// Note: precomputation
match templateParameter with
| (Lambdas (_, Call (_, minfo1, _))
| Call (_, minfo1, _)) ->
| (Lambdas (_, Call (_, minfo1, _)) | Call (_, minfo1, _)) ->
let isg1 = minfo1.IsGenericMethod

let gmd =
Expand Down
1 change: 1 addition & 0 deletions src/FSharp.Core/seqcore.fsi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Microsoft.FSharp.Collections

open System
open System.Collections
open System.Collections.Generic
Expand Down