Skip to content
Draft
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
@@ -1,5 +1,6 @@
### Fixed

* Reject non-function bindings for single-case and partial active pattern names with FS1209, matching the existing multi-case behavior. ([PR #19763](https://github.com/dotnet/fsharp/pull/19763))
* Fix attributes on return type of unparenthesized tuple methods being silently dropped from IL. ([Issue #462](https://github.com/dotnet/fsharp/issues/462), [PR #19714](https://github.com/dotnet/fsharp/pull/19714))
* Fix internal error FS0073 "Undefined or unsolved type variable" in IlxGen when nested inline SRTP functions with multiple overloads leave unsolved typars in the non-witness codegen path. ([Issue #19709](https://github.com/dotnet/fsharp/issues/19709), [PR #19710](https://github.com/dotnet/fsharp/pull/19710))
* Fix NRE when calling virtual Object methods on value types through inline SRTP functions. ([Issue #8098](https://github.com/dotnet/fsharp/issues/8098), [PR #19511](https://github.com/dotnet/fsharp/pull/19511))
Expand Down
8 changes: 5 additions & 3 deletions src/Compiler/Checking/PostInferenceChecks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2089,10 +2089,12 @@ and CheckBinding cenv env alwaysCheckNoReraise ctxt (TBind(v, bindRhs, _) as bin

let env = { env with external = env.external || ValHasWellKnownAttribute g WellKnownValAttributes.DllImportAttribute v }

// Check that active patterns don't have free type variables in their result
// Check active pattern shape/type constraints
match TryGetActivePatternInfo vref with
| Some _apinfo when _apinfo.ActiveTags.Length > 1 ->
if doesActivePatternHaveFreeTypars g vref then
| Some apinfo ->
let hasFreeTypars = doesActivePatternHaveFreeTypars g vref

if apinfo.ActiveTags.Length > 1 && hasFreeTypars then
errorR(Error(FSComp.SR.activePatternChoiceHasFreeTypars(v.LogicalName), v.Range))
| _ -> ()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ module ActivePatterns =
|) _ = (|
A
|)
let (|C|) =
let (|C|) _ =
if true then ignore (|
A
|)
Expand All @@ -255,7 +255,7 @@ module ActivePatterns =
F
|
_
|) as f = Some (|
|) _ = Some (|
C
|)
let (|
Expand Down Expand Up @@ -1265,7 +1265,7 @@ type ActivePatterns() =
|) = (|
A
|)
let (|C|) =
let (|C|) _ =
if true then ignore (|
A
|)
Expand All @@ -1283,7 +1283,7 @@ type ActivePatterns() =
F
|
_
|) as f = Some (|
|) _ = Some (|
C
|)
let (|
Expand All @@ -1305,7 +1305,7 @@ type ActivePatterns() =
|) = (|
A_
|)
static let (|C_|) =
static let (|C_|) _ =
if true then ignore (|
A_
|)
Expand All @@ -1323,7 +1323,7 @@ type ActivePatterns() =
F_
|
_
|) as f_ = Some (|
|) _ = Some (|
C_
|)
static let (|
Expand Down Expand Up @@ -2593,7 +2593,7 @@ let ActivePatterns<'a> =
|) _ = (|
A
|)
let (|C|) =
let (|C|) _ =
if true then ignore (|
A
|)
Expand All @@ -2611,7 +2611,7 @@ let ActivePatterns<'a> =
F
|
_
|) as f = Some (|
|) _ = Some (|
C
|)
let (|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// #Regression #Conformance #PatternMatching #ActivePatterns
// Regression test for FSHARP1.0:5590
//<Expects status="error" span="(5,6-5,11)" id="FS1209">Active pattern '|A|B|' is not a function$</Expects>
//<Expects status="error" span="(7,6-7,11)" id="FS1209">Active pattern '|A|B|' is not a function$</Expects>
//<Expects status="error" span="(8,6-8,9)" id="FS1209">Active pattern '|C|' is not a function$</Expects>
//<Expects status="error" span="(9,6-9,11)" id="FS1209">Active pattern '|D|_|' is not a function$</Expects>

let (|A|B|) = failwith "" : Choice<int,int>
let (|C|) = 3
let (|D|_|) = None
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ module Named =
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Error 1209, Line 5, Col 6, Line 5, Col 11, "Active pattern '|A|B|' is not a function")
|> withDiagnostics [
(Error 1209, Line 7, Col 6, Line 7, Col 11, "Active pattern '|A|B|' is not a function")
(Error 1209, Line 8, Col 6, Line 8, Col 9, "Active pattern '|C|' is not a function")
(Error 1209, Line 9, Col 6, Line 9, Col 11, "Active pattern '|D|_|' is not a function")
]

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named)
[<Theory; FileInlineData("E_ActivePatterns01.fs")>]
Expand Down Expand Up @@ -621,4 +625,4 @@ but here has type
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed
|> shouldSucceed
Loading