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 docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
* Debug: rework for expressions stepping ([PR #19894](https://github.com/dotnet/fsharp/pull/19894))
* Debug: rework conditional erasure, fix stepping over literals ([PR #19897](https://github.com/dotnet/fsharp/pull/19897))
* Debug: fix if and match condition sequence points ([PR #19932](https://github.com/dotnet/fsharp/pull/19932))
* Checker: recover on checking language version ([PR ##19970](https://github.com/dotnet/fsharp/pull/19970))

### Changed

Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ let TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) =
let TcOpenTypeDecl (cenv: cenv) mOpenDecl scopem env (synType: SynType, m) =
let g = cenv.g

checkLanguageFeatureError g.langVersion LanguageFeature.OpenTypeDeclaration mOpenDecl
checkLanguageFeatureAndRecover g.langVersion LanguageFeature.OpenTypeDeclaration mOpenDecl

let ty, _tpenv = TcType cenv NoNewTypars CheckCxs ItemOccurrence.Open WarnOnIWSAM.Yes env emptyUnscopedTyparEnv synType

Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Checking/CheckFormatStrings.fs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ let parseFormatStringInternal
let ch = fmt[i]
match ch with
| 'd' | 'i' | 'u' | 'B' | 'o' | 'x' | 'X' ->
if ch = 'B' then checkLanguageFeatureError g.langVersion Features.LanguageFeature.PrintfBinaryFormat m
if ch = 'B' then checkLanguageFeatureAndRecover g.langVersion Features.LanguageFeature.PrintfBinaryFormat m
if info.precision then failwith (FSComp.SR.forFormatDoesntSupportPrecision(ch.ToString()))
collectSpecifierLocation fragLine fragCol 1
let i = skipPossibleInterpolationHole (i+1)
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Checking/CheckPatterns.fs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ and TcPat warnOnUpper (cenv: cenv) env valReprInfo vFlags (patEnv: TcPatLinearEn

match synPat with
| SynPat.As (_, SynPat.Named _, _) -> ()
| SynPat.As (_, _, m) -> checkLanguageFeatureError g.langVersion LanguageFeature.NonVariablePatternsToRightOfAsPatterns m
| SynPat.As (_, _, m) -> checkLanguageFeatureAndRecover g.langVersion LanguageFeature.NonVariablePatternsToRightOfAsPatterns m
| _ -> ()

match synPat with
Expand Down
14 changes: 7 additions & 7 deletions src/Compiler/Checking/Expressions/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5391,7 +5391,7 @@ and TcPatLongIdentActivePatternCase warnOnUpper (cenv: cenv) (env: TcEnv) vFlags

// partial active pattern (returning bool) doesn't have output arg
if (not apinfo.IsTotal && isBoolTy g retTy) then
checkLanguageFeatureError g.langVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern m
checkLanguageFeatureAndRecover g.langVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern m
if paramCount = List.length args then
args, SynPat.Const(SynConst.Unit, m)
else
Expand Down Expand Up @@ -5946,7 +5946,7 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE

| SynExpr.InterpolatedString (parts, _, m) ->
TcNonControlFlowExpr env <| fun env ->
checkLanguageFeatureError g.langVersion LanguageFeature.StringInterpolation m
checkLanguageFeatureAndRecover g.langVersion LanguageFeature.StringInterpolation m
CallExprHasTypeSink cenv.tcSink (m, env.NameEnv, overallTy.Commit, env.AccessRights)
TcInterpolatedStringExpr cenv overallTy env m tpenv parts

Expand Down Expand Up @@ -11438,11 +11438,11 @@ and TcNormalizedBinding declKind (cenv: cenv) env tpenv overallTy safeThisValOpt

match apRetTy with
| ActivePatternReturnKind.Boolean ->
checkLanguageFeatureError g.langVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern mBinding
checkLanguageFeatureAndRecover g.langVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern mBinding
| ActivePatternReturnKind.StructTypeWrapper when not isStructRetTy ->
checkLanguageFeatureError g.langVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern mBinding
checkLanguageFeatureAndRecover g.langVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern mBinding
| ActivePatternReturnKind.StructTypeWrapper ->
checkLanguageFeatureError g.langVersion LanguageFeature.StructActivePattern mBinding
checkLanguageFeatureAndRecover g.langVersion LanguageFeature.StructActivePattern mBinding
| ActivePatternReturnKind.RefTypeWrapper -> ()

UnifyTypes cenv env mBinding (apinfo.ResultType g m activePatResTys apRetTy) apReturnTy
Expand Down Expand Up @@ -11933,7 +11933,7 @@ and TcLetBinding (cenv: cenv) isUse env containerInfo declKind tpenv (synBinds,
if not isDiscarded then
errorR(Error(FSComp.SR.tcInvalidUseBinding(), m))
else
checkLanguageFeatureError g.langVersion LanguageFeature.UseBindingValueDiscard checkedPat.Range
checkLanguageFeatureAndRecover g.langVersion LanguageFeature.UseBindingValueDiscard checkedPat.Range

elif isFixed then
errorR(Error(FSComp.SR.tcInvalidUseBinding(), m))
Expand Down Expand Up @@ -12287,7 +12287,7 @@ and CheckForNonAbstractInterface (g: TcGlobals) declKind tcref (memberFlags: Syn
if not isMemberStatic then
error(Error(FSComp.SR.tcConcreteMembersIllegalInInterface(), m))
else
checkLanguageFeatureError g.langVersion LanguageFeature.StaticMembersInInterfaces m
checkLanguageFeatureAndRecover g.langVersion LanguageFeature.StaticMembersInInterfaces m

//-------------------------------------------------------------------------
// TcLetrecBindings - AnalyzeAndMakeAndPublishRecursiveValue s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,22 @@ match "A" with
Result")
(Error 3868, Line 13, Col 3, Line 13, Col 30, "This active pattern does not expect any arguments, i.e., it should be used like 'IsA' instead of 'IsA x'.")
]

[<Fact>]
let ``Language version check`` () =
FSharp """
let (|LessThan|_|) (other: int) x = x <= other

match 1 with
| LessThan "" -> UnresolvedName
| _ -> ()
"""
|> withLangVersion80
|> typecheck
|> shouldFail
|> withDiagnostics [
Error 3350, Line 2, Col 6, Line 2, Col 18, "Feature 'Boolean-returning and return-type-directed partial active patterns' is not available in F# 8.0. Please use language version 9.0 or greater."
Error 3350, Line 5, Col 3, Line 5, Col 14, "Feature 'Boolean-returning and return-type-directed partial active patterns' is not available in F# 8.0. Please use language version 9.0 or greater."
Error 1, Line 5, Col 12, Line 5, Col 14, "This expression was expected to have type\n 'int' \n but here has type\n 'string' "
Error 39, Line 5, Col 18, Line 5, Col 32, "The value or constructor 'UnresolvedName' is not defined."
]
Loading