diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index a1cb3b8063b..7d7ba39a0e4 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -4369,6 +4369,9 @@ and TcTypeOrMeasure kindOpt (cenv: cenv) newOk checkConstraints occ (iwsam: Warn // The inner types are expected to be collected by (|TypesForTypar|) at this point. error(Error((FSComp.SR.tcSynTypeOrInvalidInDeclaration()), m)) + | SynType.FromParseError _ -> + NewErrorType (), tpenv + and CheckIWSAM (cenv: cenv) (env: TcEnv) checkConstraints iwsam m tcref = let g = cenv.g let ty = generalizedTyconRef g tcref @@ -4561,6 +4564,10 @@ and TcTypeMeasureApp kindOpt (cenv: cenv) newOk checkConstraints occ env tpenv a | _ -> errorR(Error(FSComp.SR.tcTypeParameterInvalidAsTypeConstructor(), m)) NewErrorType (), tpenv + + | StripParenTypes(SynType.FromParseError _) -> + NewErrorType (), tpenv + | _ -> errorR(Error(FSComp.SR.tcIllegalSyntaxInTypeExpression(), m)) NewErrorType (), tpenv diff --git a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs index 12dd8b9c004..f20c95fa3d8 100644 --- a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs +++ b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs @@ -260,6 +260,7 @@ let visitSynType (t: SynType) : FileContentEntry list = | SynType.Or (lhsType, rhsType, _, _) -> let continuations = List.map visit [ lhsType; rhsType ] Continuation.concatenate continuations continuation + | SynType.FromParseError _ -> continuation [] visit t id diff --git a/src/Compiler/Service/ServiceParseTreeWalk.fs b/src/Compiler/Service/ServiceParseTreeWalk.fs index 9c81e015460..d9e7cf13954 100644 --- a/src/Compiler/Service/ServiceParseTreeWalk.fs +++ b/src/Compiler/Service/ServiceParseTreeWalk.fs @@ -849,7 +849,8 @@ module SyntaxTraversal = | SynType.AnonRecd _ | SynType.LongIdent _ | SynType.Var _ - | SynType.StaticConstant _ -> None + | SynType.StaticConstant _ + | SynType.FromParseError _ -> None visitor.VisitType(origPath, defaultTraverse, ty) diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index c7440012816..67f357943f0 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -685,7 +685,8 @@ module ParsedInput = | SynType.AnonRecd _ | SynType.LongIdent _ | SynType.Var _ - | SynType.StaticConstant _ -> None + | SynType.StaticConstant _ + | SynType.FromParseError _ -> None and walkClause clause = let (SynMatchClause (pat = pat; whenExpr = e1; resultExpr = e2)) = clause @@ -1701,7 +1702,8 @@ module ParsedInput = | SynType.Anon _ | SynType.AnonRecd _ | SynType.Var _ - | SynType.StaticConstant _ -> () + | SynType.StaticConstant _ + | SynType.FromParseError _ -> () and walkClause (SynMatchClause (pat = pat; whenExpr = e1; resultExpr = e2)) = walkPat pat diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index 452d174c73c..c3dec3074f3 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -441,6 +441,8 @@ type SynType = | Or of lhsType: SynType * rhsType: SynType * range: range * trivia: SynTypeOrTrivia + | FromParseError of range: range + member x.Range = match x with | SynType.App (range = m) @@ -459,7 +461,8 @@ type SynType = | SynType.MeasurePower (range = m) | SynType.Paren (range = m) | SynType.SignatureParameter (range = m) - | SynType.Or (range = m) -> m + | SynType.Or (range = m) + | SynType.FromParseError (range = m) -> m | SynType.LongIdent lidwd -> lidwd.Range [] diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 575673804f5..575e13b8df7 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -518,6 +518,9 @@ type SynType = /// F# syntax: ^a or ^b, used in trait calls | Or of lhsType: SynType * rhsType: SynType * range: range * trivia: SynTypeOrTrivia + /// A type arising from a parse error + | FromParseError of range: range + /// Gets the syntax range of this construct member Range: range diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index c9de7544463..74021c8c9ac 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -8389,6 +8389,8 @@ FSharp.Compiler.Syntax.SynType+Array: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynType+Array: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynType+Array: Int32 get_rank() FSharp.Compiler.Syntax.SynType+Array: Int32 rank +FSharp.Compiler.Syntax.SynType+FromParseError: FSharp.Compiler.Text.Range get_range() +FSharp.Compiler.Syntax.SynType+FromParseError: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.Syntax.SynType argType FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.Syntax.SynType get_argType() FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.Syntax.SynType get_returnType() @@ -8463,6 +8465,7 @@ FSharp.Compiler.Syntax.SynType+Tags: Int32 Anon FSharp.Compiler.Syntax.SynType+Tags: Int32 AnonRecd FSharp.Compiler.Syntax.SynType+Tags: Int32 App FSharp.Compiler.Syntax.SynType+Tags: Int32 Array +FSharp.Compiler.Syntax.SynType+Tags: Int32 FromParseError FSharp.Compiler.Syntax.SynType+Tags: Int32 Fun FSharp.Compiler.Syntax.SynType+Tags: Int32 HashConstraint FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdent @@ -8497,6 +8500,7 @@ FSharp.Compiler.Syntax.SynType: Boolean IsAnon FSharp.Compiler.Syntax.SynType: Boolean IsAnonRecd FSharp.Compiler.Syntax.SynType: Boolean IsApp FSharp.Compiler.Syntax.SynType: Boolean IsArray +FSharp.Compiler.Syntax.SynType: Boolean IsFromParseError FSharp.Compiler.Syntax.SynType: Boolean IsFun FSharp.Compiler.Syntax.SynType: Boolean IsHashConstraint FSharp.Compiler.Syntax.SynType: Boolean IsLongIdent @@ -8515,6 +8519,7 @@ FSharp.Compiler.Syntax.SynType: Boolean get_IsAnon() FSharp.Compiler.Syntax.SynType: Boolean get_IsAnonRecd() FSharp.Compiler.Syntax.SynType: Boolean get_IsApp() FSharp.Compiler.Syntax.SynType: Boolean get_IsArray() +FSharp.Compiler.Syntax.SynType: Boolean get_IsFromParseError() FSharp.Compiler.Syntax.SynType: Boolean get_IsFun() FSharp.Compiler.Syntax.SynType: Boolean get_IsHashConstraint() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdent() @@ -8533,6 +8538,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewAnon(FSharp.Co FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewAnonRecd(Boolean, Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[FSharp.Compiler.Syntax.Ident,FSharp.Compiler.Syntax.SynType]], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewApp(FSharp.Compiler.Syntax.SynType, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Boolean, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewArray(Int32, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFromParseError(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFun(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewHashConstraint(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdent(FSharp.Compiler.Syntax.SynLongIdent) @@ -8551,6 +8557,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Anon FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+AnonRecd FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+App FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Array +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+FromParseError FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Fun FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+HashConstraint FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+LongIdent 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 c9de7544463..74021c8c9ac 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 @@ -8389,6 +8389,8 @@ FSharp.Compiler.Syntax.SynType+Array: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynType+Array: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynType+Array: Int32 get_rank() FSharp.Compiler.Syntax.SynType+Array: Int32 rank +FSharp.Compiler.Syntax.SynType+FromParseError: FSharp.Compiler.Text.Range get_range() +FSharp.Compiler.Syntax.SynType+FromParseError: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.Syntax.SynType argType FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.Syntax.SynType get_argType() FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.Syntax.SynType get_returnType() @@ -8463,6 +8465,7 @@ FSharp.Compiler.Syntax.SynType+Tags: Int32 Anon FSharp.Compiler.Syntax.SynType+Tags: Int32 AnonRecd FSharp.Compiler.Syntax.SynType+Tags: Int32 App FSharp.Compiler.Syntax.SynType+Tags: Int32 Array +FSharp.Compiler.Syntax.SynType+Tags: Int32 FromParseError FSharp.Compiler.Syntax.SynType+Tags: Int32 Fun FSharp.Compiler.Syntax.SynType+Tags: Int32 HashConstraint FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdent @@ -8497,6 +8500,7 @@ FSharp.Compiler.Syntax.SynType: Boolean IsAnon FSharp.Compiler.Syntax.SynType: Boolean IsAnonRecd FSharp.Compiler.Syntax.SynType: Boolean IsApp FSharp.Compiler.Syntax.SynType: Boolean IsArray +FSharp.Compiler.Syntax.SynType: Boolean IsFromParseError FSharp.Compiler.Syntax.SynType: Boolean IsFun FSharp.Compiler.Syntax.SynType: Boolean IsHashConstraint FSharp.Compiler.Syntax.SynType: Boolean IsLongIdent @@ -8515,6 +8519,7 @@ FSharp.Compiler.Syntax.SynType: Boolean get_IsAnon() FSharp.Compiler.Syntax.SynType: Boolean get_IsAnonRecd() FSharp.Compiler.Syntax.SynType: Boolean get_IsApp() FSharp.Compiler.Syntax.SynType: Boolean get_IsArray() +FSharp.Compiler.Syntax.SynType: Boolean get_IsFromParseError() FSharp.Compiler.Syntax.SynType: Boolean get_IsFun() FSharp.Compiler.Syntax.SynType: Boolean get_IsHashConstraint() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdent() @@ -8533,6 +8538,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewAnon(FSharp.Co FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewAnonRecd(Boolean, Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[FSharp.Compiler.Syntax.Ident,FSharp.Compiler.Syntax.SynType]], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewApp(FSharp.Compiler.Syntax.SynType, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Boolean, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewArray(Int32, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFromParseError(FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFun(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewHashConstraint(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdent(FSharp.Compiler.Syntax.SynLongIdent) @@ -8551,6 +8557,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Anon FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+AnonRecd FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+App FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Array +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+FromParseError FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Fun FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+HashConstraint FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+LongIdent